/* ==========================================================================
   QUEEN'S TUG 3D — the interface that floats over the realm
   Dark glass, gold leaf, engraved capitals. The 3D scene is the game; this
   layer stays thin and gets out of the way.
   ========================================================================== */

:root {
  --ink: #070a14;
  --glass: rgba(12, 16, 30, 0.72);
  --glass-strong: rgba(10, 13, 26, 0.9);
  --line: rgba(217, 164, 65, 0.35);
  --line-soft: rgba(255, 255, 255, 0.08);
  --gold: #d9a441;
  --gold-lt: #f7dda0;
  --gold-dk: #6f5218;
  --silver: #dde4f0;
  --muted: #8a95ab;
  --danger: #e0564f;
  --ok: #5fc473;
  --seat-0: #e0453f;
  --seat-1: #3faa54;
  --seat-2: #3d86e8;
  --seat-3: #e8b021;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Spectral', Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--silver);
  font-family: var(--body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
}
#stage canvas { display: block; width: 100%; height: 100%; }

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.screen > * { pointer-events: auto; }

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

/* ---------------------------------------------------------------- buttons */

.btn {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 10px;
  color: var(--silver);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line-soft);
  transition: transform 0.12s, filter 0.2s, background 0.2s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { font-size: 12px; padding: 8px 13px; }
.btn-lg { font-size: 17px; padding: 15px 26px; width: 100%; }
.btn-gold {
  color: #2a1c05;
  background: linear-gradient(180deg, #ffe7a8 0%, #e6b54f 45%, #b9842a 100%);
  border: 1px solid #fff0c4;
  box-shadow: 0 6px 24px rgba(217, 164, 65, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--silver); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--glass);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--gold-lt);
  font-size: 16px;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.94); }

.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- loading */

#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: radial-gradient(120% 90% at 50% 20%, #182041, var(--ink));
  font-family: var(--display);
  letter-spacing: 0.1em;
  color: var(--gold-lt);
  transition: opacity 0.6s;
}
#loading.gone { opacity: 0; pointer-events: none; }
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(217, 164, 65, 0.2);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading.error .spinner { display: none; }
#loading.error p { color: var(--silver); max-width: 300px; text-align: center; font-family: var(--body); letter-spacing: 0; }

/* ---------------------------------------------------------------- title */

.corner-tools {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: 12px;
  display: flex;
  gap: 8px;
}

.title-card {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  padding: 20px 20px 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(14, 18, 36, 0.78), rgba(8, 10, 22, 0.9));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 30px); } }

.logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(30px, 8.5vw, 40px);
  line-height: 1;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff6d8 10%, #e9bd5b 55%, #9b6c1c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 10px rgba(217, 164, 65, 0.35));
}
.logo-small {
  display: block;
  font-size: 0.38em;
  letter-spacing: 0.5em;
  margin-bottom: 4px;
  margin-right: -0.5em;
}
.tagline {
  margin: -4px 0 0;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}

.room-seats { display: flex; justify-content: center; gap: 10px; }
.seat-chip {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--seat) 70%, white 20%), var(--seat));
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--seat) 40%, transparent);
  position: relative;
  transition: transform 0.3s, opacity 0.3s;
}
.seat-chip svg { width: 24px; height: 24px; }
.seat-chip.waiting { opacity: 0.55; filter: saturate(0.6); }
.seat-chip.unknown { background: transparent; border-style: dashed; box-shadow: none; }
.seat-chip.is-you::after {
  content: 'YOU';
  position: absolute;
  bottom: -15px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--gold-lt);
}
.seat-chip.joined { animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes pop { from { transform: scale(0.3); } }

.room-status { margin: 10px 0 0; font-size: 14px; color: var(--silver); min-height: 1.3em; }
.room-status.error { color: #ffc27a; }
.online-only { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.code-value {
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.3em;
  padding: 6px 12px 6px 20px;
  border-radius: 12px;
  color: var(--gold-lt);
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--line);
}
.code-value.copied { border-color: var(--ok); color: var(--ok); }
.humans-only { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); cursor: pointer; }
.humans-only input { accent-color: var(--gold); width: 16px; height: 16px; }
.classic-link { font-size: 12px; color: var(--muted); text-decoration: none; opacity: 0.8; }
.classic-link:hover { color: var(--gold-lt); }

/* ---------------------------------------------------------------- HUD */

.top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(8px + var(--safe-t)) 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.top-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.round-tag {
  justify-self: start;
  font-family: var(--display);
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.round-tag span { font-size: 10px; letter-spacing: 0.2em; color: var(--muted); text-transform: uppercase; }
.round-tag b { font-size: 18px; color: var(--gold-lt); }
.tools { justify-self: end; display: flex; gap: 6px; }

.timer {
  position: relative;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glass-strong);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.timer .track { stroke: rgba(255, 255, 255, 0.08); }
.timer .fill { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 0.1s linear, stroke 0.3s; }
.timer .digits { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--gold-lt); }
.timer.urgent .fill { stroke: var(--danger); }
.timer.urgent .digits { color: #ff9a8f; animation: throb 1s infinite; }
.timer.idle .digits { color: var(--muted); }
@keyframes throb { 50% { transform: scale(1.18); } }

.seats { display: flex; justify-content: center; gap: 14px; flex-wrap: nowrap; margin-top: 2px; }

/* Each player is a round token in their colour, with a badge that says
   whether they have locked in. Big enough to read at a glance on a phone. */
.token {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 58px;
  transition: opacity 0.3s, filter 0.3s;
}
.token .disc {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--seat) 55%, white 45%), var(--seat) 55%, color-mix(in srgb, var(--seat) 70%, black));
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 0 transparent;
  transition: box-shadow 0.3s, transform 0.3s;
}
.token .disc > svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.token .badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #151a2e;
  border: 2px solid var(--ink);
  color: var(--muted);
}
.token .badge:empty { display: none; }
.token .badge svg { width: 13px; height: 13px; }
.token .badge i {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: currentColor;
  animation: think 1.2s infinite;
}
.token .badge i:nth-child(2) { animation-delay: 0.2s; }
.token .badge i:nth-child(3) { animation-delay: 0.4s; }
.token .nm {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--silver);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}
.token.me .disc { border-color: var(--gold-lt); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(247, 221, 160, 0.25); }
.token.me .nm { color: var(--gold-lt); }
.token.locked .disc { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 18px color-mix(in srgb, var(--seat) 70%, transparent); }
.token.locked .badge { background: var(--ok); color: #06200d; }
.token.locked.just .disc { animation: stamp 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
.token.fallen { opacity: 0.45; filter: grayscale(0.9); }
.token.fallen .badge { background: #3a2020; color: #ff9a8f; }
.token.fallen .nm { text-decoration: line-through; }
@keyframes stamp { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes think { 50% { opacity: 0.2; } }

.status-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 10px calc(10px + var(--safe-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.status-wrap > * { pointer-events: auto; }
.status {
  max-width: 520px;
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
  padding: 7px 14px;
  border-radius: 12px;
  background: rgba(8, 10, 22, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-height: 1em;
  pointer-events: none !important;
}
.status:empty { visibility: hidden; }
.status { display: flex; align-items: center; justify-content: center; gap: 14px; }
.status .msg { text-align: left; max-width: 260px; }
.status .msg:only-child { text-align: center; max-width: none; }
.status:has(.compass):not(:has(.msg)) { padding: 6px 8px; }

/* Last round, laid out the way the board is: ↑ on top, ↓ below, ← and → at the sides. */
.compass {
  display: grid;
  grid-template-columns: 34px 28px 34px;
  grid-template-rows: 22px 26px 22px;
  grid-template-areas: '. up .' 'left hub right' '. down .';
  align-items: center;
  justify-items: center;
  flex: none;
  font-family: var(--display);
}
.compass .up { grid-area: up; }
.compass .down { grid-area: down; }
.compass .left { grid-area: left; }
.compass .right { grid-area: right; }
.compass .hub {
  grid-area: hub;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gold-lt);
  background: radial-gradient(circle, rgba(247, 221, 160, 0.22), rgba(247, 221, 160, 0.05));
  border: 1px solid rgba(247, 221, 160, 0.35);
}
.compass .hub svg { width: 16px; height: 16px; }
.compass .hub b { font-size: 16px; color: var(--silver); }
.compass .arm {
  display: flex;
  align-items: center;
  gap: 1px;
  line-height: 1;
  font-size: 14px;
  color: var(--silver);
  transition: color 0.3s;
}
.compass .arm i { font-style: normal; font-size: 12px; opacity: 0.7; }
.compass .up, .compass .down { flex-direction: column; gap: 0; }
.compass .down { flex-direction: column-reverse; }
.compass .up i, .compass .down i { font-size: 10px; }
.compass .arm.idle { opacity: 0.28; }
.compass .arm.cut b { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.compass .arm.cut { opacity: 0.6; }
.compass .arm.lost { opacity: 0.55; }
.compass .arm.win { color: #ffd76a; text-shadow: 0 0 10px rgba(255, 200, 80, 0.7); }
.compass .arm.win b { font-size: 17px; }
.compass .arm.walled::after { content: ''; width: 3px; height: 14px; margin-left: 3px; border-radius: 2px; background: #c9a36b; }
.compass .up.walled::after, .compass .down.walled::after { width: 14px; height: 3px; margin: 2px 0 0; }
.status b { color: var(--gold-lt); }
.status .verdict { font-family: var(--display); letter-spacing: 0.04em; }
.status .tugline { display: inline-flex; gap: 10px; font-family: var(--display); font-size: 13px; }
.status .tugline span { opacity: 0.55; }
.status .tugline span.on { opacity: 1; color: var(--gold-lt); }

.dock {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(16, 20, 38, 0.86), rgba(8, 10, 22, 0.94));
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  width: min(460px, 100%);
}
.purse, .rack {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px 8px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  color: var(--gold-lt);
  min-width: 0;
}
.purse.spending { animation: spend 0.5s; }
.purse.gaining { animation: gain 0.8s; }
@keyframes spend { 30% { transform: scale(0.92); color: #ffb0a8; } }
@keyframes gain { 30% { transform: scale(1.15); color: #fff; box-shadow: 0 0 30px rgba(247, 221, 160, 0.6); } }
.coin-icon, .ball-icon { width: 26px; height: 26px; flex: none; display: grid; }
.coin-icon svg, .ball-icon svg { width: 100%; height: 100%; }
.rack { color: var(--silver); touch-action: none; position: relative; padding-right: 14px; }
.rack-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.rack-text small { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: #ffb4a6; margin-top: 3px; }
.rack.armed { border-color: #ff7a64; background: rgba(255, 90, 70, 0.2); box-shadow: 0 0 0 2px rgba(255, 110, 90, 0.35), 0 0 24px rgba(255, 90, 70, 0.35); }
.rack.armed .rack-text small { color: #fff; }
/* Until it has been used, the cannon keeps asking to be noticed. */
.rack.beckon { border-color: rgba(255, 130, 100, 0.7); animation: beckonGlow 1.6s ease-in-out infinite; }
.rack.beckon .ball-icon { animation: bounce 1.6s cubic-bezier(0.3, 0, 0.3, 1) infinite; }
.rack.glow { border-color: rgba(255, 130, 100, 0.45); box-shadow: 0 0 14px rgba(255, 90, 70, 0.18); }
@keyframes bounce {
  0%, 55%, 100% { transform: translateY(0); }
  20% { transform: translateY(-9px); }
  35% { transform: translateY(0) scale(1.08, 0.9); }
  45% { transform: translateY(-3px); }
}
@keyframes beckonGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 110, 90, 0); }
  50% { box-shadow: 0 0 0 4px rgba(255, 110, 90, 0.25), 0 0 26px rgba(255, 90, 70, 0.45); }
}

.cannon-tip {
  position: relative;
  max-width: 360px;
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  padding: 11px 14px;
  border-radius: 14px;
  color: var(--silver);
  background: linear-gradient(180deg, #2a1616, #1a0f12);
  border: 1px solid rgba(255, 130, 100, 0.55);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 24px rgba(255, 90, 70, 0.2);
  animation: toastIn 0.4s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.cannon-tip b { color: #ffc2b5; }
.cannon-tip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: calc(50% - 60px);
  width: 12px;
  height: 12px;
  background: #1a0f12;
  border-right: 1px solid rgba(255, 130, 100, 0.55);
  border-bottom: 1px solid rgba(255, 130, 100, 0.55);
  transform: rotate(45deg);
}
.rack:disabled { opacity: 0.35; }
.rack.empty .ball-icon { opacity: 0.35; }
.undo { width: 44px; height: 44px; flex: none; }
.undo:disabled { opacity: 0.3; }
.seal {
  margin-left: auto;
  flex: 1;
  max-width: 170px;
  height: 48px;
  border-radius: 14px;
  font-family: var(--display);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: #2a1c05;
  background: linear-gradient(180deg, #ffe7a8 0%, #e6b54f 45%, #b9842a 100%);
  border: 1px solid #fff0c4;
  box-shadow: 0 6px 20px rgba(217, 164, 65, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.12s, filter 0.2s, opacity 0.2s;
}
.seal.ready { animation: ready 1.4s ease-in-out infinite; }
@keyframes ready {
  0%, 100% { box-shadow: 0 6px 20px rgba(217, 164, 65, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
  50% { box-shadow: 0 6px 30px rgba(247, 205, 110, 0.75), 0 0 0 4px rgba(247, 221, 160, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
}
.seal.nudge { animation: nudge 0.6s ease-in-out 2; }
@keyframes nudge { 25% { transform: scale(1.07); } 50% { transform: scale(0.97); } 75% { transform: scale(1.04); } }
.seal.pass { background: linear-gradient(180deg, #4a5270, #2b3148); color: var(--silver); border-color: rgba(255,255,255,.15); box-shadow: none; }
.seal:active { transform: scale(0.97); }
.seal:disabled { opacity: 0.55; cursor: default; filter: grayscale(0.4); }
.seal.done { background: rgba(95, 196, 115, 0.15); color: var(--ok); border-color: rgba(95, 196, 115, 0.5); box-shadow: none; }

.drag-ball {
  position: fixed;
  z-index: 40;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.6));
}
.drag-ball svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- world labels */

.wl {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  pointer-events: none;
  font-family: var(--display);
  font-weight: 700;
  text-align: center;
  will-change: transform;
}
.wl > * { position: relative; }
.stack-label, .chest-label, .rope-label, .ghost-label, .reveal-label {
  translate: -50% -100%;
}
.stack-label b {
  display: inline-block;
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 15px;
  color: #2a1c05;
  background: linear-gradient(180deg, #fff1c4, #e5b24c);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.chest-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  color: #2a1c05;
  padding: 2px 10px 2px 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff1c4, #e5b24c);
  border: 1px solid #fff4d0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 200, 90, 0.45);
}
.chest-label::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff5cc, #f0c04e 45%, #8f6216);
  box-shadow: inset 0 0 0 1.5px rgba(92, 68, 22, 0.8);
}
.chest-label .cap { font-size: 11px; letter-spacing: 0.04em; opacity: 0.85; margin-right: 1px; }
.chest-label.low { background: linear-gradient(180deg, #ffd9c9, #d98b62); }
.chest-label.mini { font-size: 11px; padding: 1px 7px 1px 3px; box-shadow: 0 0 0 2px var(--seat), 0 3px 10px rgba(0, 0, 0, 0.5); }
.chest-label.mini::before { width: 11px; height: 11px; }
.rope-label {
  font-size: 18px;
  color: #fff4d4;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 12px rgba(255, 190, 80, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  animation: labelIn 0.3s ease-out;
}
.rope-label small { font-size: 10px; letter-spacing: 0.08em; color: var(--gold-lt); opacity: 0.85; margin-top: 2px; }
.rope-label.win { color: #ffe08a; font-size: 24px; }
.rope-label.lost { color: #9aa0ab; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9); text-decoration: line-through; }
@keyframes labelIn { from { opacity: 0; transform: scale(0.5); } }
.ghost-label {
  font-size: 12px;
  color: #ffe9b8;
  padding: 1px 7px;
  border-radius: 8px;
  background: rgba(20, 16, 8, 0.6);
  border: 1px dashed rgba(247, 221, 160, 0.55);
}
.ghost-label.win { color: #b8ffb8; border-color: #7fe07f; background: rgba(10, 40, 10, 0.7); }
.reveal-label {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  background: color-mix(in srgb, var(--seat) 75%, black);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
  animation: labelIn 0.5s ease-out;
}
.reveal-label.win { font-size: 14px; box-shadow: 0 0 20px var(--seat); }
.reveal-label.fallen { opacity: 0.7; text-decoration: line-through; }

/* ---------------------------------------------------------------- result */

.result-card {
  position: absolute;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  width: min(440px, calc(100% - 20px));
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(14, 18, 36, 0.82), rgba(8, 10, 22, 0.94));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.winner-line { display: flex; align-items: center; justify-content: center; gap: 10px; }
.winner-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--seat, var(--muted)); box-shadow: 0 0 16px var(--seat, transparent); }
.winner-line h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: 24px;
  background: linear-gradient(180deg, #fff6d8, #e9bd5b 60%, #b9842a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.result-stats b { color: var(--silver); }
.replay-bar { display: flex; align-items: center; gap: 10px; }
.replay-bar input { flex: 1; accent-color: var(--gold); }
.round-label { font-family: var(--display); font-size: 12px; color: var(--muted); min-width: 52px; text-align: right; }

/* ---------------------------------------------------------------- modals & toasts */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 5, 12, 0.66);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px 20px 20px;
  border-radius: 18px;
  background: #0e1224;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  user-select: text;
  -webkit-user-select: text;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-family: var(--display); color: var(--gold-lt); font-size: 22px; }
.modal-card h4 { margin: 18px 0 4px; font-family: var(--display); color: var(--gold-lt); letter-spacing: 0.05em; }
.modal-card p, .modal-card li { font-size: 15px; line-height: 1.55; color: #c9d1df; }
.modal-card ul { padding-left: 20px; }
.modal-card strong { color: var(--silver); }
.lede { font-style: italic; color: var(--gold-lt) !important; }
.aside { font-style: italic; color: var(--muted) !important; }
.code-input {
  width: 100%;
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--gold-lt);
  outline: none;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast-stack {
  position: fixed;
  left: 50%;
  top: calc(130px + var(--safe-t));
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: min(420px, calc(100% - 24px));
}
.toast {
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  background: rgba(14, 18, 36, 0.94);
  border: 1px solid var(--line-soft);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.3s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.toast.bad { border-color: rgba(224, 86, 79, 0.6); color: #ffc2bc; }
.toast.gold { border-color: var(--line); color: var(--gold-lt); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(0.95); } }

@media (min-width: 900px) {
  .title-card { left: auto; right: 5vw; bottom: auto; top: 50%; transform: translateY(-50%); animation-name: riseSide; }
  @keyframes riseSide { from { opacity: 0; transform: translate(30px, -50%); } }
  .result-card { left: auto; right: 4vw; bottom: auto; top: 50%; transform: translateY(-50%); animation-name: riseSide; }
}

@media (max-height: 640px) {
  .tagline { display: none; }
  .title-card { gap: 8px; padding: 14px; }
  .code-value { font-size: 20px; }
}

@media (max-width: 360px) {
  .seats { gap: 8px; }
  .token { width: 52px; }
  .token .disc { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .rack.beckon .ball-icon, .rack.beckon, .seal.ready { animation: none; }
}

/* ---------------------------------------------------------------- the lesson */

body.tut .timer,
body.tut #status,
body.tut #cannon-tip { display: none !important; }
body.tut .round-tag span { font-size: 11px; letter-spacing: 0.16em; color: var(--gold-lt); white-space: nowrap; }

.coach {
  width: min(460px, 100%);
  padding: 12px 14px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(34, 28, 12, 0.94), rgba(16, 13, 8, 0.96));
  border: 1px solid rgba(247, 221, 160, 0.55);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 30px rgba(217, 164, 65, 0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.coach.pop { animation: coachIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1); }
.coach.tick .coach-text { animation: coachTick 0.5s ease-out; }
@keyframes coachTick { from { color: #fff; text-shadow: 0 0 12px rgba(255, 215, 120, 0.8); } }
.coach.shake { animation: coachShake 0.4s; }
@keyframes coachIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes coachShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.coach-top { display: flex; align-items: center; justify-content: space-between; }
.coach-steps { display: flex; gap: 5px; }
.coach-steps i { width: 18px; height: 4px; border-radius: 2px; background: rgba(247, 221, 160, 0.2); }
.coach-steps i.done { background: rgba(247, 221, 160, 0.55); }
.coach-steps i.on { background: var(--gold); box-shadow: 0 0 8px rgba(217, 164, 65, 0.8); }
.coach-skip { font-size: 12px; color: var(--muted); padding: 4px 6px; }
.coach-skip:hover { color: var(--silver); }
.coach-text { font-size: 16px; line-height: 1.45; color: #efe6cf; }
.coach-text b { color: #ffd98a; }
.coach-next { align-self: flex-end; min-width: 120px; }
.coach-compass { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.35; }

.pointer-label {
  translate: -50% -100%;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #2a1c05;
  background: linear-gradient(180deg, #fff1c4, #e5b24c);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 16px rgba(255, 200, 90, 0.45);
  animation: labelIn 0.4s ease-out;
}
.pointer-label.small { font-size: 11px; padding: 2px 8px; opacity: 0.92; }

.welcome-card { text-align: center; display: flex; flex-direction: column; gap: 12px; max-width: 400px; padding: 24px 22px 18px; }
.welcome-card h2 { margin: 0; font-family: var(--display); font-size: 24px; color: var(--gold-lt); }
.welcome-card p { margin: 0; }
.welcome-crown { font-size: 34px; color: var(--gold); line-height: 1; filter: drop-shadow(0 0 12px rgba(217, 164, 65, 0.6)); }
.dont-show { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.dont-show input { accent-color: var(--gold); width: 16px; height: 16px; }
.ready-list { text-align: left; margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.ready-list li { font-size: 14px !important; }
.rules-lesson { margin: 10px 0 4px; }

/* ---------------------------------------------------------------- spoils */

.fly-icon {
  position: fixed;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  z-index: 45;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 8px rgba(255, 210, 110, 0.55));
}
.fly-icon svg { width: 100%; height: 100%; }
.spoils-label {
  translate: -50% -100%;
  font-size: 30px;
  font-weight: 900;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 18px rgba(255, 200, 80, 0.8);
  animation: spoilsUp 1.6s ease-out forwards;
}
.spoils-label.coins { color: #ffe08a; }
.spoils-label.balls { color: #dfe6f5; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 18px rgba(160, 190, 255, 0.8); }
@keyframes spoilsUp {
  0% { opacity: 0; transform: scale(0.4); }
  15% { opacity: 1; transform: scale(1.25); }
  30% { transform: scale(1); }
  100% { opacity: 0.9; transform: translateY(-30px); }
}
.rack.gaining { animation: gain 0.6s; }
