:root {
  --sand: #c9a15b;
  --indigo: #2a2450;
  --amber: #e08a3c;
  --teal: #4a8b8a;
  --rose: #b56b6b;
  --cream: #efe6d2;
  --navy: #0c0a16;
  --ink: #1a1630;
  --display: "Cinzel", Georgia, serif;
  --body: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--navy);
  color: var(--cream);
  font-family: var(--body);
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, #2a2450 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(224, 138, 60, 0.08), transparent 40%),
    #0c0a16;
}

#page {
  width: min(980px, 96vw);
  padding: 18px 8px 10px;
}

#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 540;
  background: #16122a;
  box-shadow:
    0 0 0 2px var(--sand),
    0 0 0 6px #1a1630,
    0 24px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  border-radius: 2px;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

#credit {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7a6f58;
}

/* ---- HUD ---- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-shadow: 0 1px 2px #000;
}

#hud-left, #hud-right {
  font-size: 14px;
  line-height: 1.35;
}

#hud-left strong, #hud-right strong {
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--sand);
}

.beads { letter-spacing: 1px; }
.bead-hp { color: #e08a3c; }
.bead-mp { color: #7ec8c4; }
.bead-empty { color: #3a3458; }

#nim-caption {
  pointer-events: none;
  align-self: flex-start;
  max-width: 72%;
  margin-bottom: 52px;
  padding: 6px 10px 7px;
  background: rgba(20, 16, 36, 0.72);
  border-left: 3px solid var(--amber);
  color: var(--cream);
  font-size: 14px;
  font-style: italic;
}

/* ---- touch bar ---- */
#touch {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 6px;
  padding: 8px;
  pointer-events: auto;
  background: linear-gradient(transparent, rgba(8, 6, 16, 0.85));
}

#touch button, .btn, .icon-btn {
  font-family: var(--display);
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 1px solid var(--sand);
  background: rgba(42, 36, 80, 0.88);
  color: var(--cream);
  padding: 8px 12px;
}

#touch button { flex: 1; font-size: 12px; }

#touch button:hover, .btn:hover, .icon-btn:hover {
  background: #3a3366;
  color: #fff;
}

.btn.gold {
  background: linear-gradient(180deg, #e8c57a, #c9a15b);
  color: #1a1630;
  border-color: #efe6d2;
  font-size: 18px;
  padding: 10px 28px;
}

.btn.gold:hover { filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  font-size: 14px;
  padding: 8px 16px;
}

.icon-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  z-index: 5;
  pointer-events: auto;
}

/* ---- title ---- */
#title-screen {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(12, 10, 22, 0.15), rgba(12, 10, 22, 0.55)),
    url("../art/key-art.png") center / cover no-repeat,
    #2a2450;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  z-index: 8;
}

.title-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(12, 10, 22, 0.72) 0%, rgba(12, 10, 22, 0.15) 58%, transparent 100%);
  pointer-events: none;
}

.title-copy {
  position: relative;
  padding: 36px 40px 32px;
  max-width: 520px;
}

.kicker {
  font-family: var(--display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--sand);
  margin-bottom: 6px;
}

.title-copy h1 {
  font-family: var(--display);
  font-size: clamp(36px, 7vw, 58px);
  line-height: 0.95;
  color: var(--cream);
  text-shadow: 0 2px 0 #1a1630, 0 8px 24px rgba(0, 0, 0, 0.5);
}

.title-copy .sub {
  margin: 8px 0 18px;
  color: var(--amber);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 13px;
}

.title-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.title-copy .hint {
  font-size: 12px;
  color: #cbbca0;
  letter-spacing: 0.04em;
}

/* ---- modal / parchment ---- */
#modal-root {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

#modal-root .shade {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 20, 0.55);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.panel {
  width: min(520px, 92%);
  max-height: 90%;
  overflow: auto;
  background:
    linear-gradient(180deg, #f3ead4, #e6d3aa);
  color: var(--ink);
  border: 3px solid #8a6a32;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #efe6d2;
  padding: 18px 20px 16px;
}

.panel h2 {
  font-family: var(--display);
  font-size: 20px;
  color: #2a2450;
  margin-bottom: 8px;
}

.panel p { margin: 0 0 10px; font-size: 15px; line-height: 1.45; }

.panel .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(42, 36, 80, 0.12);
  font-size: 15px;
}

.panel .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.panel .btn {
  border-color: #5a3e18;
  background: #2a2450;
  color: var(--cream);
}

.panel .btn.gold { color: #1a1630; }

.speaker {
  font-family: var(--display);
  color: #7a3a2a;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- banner / toast ---- */
#banner {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 18, 0.72);
  pointer-events: auto;
}

#banner .banner-card {
  text-align: center;
  padding: 28px 36px;
  max-width: 520px;
}

#banner h2 {
  font-family: var(--display);
  font-size: 28px;
  color: var(--sand);
  margin-bottom: 10px;
}

#banner p { color: var(--cream); margin-bottom: 16px; }

#toast {
  position: absolute;
  top: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  background: rgba(20, 16, 36, 0.9);
  border: 1px solid var(--sand);
  color: var(--cream);
  padding: 6px 14px;
  font-size: 14px;
  pointer-events: none;
}

.hidden { display: none !important; }

@media (max-width: 700px) {
  #nim-caption { margin-bottom: 58px; font-size: 13px; }
  .title-copy { padding: 20px; }
  #touch button { font-size: 11px; padding: 8px 4px; }
}
