/* Token Trail — original woodland palette. */
:root{
  --floor-deep:#12211a;
  --floor:#1b2f24;
  --floor-lift:#24402f;
  --panel:#1d3327;
  --panel-edge:#2f5039;
  --bark:#8a6a3e;
  --sand:#e9dcbe;
  --parchment:#f4eedf;
  --muted:#a9bfa8;
  --gold:#e3b24a;
  --gold-deep:#b4842c;
  --ember:#c75b2a;
  --sorrel:#8a4a86;
  --pip:#1e7f6e;
  --thistle:#43629e;
  --danger:#a8443a;
  --r:16px;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bot:env(safe-area-inset-bottom,0px);
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;
  font-family:ui-rounded,"SF Pro Rounded","Segoe UI Variable Display",Nunito,"Segoe UI",system-ui,-apple-system,sans-serif;
  color:var(--parchment);
  background:
    radial-gradient(120% 80% at 50% -10%,#2b4b36 0%,rgba(43,75,54,0) 60%),
    linear-gradient(#16281e,#0d1913 70%);
  overflow:hidden;
  overscroll-behavior:none;
  user-select:none;
}
#app{height:100dvh;display:flex;flex-direction:column}
.screen{
  flex:1;min-height:0;display:flex;flex-direction:column;
  padding:calc(10px + var(--safe-top)) 14px calc(10px + var(--safe-bot));
}
.hidden{display:none !important}

/* ---------- buttons ---------- */
.btn{
  font:inherit;font-weight:800;letter-spacing:.2px;
  border:none;border-radius:14px;padding:14px 18px;
  cursor:pointer;width:100%;transition:transform .08s ease,filter .15s ease;
}
.btn:active{transform:translateY(2px)}
.btn.primary{
  color:#2a1c07;
  background:linear-gradient(#f0c463,var(--gold) 55%,var(--gold-deep));
  box-shadow:0 4px 0 #8c6520,0 8px 18px rgba(0,0,0,.35);
}
.btn.primary:active{box-shadow:0 2px 0 #8c6520,0 4px 10px rgba(0,0,0,.35)}
.btn.ghost{
  color:var(--parchment);background:rgba(255,255,255,.07);
  box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.24);
}
.btn.danger{color:#ffe9e5;background:rgba(168,68,58,.35);box-shadow:inset 0 0 0 1.5px rgba(214,120,110,.5)}
.btn:disabled{opacity:.42;filter:grayscale(.5);cursor:default;transform:none}

/* ---------- setup (one screen, never scrolls) ---------- */
#setup{overflow:hidden;align-items:center}
.setup-inner{
  width:100%;max-width:440px;height:100%;
  display:flex;flex-direction:column;gap:12px;padding:2px 0;
}
.brand{flex:none;display:flex;align-items:center;gap:12px;text-align:left}
#crest{width:96px;height:66px;display:block;flex:none;filter:drop-shadow(0 3px 7px rgba(0,0,0,.35))}
.brand-txt{min-width:0}
.brand h1{
  margin:0;font-size:clamp(26px,7.6vw,34px);line-height:1;letter-spacing:-.5px;
  background:linear-gradient(#fbf0d4,var(--gold) 70%,#c8952f);
  -webkit-background-clip:text;background-clip:text;color:transparent;
  text-shadow:0 2px 0 rgba(0,0,0,.18);
}
.tagline{margin:5px 0 0;color:var(--muted);font-size:12px;line-height:1.4;font-weight:700}

.mode-switch{
  flex:none;display:flex;gap:4px;padding:4px;border-radius:14px;
  background:rgba(0,0,0,.3);box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.12);
}
.mode{
  flex:1;border:none;border-radius:10px;padding:9px 6px;cursor:pointer;
  font:inherit;font-size:13.5px;font-weight:900;letter-spacing:.3px;
  color:var(--muted);background:transparent;
  transition:background .15s ease,color .15s ease;
}
.mode.on{
  color:#2a1c07;
  background:linear-gradient(#f0c463,var(--gold) 60%,var(--gold-deep));
  box-shadow:0 2px 0 rgba(140,101,32,.8);
}
.mode.has-resume::after{
  content:'';display:inline-block;width:7px;height:7px;border-radius:50%;
  background:var(--gold);margin-left:6px;
}
.mode.on.has-resume::after{background:#2a1c07}

.pane{flex:1;min-height:0;display:flex;flex-direction:column;justify-content:center;gap:10px}
#mpResume:empty{display:none}
.mp-row{display:flex;gap:9px}
.mp-row>*{flex:1}

.roster{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.slot{
  position:relative;border-radius:var(--r);padding:12px 10px 11px;text-align:center;cursor:pointer;
  background:linear-gradient(rgba(255,255,255,.06),rgba(255,255,255,.02));
  box-shadow:inset 0 0 0 2px rgba(233,220,190,.14);
  transition:box-shadow .16s ease,background .16s ease,opacity .16s ease;
}
.slot canvas{width:clamp(46px,15vw,60px);height:clamp(46px,15vw,60px);display:block;margin:0 auto 3px}
.slot .nm{font-weight:900;font-size:16px;letter-spacing:.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.slot .sp{font-size:11.5px;color:var(--muted);font-weight:700;margin-top:1px}
.slot .role{
  margin-top:6px;font-size:12px;font-weight:900;letter-spacing:.5px;text-transform:uppercase;
  padding:5px 8px;border-radius:999px;background:rgba(0,0,0,.3);
}
.slot[data-role="you"]{box-shadow:inset 0 0 0 2.5px var(--gold)}
.slot[data-role="you"] .role{background:var(--gold);color:#2a1c07}
.slot[data-role="ai"] .role{background:rgba(233,220,190,.2);color:var(--parchment)}
.slot[data-role="off"]{opacity:.4}
.roster-note{margin:0;text-align:center;color:var(--muted);font-size:12.5px;font-weight:700}
.roster-note a{color:var(--gold)}
.setup-actions{flex:none;display:flex;flex-direction:column;gap:8px}
.btn.text{
  width:auto;align-self:center;background:none;box-shadow:none;
  color:var(--muted);font-weight:800;font-size:13px;padding:6px 14px;
  text-decoration:underline dotted rgba(169,191,168,.55);text-underline-offset:3px;
}

/* ---------- game ---------- */
#game{gap:8px;position:relative}
/* ---------- who is on ----------
   Whose turn it is has to survive a glance from across a table, so it is said
   three ways at once: the critter's own face, its corner colour, and everyone
   else stepping back. */
.scoreboard{display:flex;gap:6px;align-items:flex-end}
.pill{
  flex:1;min-width:0;border-radius:12px;padding:7px 6px 6px;text-align:center;
  background:rgba(0,0,0,.28);box-shadow:inset 0 0 0 1.5px rgba(255,255,255,.07);
  opacity:.62;transform:scale(.96);transform-origin:50% 100%;
  transition:box-shadow .22s ease,background .22s ease,opacity .22s ease,transform .22s ease;
}
.pill.on{
  opacity:1;transform:scale(1);
  background:linear-gradient(var(--seat-soft),rgba(0,0,0,.3));
  box-shadow:inset 0 0 0 2.5px var(--seat),0 4px 16px -4px var(--seat);
}
.pill .pav{position:relative;display:flex;justify-content:center}
.pill.on .pav::after{
  content:'';position:absolute;left:50%;bottom:-3px;width:5px;height:5px;margin-left:-2.5px;
  border-radius:50%;background:var(--seat);box-shadow:0 0 8px var(--seat);
}
.pill canvas,.pill .av-img{transition:transform .22s ease}
.pill.on canvas,.pill.on .av-img{transform:translateY(-1px) scale(1.08)}
.pill .pname{font-size:12px;font-weight:900;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pill .pips{display:flex;gap:3px;justify-content:center;margin-top:5px}
.pill .pip{width:7px;height:7px;border-radius:50%;background:rgba(255,255,255,.16)}
.pill .pip.done{box-shadow:0 0 6px rgba(255,255,255,.35)}
.pill .ptag{font-size:9.5px;font-weight:800;color:var(--muted);letter-spacing:.4px;margin-top:3px;text-transform:uppercase}
.pill.on .ptag{color:var(--seat)}

/* A player whose device has gone quiet. Said plainly rather than hidden, so
   "why is nothing happening" has a visible answer on the board itself. */
.pill.away{opacity:.34}
.pill.away .pname{text-decoration:line-through;text-decoration-thickness:1px}
.pill.away .ptag{color:var(--muted)}
.pill.away.on{opacity:.62}

.banner{
  --turn:var(--gold);--turn-soft:rgba(255,255,255,.10);
  display:flex;align-items:center;gap:11px;min-height:56px;
  border-radius:12px;padding:8px 13px;
  background:linear-gradient(90deg,var(--turn-soft),rgba(255,255,255,.03) 62%);
  box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.13),inset 4px 0 0 var(--turn);
  transition:background .25s ease,box-shadow .25s ease;
}
.banner-av{
  flex:none;width:38px;height:38px;border-radius:50%;overflow:hidden;
  display:flex;align-items:flex-end;justify-content:center;
  background:rgba(0,0,0,.3);box-shadow:0 0 0 2px var(--turn),0 0 12px -2px var(--turn);
}
.banner-av.none{
  width:11px;height:11px;background:var(--turn);
  box-shadow:0 0 0 3px rgba(255,255,255,.09);
}
.banner-av canvas,.banner-av .av-img{width:38px;height:38px;display:block}
.banner-av.none canvas,.banner-av.none .av-img{display:none}
.banner-text{font-size:14.5px;font-weight:800;line-height:1.3}

/* Replayed on every handover, so the change is felt and not just read. */
.banner.turned{animation:turnpop .5s ease}
.banner.turned .banner-av{animation:turnav .5s cubic-bezier(.34,1.56,.64,1)}
@keyframes turnpop{
  0%{box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.13),inset 4px 0 0 var(--turn),0 0 0 0 var(--turn)}
  35%{box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.13),inset 4px 0 0 var(--turn),0 0 0 4px var(--turn-soft)}
  100%{box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.13),inset 4px 0 0 var(--turn),0 0 0 0 transparent}
}
@keyframes turnav{0%{transform:scale(.7)}60%{transform:scale(1.14)}100%{transform:scale(1)}}
@media (prefers-reduced-motion:reduce){
  .banner.turned,.banner.turned .banner-av{animation:none}
  .pill,.pill canvas,.pill .av-img{transition:none}
}

.board-wrap{flex:1;min-height:0;display:flex;align-items:center;justify-content:center}
#board{display:block;border-radius:20px;box-shadow:0 10px 34px rgba(0,0,0,.5),0 0 0 3px rgba(138,106,62,.55)}

.tray{display:flex;align-items:center;gap:12px}
.die-btn{
  flex:none;width:76px;height:76px;padding:0;border:none;border-radius:18px;cursor:pointer;
  background:rgba(0,0,0,.25);box-shadow:inset 0 0 0 1.5px rgba(233,220,190,.15);
  transition:transform .08s ease;
}
.die-btn:active{transform:scale(.95)}
.die-btn canvas{width:100%;height:100%;display:block}
.tray-right{flex:1;min-width:0}
.btn.roll{
  color:#2a1c07;background:linear-gradient(#f0c463,var(--gold) 55%,var(--gold-deep));
  box-shadow:0 4px 0 #8c6520,0 8px 18px rgba(0,0,0,.32);padding:13px 16px;font-size:16px;
}
.btn.roll:active{box-shadow:0 2px 0 #8c6520}
.hint{margin:6px 2px 0;font-size:11.5px;color:var(--muted);font-weight:700;line-height:1.35;min-height:16px}

.menu-btn{
  position:absolute;top:calc(6px + var(--safe-top));right:10px;
  width:34px;height:34px;border:none;border-radius:10px;cursor:pointer;
  color:var(--parchment);background:rgba(0,0,0,.3);font-size:16px;line-height:1;
  box-shadow:inset 0 0 0 1.5px rgba(255,255,255,.09);opacity:.55;
}

/* ---------- modals ---------- */
.modal{
  position:fixed;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;
  padding:18px;background:rgba(6,13,9,.74);backdrop-filter:blur(5px);
  animation:fade .18s ease;
}
@keyframes fade{from{opacity:0}to{opacity:1}}
.sheet{
  width:100%;max-width:400px;max-height:86dvh;overflow-y:auto;
  border-radius:22px;padding:22px 20px;display:flex;flex-direction:column;gap:11px;
  background:linear-gradient(#274031,#1a2d22);
  box-shadow:0 20px 60px rgba(0,0,0,.6),inset 0 0 0 2px rgba(233,220,190,.14);
  animation:rise .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes rise{from{transform:translateY(22px) scale(.97);opacity:0}to{transform:none;opacity:1}}
.sheet h2{margin:0;font-size:23px;line-height:1.15}
.sheet-note{margin:0;color:var(--muted);font-size:14px;font-weight:700;line-height:1.5}
.rules{margin:2px 0 6px;padding-left:20px;display:flex;flex-direction:column;gap:9px}
.rules li{font-size:14px;line-height:1.5;color:#dfe9db}
.rules b{color:var(--gold)}
.win-sheet{text-align:center;align-items:center}
#winCrest{width:130px;height:130px}
.standings{width:100%;display:flex;flex-direction:column;gap:6px;margin:2px 0 6px}
.stand-row{
  display:flex;align-items:center;gap:9px;padding:8px 11px;border-radius:11px;
  background:rgba(0,0,0,.25);font-size:13.5px;font-weight:800;
}
.stand-row .sw{width:13px;height:13px;border-radius:4px;flex:none}
.stand-row .sn{flex:1;text-align:left}
.stand-row .sv{color:var(--muted);font-size:12px}

@media (min-width:620px){
  .screen{padding-left:22px;padding-right:22px}
  .banner-text{font-size:16px}
  .hint{font-size:12.5px}
}
@media (max-height:620px){
  .setup-inner{gap:9px}
  #crest{width:74px;height:51px}
  .tagline{display:none}
  .slot canvas{width:44px;height:44px}
  .slot .role{margin-top:4px;font-size:11px;padding:4px 7px}
  .die-btn{width:66px;height:66px}
}

/* Menu toggles. Every player now hears and feels every toss on the trail, so
   both channels get a switch that reads its own state rather than a label you
   have to interpret. */
.toggles { display: flex; gap: 8px; }
.toggles .toggle { flex: 1; position: relative; padding-left: 34px; }
.toggles .toggle::before {
  content: ''; position: absolute; left: 12px; top: 50%; width: 12px; height: 12px;
  margin-top: -6px; border-radius: 50%; background: rgba(233, 220, 190, .22);
  box-shadow: inset 0 0 0 1.5px rgba(233, 220, 190, .28);
}
.toggles .toggle[aria-pressed="true"]::before { background: #9dbf78; box-shadow: 0 0 8px rgba(157, 191, 120, .55); }
.toggles .toggle[aria-pressed="false"] { opacity: .62; }

/* ---------- the shared screen ----------
   The TV-sound switch sits outside the .toggles pair on purpose: those two are
   this phone's own settings, and this one reaches across the table and quiets
   everybody. It only appears for the host. */
.tv-sound {
  position: relative;
  padding-left: 34px;
  width: 100%;
}
.tv-sound::before {
  content: ""; position: absolute; left: 14px; top: 50%; margin-top: -5px;
  width: 10px; height: 10px; border-radius: 50%; background: #4a5a4e;
}
.tv-sound[aria-pressed="true"]::before { background: #e3b24a; box-shadow: 0 0 8px rgba(227, 178, 74, .55); }
.tv-sound[aria-pressed="false"] { opacity: .62; }

/* While the TV is carrying the sound, this phone's own Sound button still
   works — it is how you take yours back — so it must not read as disabled. */
#menuSound.hushed { opacity: .72; border-style: dashed; }
