/*
=====================================================================
 YOUMANJI LAYOUT AND COMPONENTS
=====================================================================
*/

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--parchment);
  background-color: var(--jungle-deepest);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ==================================================================
   SCREENS
   ================================================================== */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-slow) var(--ease-out),
              visibility var(--t-slow) var(--ease-out);
  z-index: 1;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  z-index: 2;
}

/* The board screen scrolls on short viewports */
#screen-board {
  justify-content: flex-start;
  overflow-y: auto;
  padding: 20px 16px 40px;
}

/* ==================================================================
   VIGNETTE / JUNGLE FRAME
   [ART] Replace with real vine & leaf artwork
   ================================================================== */

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background:
    radial-gradient(ellipse at center, transparent 52%, rgba(3, 10, 6, 0.82) 100%);
}

/* ==================================================================
   TITLE SCREEN
   ================================================================== */

.title-mark {
  text-align: center;
  margin-bottom: 8px;
}

/* [ART] Placeholder logotype. Swap for the real YOUMANJI logo */
.title-mark h1 {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--brass);
  text-shadow:
    0 2px 0 var(--wood-dark),
    0 5px 18px rgba(0, 0, 0, 0.8),
    0 0 46px rgba(201, 162, 39, 0.28);
}

.title-mark .tagline {
  margin-top: 20px;
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--parchment-deep);
}

.title-mark .blurb {
  max-width: 30rem;
  margin: 26px auto 0;
  color: var(--parchment-dim);
  line-height: 1.65;
  font-style: italic;
}

/* --- The big START button ----------------------------------------- */

.start-btn {
  position: relative;
  margin-top: 52px;
  padding: 26px 68px;
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-size: clamp(1.3rem, 3.4vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--wood-dark);
  background: linear-gradient(175deg, var(--brass-bright), var(--brass) 55%, var(--brass-dim));
  box-shadow: var(--shadow-raise);
  transition: transform var(--t-fast) var(--ease-bump),
              box-shadow var(--t-fast) var(--ease-out);
  animation: pulse-glow 2.8s ease-in-out infinite;
}

.start-btn:hover {
  transform: translateY(-3px);
}

.start-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 6px 14px rgba(0, 0, 0, 0.5);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--shadow-raise), 0 0 0 0 rgba(201, 162, 39, 0.5); }
  50%      { box-shadow: var(--shadow-raise), 0 0 40px 12px rgba(201, 162, 39, 0.12); }
}

/* ==================================================================
   PLAYER SELECT (age bands)
   ================================================================== */

.section-heading {
  font-family: var(--font-heading);
  font-size: var(--fs-title);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  text-align: center;
}

.section-sub {
  margin-top: 12px;
  margin-bottom: 40px;
  color: var(--parchment-dim);
  text-align: center;
  font-style: italic;
}

.player-grid {
  display: grid;
  /* Flows 5 across on desktop, then wraps down to 2 on phones */
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1020px;
}

.player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 14px 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(201, 162, 39, 0.28);
  background-color: rgba(20, 48, 38, 0.72);
  box-shadow: var(--shadow-sink);
  transition: transform var(--t-fast) var(--ease-bump),
              border-color var(--t-fast) var(--ease-out),
              background-color var(--t-fast) var(--ease-out);
}

.player-card:hover,
.player-card:focus-visible {
  transform: translateY(-6px);
  border-color: var(--brass);
  background-color: rgba(30, 68, 51, 0.9);
  outline: none;
}

/* [ART] Placeholder pawn. Swap for carved animal tokens */
.player-token {
  width: 54px;
  height: 54px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.5), transparent 55%),
              var(--token-color, var(--brass));
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4), 0 10px 18px rgba(0, 0, 0, 0.5);
}

.player-age {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--parchment);
}

.player-grade {
  font-size: var(--fs-sm);
  color: var(--parchment-deep);
  text-align: center;
  line-height: 1.4;
}

/* ==================================================================
   BOARD
   ================================================================== */

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: var(--board-size);
  margin-bottom: 14px;
}

.board-header .brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.2em;
  color: var(--brass);
}

.ghost-btn {
  font-family: var(--font-heading);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--parchment-deep);
  padding: 7px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 162, 39, 0.28);
  transition: var(--t-fast);
}

.ghost-btn:hover {
  color: var(--brass);
  border-color: var(--brass);
}

.board-wrap {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-card), var(--shadow-sink);
  border: 10px solid var(--wood-dark);
}

#board-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* --- Spaces along the spiral --------------------------------------- */

.space {
  fill: rgba(233, 220, 187, 0.13);
  stroke: rgba(201, 162, 39, 0.35);
  stroke-width: 1.5;
  transition: fill var(--t-med) var(--ease-out),
              stroke var(--t-med) var(--ease-out);
}

.space.visited {
  fill: rgba(201, 162, 39, 0.28);
  stroke: var(--brass);
}

/* --- Station markers (Passion / Pain / Proficiency / Sweet Spot) ---- */

.station-ring {
  fill: rgba(7, 19, 13, 0.85);
  stroke: var(--station-color, var(--brass));
  stroke-width: 3;
  transition: var(--t-med) var(--ease-out);
}

.station.is-active .station-ring {
  filter: drop-shadow(0 0 14px var(--station-glow, var(--brass)));
  stroke-width: 4.5;
}

.station.is-done .station-ring {
  fill: var(--station-color, var(--brass));
  fill-opacity: 0.32;
}

.station-label {
  font-family: var(--font-heading);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  fill: var(--parchment);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  /* Dark halo keeps the word legible wherever it lands on the wood */
  stroke: rgba(10, 6, 2, 0.85);
  stroke-width: 5px;
  paint-order: stroke fill;
}

.station-num {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 700;
  fill: var(--station-color, var(--brass));
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* --- The center gem (Sweet Spot) ------------------------------------ */

.gem-core {
  fill: var(--gem);
  filter: drop-shadow(0 0 18px var(--gem-glow));
  opacity: 0.35;
  transition: opacity var(--t-slow) var(--ease-out);
}

.gem-core.lit {
  opacity: 1;
  animation: gem-throb 2.4s ease-in-out infinite;
}

@keyframes gem-throb {
  0%, 100% { filter: drop-shadow(0 0 16px var(--gem-glow)); }
  50%      { filter: drop-shadow(0 0 40px var(--gem-bright)); }
}

/* --- The pawn -------------------------------------------------------- */

.pawn {
  position: absolute;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50% 50% 44% 44%;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.6), transparent 52%),
              var(--token-color, var(--brass));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 8px 16px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 5;
  will-change: transform;
}

.pawn::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 26px;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  filter: blur(2px);
}

/* ==================================================================
   ROLL / ADVANCE CONTROL
   ================================================================== */

.roll-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
  min-height: 132px;
}

.die-btn {
  width: 82px;
  height: 82px;
  border-radius: 18px;
  background: linear-gradient(160deg, var(--parchment), var(--parchment-dim));
  box-shadow: var(--shadow-raise);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 13px;
  gap: 4px;
  transition: transform var(--t-fast) var(--ease-bump);
}

.die-btn:hover  { transform: translateY(-3px) rotate(-4deg); }
.die-btn:active { transform: translateY(2px) scale(0.96); }

.die-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.pip {
  border-radius: 50%;
  background: var(--wood-dark);
  opacity: 0;
}

.pip.on { opacity: 1; }

.die-btn.rolling { animation: die-tumble 620ms var(--ease-out); }

@keyframes die-tumble {
  0%   { transform: rotate(0deg)   scale(1); }
  30%  { transform: rotate(190deg) scale(1.16); }
  65%  { transform: rotate(310deg) scale(0.92); }
  100% { transform: rotate(360deg) scale(1); }
}

.roll-hint {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--parchment-deep);
  text-align: center;
  min-height: 1.2em;
}

/* ==================================================================
   STATION CARD (slides up when the pawn lands)
   ================================================================== */

.card-scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 6, 0.72);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: var(--t-med) var(--ease-out);
  z-index: 20;
}

.card-scrim.open {
  opacity: 1;
  visibility: visible;
}

.card {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(94vw, 720px);
  max-height: 88vh;
  overflow-y: auto;
  transform: translate(-50%, 105%);
  transition: transform var(--t-slow) var(--ease-out);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 3px solid var(--wood-dark);
  border-bottom: none;
  box-shadow: var(--shadow-card);
  color: var(--wood-dark);
  padding: 34px 30px 30px;
  z-index: 21;
}

.card.open { transform: translate(-50%, 0); }

.card-eyebrow {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--station-color, var(--wood));
  text-align: center;
}

.card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  text-align: center;
  margin-top: 8px;
  color: var(--wood-dark);
}

.card .prompt {
  text-align: center;
  margin: 14px auto 26px;
  max-width: 34rem;
  line-height: 1.6;
  color: var(--wood);
  font-style: italic;
}

/* --- Tag chooser ---------------------------------------------------- */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.tag {
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  color: var(--wood-dark);
  background: rgba(255, 255, 255, 0.42);
  border: 1.5px solid rgba(60, 40, 15, 0.28);
  transition: transform var(--t-fast) var(--ease-bump),
              background-color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

.tag:hover { transform: translateY(-2px); }

.tag.picked {
  background: var(--station-color, var(--brass));
  border-color: var(--wood-dark);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.custom-row {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  justify-content: center;
}

.custom-row input {
  flex: 1;
  max-width: 320px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(60, 40, 15, 0.3);
  background: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--wood-dark);
  outline: none;
}

.custom-row input:focus { border-color: var(--wood); }

.custom-row button,
.card-cta {
  font-family: var(--font-heading);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--wood-dark);
  color: var(--parchment);
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 0.82rem;
  transition: var(--t-fast);
}

.custom-row button:hover,
.card-cta:hover:not([disabled]) { background: var(--wood-light); }

.card-footer {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.card-cta {
  padding: 16px 44px;
  font-size: 0.95rem;
}

.card-cta[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.pick-count {
  font-size: var(--fs-sm);
  color: var(--wood);
  opacity: 0.75;
}

/* ==================================================================
   RESULTS (Sweet Spot)
   ================================================================== */

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.result-card {
  background: rgba(255, 255, 255, 0.34);
  border: 1.5px solid rgba(60, 40, 15, 0.22);
  border-radius: var(--radius);
  padding: 20px 18px;
}

.result-card h3 {
  font-family: var(--font-heading);
  font-size: 0.94rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wood-dark);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid rgba(60, 40, 15, 0.2);
}

.result-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.result-card li {
  position: relative;
  padding-left: 20px;
  line-height: 1.45;
  color: var(--wood);
}

.result-card li::before {
  content: '❖';
  position: absolute;
  left: 0;
  color: var(--brass-dim);
  font-size: 0.8em;
}

/* --- Recap of what they picked --------------------------------------- */

.recap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}

.recap .chip {
  font-size: 0.78rem;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(60, 40, 15, 0.2);
  color: var(--wood);
}

/* --- Loading / error -------------------------------------------------- */

.oracle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 36px 0;
  text-align: center;
}

.oracle .spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(60, 40, 15, 0.18);
  border-top-color: var(--wood-dark);
  animation: spin 900ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.oracle p {
  font-family: var(--font-heading);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--wood);
}

.fallback-note {
  margin-top: 16px;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--wood);
  opacity: 0.7;
  text-align: center;
}

/* ==================================================================
   RESPONSIVE
   ================================================================== */

@media (max-width: 720px) {
  /* Leave room either side for the radial station labels, which sit
     outside the board circle */
  :root {
    --board-size: min(78vw, 52vh, 700px);
  }

  .player-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card {
    padding: 26px 18px 22px;
  }

  .station-label { font-size: 26px; }
  .station-num   { font-size: 30px; }

  .start-btn {
    padding: 22px 44px;
  }
}

@media (max-width: 420px) {
  .player-grid { gap: 12px; }
  .tag { padding: 10px 15px; font-size: 0.88rem; }
}
