/* ============ Dragon Dash styles ============ */
* { box-sizing: border-box; }
:root {
  --ink: #1d1436;
  --parch: #fff7e6;
  --gold: #ffcb45;
  --gold-2: #ff9f1c;
  --grape: #6c4bd6;
  --grape-dk: #3a2570;
  --mint: #2fbf71;
  --rose: #ff5d8f;
  --sky: #48c9ff;
  --shadow: 0 10px 0 rgba(0,0,0,.25);
}
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  color: var(--parch);
  background:
    radial-gradient(1100px 620px at 15% -10%, #5b3fa8 0%, rgba(91,63,168,0) 60%),
    radial-gradient(900px 520px at 110% 20%, #2b6f9e 0%, rgba(43,111,158,0) 60%),
    linear-gradient(180deg, #1a1030 0%, #241645 55%, #14102a 100%);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100vh; padding: 14px; }
.hidden { display: none !important; }
.tiny { font-size: .72em; opacity: .8; font-weight: 600; }
b { color: #ffe9a8; }

/* ---------- buttons ---------- */
.bigBtn, .ghostBtn, .iconBtn, .seg {
  font-family: inherit; cursor: pointer; border: 0; user-select: none;
  transition: transform .08s ease, filter .15s ease, box-shadow .1s ease;
}
.bigBtn {
  background: linear-gradient(180deg, #ffd873, var(--gold-2));
  color: #3a2000; font-size: 1.35rem; font-weight: 800; letter-spacing: .4px;
  padding: 16px 26px; border-radius: 18px; box-shadow: 0 7px 0 #b96a09, 0 14px 24px rgba(0,0,0,.35);
}
.bigBtn:hover { filter: brightness(1.06); }
.bigBtn:active { transform: translateY(5px); box-shadow: 0 2px 0 #b96a09; }
.bigBtn[disabled] { filter: grayscale(.7) brightness(.75); cursor: not-allowed; box-shadow: 0 3px 0 #6b4a12; }
.ghostBtn {
  background: rgba(255,255,255,.12); color: var(--parch); font-size: 1rem; font-weight: 700;
  padding: 10px 16px; border-radius: 14px; border: 2px solid rgba(255,255,255,.25);
}
.ghostBtn:hover { background: rgba(255,255,255,.2); }
.iconBtn {
  background: rgba(255,255,255,.14); color: var(--parch); font-size: 1.15rem;
  width: 44px; height: 44px; border-radius: 13px; border: 2px solid rgba(255,255,255,.2);
}
.iconBtn:hover { background: rgba(255,255,255,.26); }
.iconBtn.is-off { opacity: .45; }

/* ---------- start screen ---------- */
.screen { display: flex; justify-content: center; }
.startCard {
  width: min(660px, 100%); background: rgba(255,255,255,.08); border: 2px solid rgba(255,203,69,.35);
  border-radius: 26px; padding: 22px 24px 26px; backdrop-filter: blur(6px);
  box-shadow: 0 24px 60px rgba(0,0,0,.45); text-align: center;
}
.crest { font-size: 3.6rem; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.gameTitle { font-size: clamp(2.4rem, 7vw, 3.5rem); margin: 4px 0 0; letter-spacing: 1px;
  background: linear-gradient(180deg, #fff3c4, #ffb03a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.subtitle { margin: 2px 0 12px; color: #c9b7ff; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; font-size: .9rem; }
.blurb { font-size: 1.02rem; line-height: 1.5; color: #efe6ff; margin: 0 auto 14px; max-width: 52ch; }
.fieldLabel { text-align: left; font-weight: 800; color: #ffd98a; margin: 14px 2px 6px; letter-spacing: .4px; }
.playerList { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.pRow { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.22); border: 2px solid rgba(255,255,255,.14); border-radius: 14px; padding: 8px; }
.pRow .pEmoji { font-size: 1.7rem; width: 38px; text-align: center; cursor: pointer; }
.pRow input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 1rem; font-weight: 700; color: #fff;
  background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.18); border-radius: 10px; padding: 9px 10px;
}
.pRow input:focus { outline: none; border-color: var(--gold); }
.pRow .cpuTag { font-size: .7rem; font-weight: 800; background: rgba(255,93,143,.3); border: 1px solid rgba(255,93,143,.6); color: #ffd9e6; padding: 3px 7px; border-radius: 99px; }
.segBar { display: flex; gap: 10px; flex-wrap: wrap; }
.seg {
  flex: 1 1 auto; min-width: 108px; background: rgba(0,0,0,.24); color: #e9dcff; font-weight: 800; font-size: .98rem;
  border: 2px solid rgba(255,255,255,.16); border-radius: 14px; padding: 10px 12px; line-height: 1.2;
}
.seg.is-on { background: linear-gradient(180deg, #8b6bff, var(--grape)); border-color: #ffd98a; color: #fff; box-shadow: 0 6px 16px rgba(108,75,214,.5); }
#startBtn { margin-top: 20px; width: 100%; }
.hallTeaser { margin-top: 14px; font-size: .95rem; color: #d8c9ff; }

/* ---------- game screen ---------- */
#gameScreen { flex-direction: column; }
.topbar {
  width: min(1180px, 100%); margin: 0 auto 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: rgba(0,0,0,.25); border: 2px solid rgba(255,255,255,.12); border-radius: 18px; padding: 8px 12px;
}
.brand { font-weight: 900; font-size: 1.15rem; letter-spacing: .5px; display: flex; gap: 6px; align-items: center; }
.brandEgg { font-size: 1.5rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.chip {
  display: flex; align-items: center; gap: 6px; font-size: .9rem; font-weight: 800;
  background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.18); border-radius: 99px; padding: 5px 10px;
}
.chip.is-turn { border-color: var(--gold); background: rgba(255,203,69,.2); transform: scale(1.06); }
.chip .cEgg { font-size: 1.1rem; }
.chip .cPos { opacity: .75; font-weight: 700; }
.chip .cShield { font-size: .85rem; }
.topActions { display: flex; gap: 6px; }

.play { width: min(1180px, 100%); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; align-items: start; }

/* ---------- board: an adventure map, not a spreadsheet ---------- */
.boardFrame {
  position: relative; padding: 16px 14px 14px;
  background:
    repeating-linear-gradient(180deg, rgba(0,0,0,.06) 0 3px, rgba(255,255,255,.02) 3px 7px),
    linear-gradient(180deg, #8a5a2f, #5d3a1c 60%, #43290f);
  border: 3px solid #2f1d0b; border-radius: 26px;
  box-shadow: 0 22px 45px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,220,170,.35), inset 0 -8px 18px rgba(0,0,0,.5);
}
.ribbon {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(-1deg); z-index: 8;
  background: linear-gradient(180deg, #fff2c4, #ffb03a); color: #4a2b05; font-weight: 900; font-size: .82rem;
  letter-spacing: .4px; padding: 5px 18px; border-radius: 99px; border: 2px solid #b9751a; white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
.boardWrap { position: relative; }
.boardMat {
  position: absolute; inset: 0; z-index: 0; border-radius: 18px; overflow: hidden;
  background:
    radial-gradient(90% 40% at 12% 100%, rgba(255,220,150,.45), transparent 62%),
    linear-gradient(180deg,
      #e8ecff 0%, #c9cef0 15.5%,
      #a488cc 16.5%, #7c60aa 32.5%,
      #5aa0cc 33.5%, #2f7ba8 49.5%,
      #35845c 50.5%, #22624a 66.5%,
      #86c461 67.5%, #5f9d45 82.5%,
      #d9b072 83.5%, #a87f45 100%);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.18), inset 0 -30px 60px rgba(0,0,0,.28);
}
.boardMat::after {
  content: ''; position: absolute; inset: 0; opacity: .35; mix-blend-mode: overlay;
  background-image: radial-gradient(rgba(255,255,255,.5) 1px, transparent 1.6px);
  background-size: 9px 9px;
}
.matDecor {
  position: absolute; transform: translate(-50%, -50%); line-height: 1; opacity: .92;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); user-select: none;
}
.trailLayer { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
.trailLayer polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trailLayer .trailWide { stroke: #f3dcb0; opacity: .95; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.trailLayer .trailMid { stroke: #e0c085; opacity: .9; }
.trailLayer .trailDashes { stroke: rgba(255,255,255,.9); stroke-dasharray: 2 16; opacity: .85; }

.board {
  position: relative; z-index: 3;
  display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr);
  gap: 14px; aspect-ratio: 7 / 6; width: 100%;
}

/* stones: organic pebbles, tinted by biome */
.tile {
  position: relative; margin: 4px; overflow: hidden; text-align: center; padding: 2px 2px 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 46% 54% 52% 48% / 52% 48% 54% 46%;
  background: linear-gradient(180deg, var(--stone1, #6a55a0), var(--stone2, #3b2a5e));
  border: 2px solid rgba(255,255,255,.4);
  box-shadow: 0 3px 0 rgba(0,0,0,.3), inset 0 3px 7px rgba(255,255,255,.24), inset 0 -7px 11px rgba(0,0,0,.26);
  transition: transform .14s ease, filter .14s ease;
}
.tile.sh-1 { border-radius: 52% 48% 44% 56% / 46% 54% 48% 52%; }
.tile.sh-2 { border-radius: 44% 56% 52% 48% / 55% 45% 50% 50%; }
.tile:hover { transform: translateY(-3px) scale(1.03); filter: brightness(1.08); z-index: 4; }
.z-village { --stone1: #d69a63; --stone2: #8a5427; }
.z-meadow  { --stone1: #93c072; --stone2: #4b7a3a; }
.z-woods   { --stone1: #5da286; --stone2: #2a5847; }
.z-river   { --stone1: #6bb1d6; --stone2: #2f6f96; }
.z-cliffs  { --stone1: #9d8ccf; --stone2: #4f3f7a; }
.z-peak    { --stone1: #b6c0ef; --stone2: #6a72ad; }
.tile .badge {
  position: absolute; top: 3px; left: 4px; min-width: 17px; height: 17px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: .64rem; font-weight: 900; line-height: 1; color: #4a2b05;
  background: rgba(255,247,225,.92); border-radius: 99px; box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.tile .flag { position: absolute; top: 1px; right: 3px; font-size: .82rem; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.tile .icn { font-size: clamp(1rem, 3vw, 1.85rem); line-height: 1.15; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.tile .tname {
  font-size: .55rem; font-weight: 900; letter-spacing: .2px; text-transform: uppercase; line-height: 1.05;
  margin-top: 1px; padding: 1px 5px; border-radius: 99px; background: rgba(0,0,0,.28); color: #fff6df;
  max-width: 96%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile.t-bridge { background: linear-gradient(180deg, #ffb3dc, #86e0ff); border-color: #fff6c8; color: #2b1046; }
.tile.t-slide { background: linear-gradient(180deg, #8b5cf0, #43265f); border-color: #d6a8ff; color: #ffe6ff; }
.tile.t-star { background: linear-gradient(180deg, #ffe07a, #ff9d2e); border-color: #fff8d8; color: #4a2800; }
.tile.t-treasure { background: linear-gradient(180deg, #6ff0d6, #2b8fb8); border-color: #e2fff8; color: #05303a; }
.tile.t-peak { background: linear-gradient(180deg, #fff4c6, #ffb03a); border-color: #fff; color: #40230a; }
.tile.t-star .tname, .tile.t-bridge .tname, .tile.t-slide .tname { background: rgba(255,255,255,.45); color: #3a2200; }
.tile.is-land { animation: pop .5s ease; }
.tile.is-glow { box-shadow: 0 0 0 4px rgba(255,203,69,.85), 0 3px 0 rgba(0,0,0,.3); }
.tile.is-start::after, .tile.is-goal::after {
  content: 'START'; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  font-size: .52rem; font-weight: 900; letter-spacing: .5px; padding: 1px 6px; border-radius: 99px;
  background: #2fbf71; color: #05331c;
}
.tile.is-goal::after { content: 'FINISH'; background: #ffd45e; color: #4a2800; }
.tile.is-start .tname, .tile.is-goal .tname { display: none; }
.tile.is-goal { animation: goalPulse 2.6s ease-in-out infinite; }
.tile.t-star { animation: starPulse 3.2s ease-in-out infinite; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.14) rotate(-2deg); } 100% { transform: scale(1); } }
@keyframes goalPulse { 0%, 100% { box-shadow: 0 3px 0 rgba(0,0,0,.3), 0 0 0 0 rgba(255,212,94,.6); } 50% { box-shadow: 0 3px 0 rgba(0,0,0,.3), 0 0 0 9px rgba(255,212,94,0); } }
@keyframes starPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.16); } }

/* drifting sky over the peak */
.sceneFx { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; border-radius: 18px; }
.sceneFx .cloud { position: absolute; line-height: 1; opacity: .38; filter: drop-shadow(0 3px 4px rgba(0,0,0,.2)); animation: drift linear infinite; }
.sceneFx .sparkle { position: absolute; line-height: 1; opacity: .8; animation: twinkle 3.4s ease-in-out infinite; }
.sceneFx .glider { position: absolute; left: -10%; opacity: .5; animation: glide 52s linear infinite; }
@keyframes drift { from { left: -14%; } to { left: 108%; } }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.8) rotate(0); } 50% { opacity: 1; transform: scale(1.25) rotate(20deg); } }
@keyframes glide { 0% { left: -12%; top: 46%; } 50% { top: 26%; } 100% { left: 110%; top: 44%; } }

.warpLayer { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; pointer-events: none; }
.warpLayer .bridgePath { fill: none; stroke-width: 7; stroke-linecap: round; opacity: .72; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.warpLayer .slidePath { fill: none; stroke-width: 10; stroke-linecap: round; opacity: .6; }
.warpLayer .bridgeRungs { stroke-dasharray: 3 13; opacity: .9; }
.warpLayer .warpEnd { font-size: 13px; }
.warpLayer .active { animation: warpGlow 1s ease-in-out infinite alternate; }
@keyframes warpGlow { from { opacity: .6; } to { opacity: 1; filter: drop-shadow(0 0 12px rgba(255,220,120,.95)); } }

.tokens { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.token {
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
  background: rgba(255,255,255,.92); box-shadow: 0 0 0 3px var(--tk, #7c5cff), 0 6px 12px rgba(0,0,0,.45);
  transition: transform .19s cubic-bezier(.34,1.56,.64,1);
}
.token.is-turn::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 3px dashed var(--gold);
  animation: spin 3.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.token.hop { animation: hop .22s ease; }
@keyframes hop { 50% { filter: brightness(1.4); } }
.peakBanner {
  position: absolute; top: -2px; left: 50%; transform: translate(-50%, -140%);
  font-size: .72rem; font-weight: 900; background: rgba(255,241,184,.95); color: #4a2b05;
  padding: 3px 10px; border-radius: 99px; white-space: nowrap;
}

/* ---------- side panel ---------- */
.side { display: flex; flex-direction: column; gap: 12px; }
.turnCard { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.1); border: 3px solid var(--gold);
  border-radius: 18px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.turnEgg { font-size: 2.2rem; }
.turnName { font-size: 1.2rem; font-weight: 900; }
.turnHint { font-size: .9rem; color: #ffe9a8; font-weight: 700; }
.dicePanel { display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,.24); border: 2px solid rgba(255,255,255,.12);
  border-radius: 18px; padding: 12px; position: relative; }
.die {
  width: 78px; height: 78px; flex: 0 0 auto; border-radius: 18px; background: linear-gradient(160deg, #fffdf6, #ffe3a8);
  border: 3px solid #b9812a; display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem; font-weight: 900; color: #3a2000; box-shadow: 0 6px 0 #a5701d, inset 0 -6px 12px rgba(190,140,40,.35);
}
.die.rolling { animation: shake .12s linear infinite; }
#dieFace { display: grid; grid-template-columns: repeat(3, 14px); grid-template-rows: repeat(3, 14px); gap: 4px; }
#dieFace .pip { width: 14px; height: 14px; border-radius: 50%; background: #4a2b05; box-shadow: inset 0 -2px 2px rgba(255,255,255,.35); }
#dieFace .pip.off { background: transparent; box-shadow: none; }
@keyframes shake { 0% { transform: rotate(-9deg) translateY(0); } 50% { transform: rotate(9deg) translateY(-4px); } 100% { transform: rotate(-6deg) translateY(0); } }
.rollBtn { flex: 1; font-size: 1.15rem; padding: 14px 10px; }
.starBank { position: absolute; right: 10px; bottom: -10px; font-size: .82rem; font-weight: 900; background: #2a1b52;
  border: 2px solid var(--gold); color: #ffe9a8; padding: 3px 9px; border-radius: 99px; }
.panel { background: rgba(0,0,0,.26); border: 2px solid rgba(255,255,255,.12); border-radius: 18px; padding: 10px 12px; }
.panelHead { font-weight: 900; color: #ffd98a; letter-spacing: .4px; margin-bottom: 6px; font-size: .95rem; }
.log { max-height: 190px; overflow-y: auto; font-size: .9rem; line-height: 1.35; display: flex; flex-direction: column; gap: 5px; }
.log .entry { padding: 4px 8px; border-radius: 9px; background: rgba(255,255,255,.06); }
.log .entry.big { background: rgba(255,203,69,.18); color: #fff2c4; font-weight: 800; }
.log .entry.bad { background: rgba(255,93,143,.16); }
.log .entry.good { background: rgba(47,191,113,.16); }
.hall { font-size: .9rem; }
.hall table { width: 100%; border-collapse: collapse; }
.hall th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: #c9b7ff; }
.hall td { padding: 3px 2px; border-top: 1px solid rgba(255,255,255,.1); }
.hall .rank { color: #ffd98a; font-weight: 900; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(10,5,25,.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modalCard, .resultCard {
  width: min(760px, 100%); max-height: 94vh; overflow-y: auto; background: linear-gradient(180deg, #3b2a68, #241645);
  border: 3px solid var(--gold); border-radius: 24px; padding: 16px 18px; box-shadow: 0 30px 70px rgba(0,0,0,.6);
}
.miniHead { display: flex; gap: 10px; align-items: flex-start; }
.miniHead h2 { margin: 0; font-size: 1.6rem; color: #ffe9a8; }
.miniHow { margin: 4px 0 0; font-size: 1rem; color: #eee4ff; }
.miniHeadBtns { margin-left: auto; display: flex; gap: 6px; }
.miniStage { margin-top: 14px; min-height: 260px; display: flex; align-items: center; justify-content: center; }
.miniFoot { display: flex; align-items: center; margin-top: 12px; gap: 10px; }
.miniTimer { font-weight: 900; font-size: 1.15rem; color: #ffe9a8; }
.miniScore { margin-left: auto; font-weight: 900; font-size: 1.1rem; }

.resultCard { text-align: center; width: min(560px, 100%); }
.resultEgg { font-size: 4rem; }
.resultCard h2 { font-size: 2rem; margin: 4px 0 8px; color: #ffe9a8; }
.resultText { font-size: 1.05rem; line-height: 1.5; }
.resultStars { font-size: 1.4rem; margin: 8px 0 14px; }
.resultBtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.helpText { text-align: left; font-size: 1rem; line-height: 1.5; }
.helpText p { margin: 8px 0; }

/* ---------- mini-game pieces ---------- */
.moleGrid, .memGrid, .simonGrid { display: grid; gap: 10px; width: 100%; max-width: 460px; }
.moleGrid { grid-template-columns: repeat(3, 1fr); }
.hole { aspect-ratio: 1/.85; border-radius: 50% 50% 18px 18px; background: radial-gradient(circle at 50% 120%, #4b2f18, #241645 70%);
  border: 3px solid rgba(255,255,255,.14); display: flex; align-items: flex-end; justify-content: center; overflow: hidden; cursor: pointer; }
.hole .mole { font-size: 2.2rem; transform: translateY(110%); transition: transform .13s ease; }
.hole.up .mole { transform: translateY(6%); }
.hole.bonk { background: radial-gradient(circle at 50% 40%, #ffd45e, #ff7a3d); }
.hole.miss { background: radial-gradient(circle at 50% 40%, #5a5a6a, #241645 70%); }
.memGrid { grid-template-columns: repeat(4, 1fr); }
.card { aspect-ratio: 3/4; border-radius: 14px; background: linear-gradient(160deg, #7b5cd6, #432b7a); border: 3px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; font-size: 2rem; cursor: pointer; transition: transform .18s ease, background .2s; }
.card .face { opacity: 0; }
.card.open { background: linear-gradient(160deg, #ffe08a, #ffab3c); color: #4a2800; transform: rotateY(0) scale(1.03); }
.card.open .face { opacity: 1; }
.card.done { background: linear-gradient(160deg, #9ff0c4, #2fbf71); opacity: .85; cursor: default; }
.simonGrid { grid-template-columns: repeat(2, 1fr); max-width: 380px; }
.rune { aspect-ratio: 1; border-radius: 20px; border: 4px solid rgba(255,255,255,.22); cursor: pointer; filter: brightness(.62); transition: filter .12s, transform .12s; }
.rune.lit { filter: brightness(1.45); transform: scale(1.05); }
.rune.r0 { background: #ff5d8f; } .rune.r1 { background: #48c9ff; } .rune.r2 { background: #ffd45e; } .rune.r3 { background: #2fbf71; }
.catchField { position: relative; width: 100%; max-width: 560px; height: 320px; border-radius: 20px; overflow: hidden;
  background: linear-gradient(180deg, #1f3b6e, #2b6f9e 60%, #3f8f5f); border: 3px solid rgba(255,255,255,.2); cursor: crosshair; }
.flyer { position: absolute; font-size: 2.1rem; transform: translate(-50%, -50%); cursor: pointer; user-select: none; transition: transform .08s; }
.flyer:hover { transform: translate(-50%, -50%) scale(1.15); }
.barField { width: 100%; max-width: 560px; text-align: center; }
.barTrack { position: relative; height: 62px; border-radius: 16px; background: linear-gradient(90deg, #463, #463); overflow: hidden; border: 3px solid rgba(255,255,255,.22); }
.barSafe { position: absolute; top: 0; bottom: 0; background: linear-gradient(180deg, #9ff0c4, #2fbf71); box-shadow: 0 0 18px rgba(47,191,113,.7); }
.barRunner { position: absolute; top: -6px; bottom: -6px; width: 12px; border-radius: 6px; background: #fff; box-shadow: 0 0 14px #fff; }
.mathRow { display: flex; align-items: center; gap: 8px; font-size: 1.6rem; font-weight: 900; flex-wrap: wrap; justify-content: center; }
.mathRow .emoji { font-size: 2rem; }
.mathOpts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.optBtn { font-family: inherit; font-size: 1.6rem; font-weight: 900; padding: 12px 22px; border-radius: 16px; cursor: pointer;
  background: linear-gradient(180deg, #8b6bff, var(--grape)); color: #fff; border: 3px solid rgba(255,255,255,.25); }
.optBtn:hover { filter: brightness(1.1); }
.optBtn.right { background: linear-gradient(180deg, #9ff0c4, #2fbf71); color: #06401f; }
.optBtn.wrong { background: linear-gradient(180deg, #ffa9c0, #ff5d8f); }
.centerCol { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.miniMsg { font-size: 1.25rem; font-weight: 900; color: #ffe9a8; text-align: center; }

/* ---------- toast / fx ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 70;
  background: linear-gradient(180deg, #fff2c4, #ffc247); color: #4a2b05; font-weight: 900; font-size: 1.1rem;
  padding: 12px 22px; border-radius: 99px; box-shadow: 0 14px 30px rgba(0,0,0,.5); animation: rise .3s ease;
  max-width: 90vw; text-align: center;
}
@keyframes rise { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetto { position: absolute; font-size: 1.4rem; animation: fall linear forwards; }
@keyframes fall { from { transform: translateY(-10vh) rotate(0); opacity: 1; } to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  .play { grid-template-columns: 1fr; }
  .side { order: 2; }
  .tile .tname { display: none; }
}
@media (max-width: 560px) {
  #app { padding: 8px; }
  .play { gap: 10px; }
  .play > * { min-width: 0; }
  .chips { width: 100%; margin-left: 0; }
  .topActions { margin-left: auto; }
  .board { gap: 9px; }
  .boardFrame { padding: 10px 8px 8px; border-radius: 20px; }
  .ribbon { font-size: .68rem; padding: 4px 12px; }
  .tile { margin: 3px; }
  .tile .badge { min-width: 14px; height: 14px; font-size: .55rem; }
  .matDecor { opacity: .8; }
  .token { width: 26px; height: 26px; margin: -13px 0 0 -13px; font-size: 1rem; }
  .warpLayer .bridgePath { stroke-width: 4; }
  .warpLayer .slidePath { stroke-width: 6; }
  .log { max-height: 140px; }
  .bigBtn { font-size: 1.1rem; padding: 13px 18px; }
  .die { width: 62px; height: 62px; }
  .miniHead h2 { font-size: 1.25rem; }
  .catchField { height: 260px; }
}

/* ================= v2: castle, dusk, paint, confetti ================= */
.artLayer { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.trailLayer { z-index: 2; }
.duskVeil {
  position: absolute; inset: 0; z-index: 5; pointer-events: none; border-radius: 18px;
  opacity: calc(var(--dusk, 0) * .94); transition: opacity 2s ease;
  background:
    radial-gradient(60% 40% at 82% 8%, rgba(255,168,96,.55), transparent 70%),
    linear-gradient(180deg, rgba(38,24,96,.97) 0%, rgba(60,32,92,.88) 45%, rgba(16,10,44,.96) 100%);
  mix-blend-mode: multiply;
}
.boardMat { filter: brightness(calc(1 - .26 * var(--dusk, 0))) saturate(calc(1 - .14 * var(--dusk, 0))); transition: filter 2s ease; }

/* the keep at the top of the world */
.castle { position: absolute; line-height: 1; }
.castle .rock {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 210%; height: 58%; border-radius: 46% 54% 40% 60% / 70% 66% 34% 30%;
  background: linear-gradient(180deg, #9aa3d6, #5b5f96 55%, #3a3a68);
  box-shadow: inset 0 -8px 14px rgba(0,0,0,.4), inset 0 4px 8px rgba(255,255,255,.28);
}
.castle .keep {
  position: absolute; left: 50%; bottom: 30%; transform: translateX(-50%);
  width: 58%; height: 52%; border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, #e8ecff, #b6bee8 60%, #8d95c8);
  box-shadow: inset -6px 0 10px rgba(0,0,0,.22), inset 4px 0 8px rgba(255,255,255,.5);
}
.castle .keep::before {
  content: ''; position: absolute; left: -4%; right: -4%; top: -12%; height: 16%;
  background:
    repeating-linear-gradient(90deg, #dfe4ff 0 8%, transparent 8% 16%),
    linear-gradient(180deg, #cfd6f5, #a8b0dd);
  border-radius: 3px;
}
.castle .tower {
  position: absolute; bottom: 30%; width: 22%; height: 74%; border-radius: 5px 5px 3px 3px;
  background: linear-gradient(180deg, #f0f3ff, #b9c1e8 55%, #8a92c6);
  box-shadow: inset -4px 0 8px rgba(0,0,0,.24), inset 3px 0 6px rgba(255,255,255,.55);
}
.castle .tower.l { left: 2%; } .castle .tower.r { right: 2%; }
.castle .tower::before {
  content: ''; position: absolute; left: -14%; right: -14%; top: -8%; height: 14%;
  background: repeating-linear-gradient(90deg, #e6eaff 0 12%, transparent 12% 24%);
}
.castle .tower::after {
  content: ''; position: absolute; left: 50%; top: -34%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 16px solid #ff6b8a; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.castle .gate {
  position: absolute; left: 50%; bottom: 30%; transform: translateX(-50%);
  width: 20%; height: 26%; border-radius: 50% 50% 6px 6px;
  background: linear-gradient(180deg, #6b4a2a, #33210f);
  box-shadow: inset 0 3px 6px rgba(0,0,0,.6);
}
.castle .win {
  position: absolute; width: 6%; height: 8%; border-radius: 50% 50% 2px 2px;
  background: rgba(84,84,132,.9); box-shadow: 0 0 0 2px rgba(255,255,255,.4);
  opacity: calc(.6 + var(--dusk, 0) * .4);
  transition: background 2s ease, box-shadow 2s ease, opacity 2s ease;
}
.castle .win.lit { background: rgba(70,60,120,.9); }
.boardWrap.dusk-on .castle .win {
  background: radial-gradient(circle, #fff2b0, #ffb03a 70%);
  box-shadow: 0 0 10px 3px rgba(255,190,80,.85);
}
.castle .banner {
  position: absolute; left: 50%; bottom: 82%; transform: translateX(-50%);
  font-size: 15px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
}
.dragonHead {
  position: absolute; line-height: 1; transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.45));
  animation: breathe 3.4s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: translate(-50%,-50%) scale(1) rotate(-4deg); } 50% { transform: translate(-50%,-54%) scale(1.08) rotate(3deg); } }
.lanterns { position: absolute; inset: 0; opacity: var(--dusk, 0); transition: opacity 2s ease; }
.lantern { position: absolute; line-height: 1; transform: translate(-50%,-50%); text-shadow: 0 0 14px rgba(255,190,80,.95), 0 0 30px rgba(255,150,60,.6); animation: sway 4s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: translate(-50%,-50%) rotate(-6deg); } 50% { transform: translate(-50%,-52%) rotate(6deg); } }
.nightStars { position: absolute; inset: 0; opacity: calc(var(--dusk, 0) * var(--dusk, 0)); transition: opacity 2s ease; }
.nightStars span { position: absolute; line-height: 1; animation: twinkle 3.2s ease-in-out infinite; }

/* dragon tail slide */
.warpLayer .tailPath { stroke: url(#gTail); opacity: .95; }
.warpLayer .tailRidge { stroke: #ffd166; opacity: .85; stroke-dasharray: 3 16; stroke-linecap: butt; }
.warpLayer .tailBelly { stroke: #ffe6a8; opacity: .5; }
.warpLayer .tailGlow { stroke: #b06bff; opacity: .2; }

/* stones painted by whoever walked there */
.tile { transition: transform .14s ease, filter .14s ease, box-shadow .35s ease; }
.tile.washed { box-shadow: 0 3px 0 rgba(0,0,0,.3), inset 0 3px 7px rgba(255,255,255,.24), inset 0 -7px 11px rgba(0,0,0,.26), 0 0 0 3px var(--paintSoft, transparent); }
.tile.owned {
  box-shadow: 0 3px 0 rgba(0,0,0,.3), inset 0 3px 7px rgba(255,255,255,.24), inset 0 -7px 11px rgba(0,0,0,.26),
    0 0 0 4px var(--paint, #fff), 0 0 16px 2px var(--paintSoft, transparent);
}
.tile.owned .badge { background: var(--paint, #fff2c4); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* little confetti burst where a token lands */
.burst {
  position: absolute; width: 9px; height: 9px; border-radius: 3px; pointer-events: none;
  animation: burst .78s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes burst {
  from { transform: translate(-50%,-50%) scale(1) rotate(0); opacity: 1; }
  to { transform: translate(calc(-50% + var(--bx)), calc(-50% + var(--by))) scale(.25) rotate(320deg); opacity: 0; }
}

/* board shake when the dragon's tail drops you */
.boardWrap.shaken { animation: boardShake .62s cubic-bezier(.36,.07,.19,.97); }
@keyframes boardShake {
  10%, 90% { transform: translateX(-2px) rotate(-.2deg); }
  20%, 80% { transform: translateX(4px) rotate(.3deg); }
  30%, 50%, 70% { transform: translateX(-7px) rotate(-.45deg); }
  40%, 60% { transform: translateX(7px) rotate(.45deg); }
}
.chip .cPaint { color: #ffd98a; font-weight: 800; display: inline-flex; align-items: center; }
.chip .dotP { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; border: 1px solid rgba(255,255,255,.55); }

/* time-of-day meter */
.skyMeter {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  background: rgba(0,0,0,.24); border: 2px solid rgba(255,255,255,.12); border-radius: 16px;
}
.skyMeter .skyIcon { font-size: 1.3rem; line-height: 1; }
.skyMeter .skyTrack { position: relative; flex: 1; height: 12px; border-radius: 99px; overflow: hidden;
  background: linear-gradient(90deg, #9fe0ff, #ffe08a, #ff9d5c, #7c5cff, #241645); opacity: .85; }
.skyMeter .skyFill { position: absolute; top: 0; bottom: 0; right: 0; width: 0%;
  background: rgba(10,5,25,.62); border-left: 2px solid rgba(255,255,255,.7); transition: width 1.4s ease; }
.skyMeter .skyLabel { font-size: .82rem; font-weight: 900; color: #ffe9a8; min-width: 96px; text-align: right; }

@media (prefers-reduced-motion: reduce) {
  .sceneFx .cloud, .sceneFx .glider, .sceneFx .sparkle, .castle .win, .lantern, .dragonHead,
  .tile.t-star, .tile.is-goal, .nightStars span { animation: none !important; }
  .burst { animation-duration: .4s; }
}
