:root {
  --walnut: #3b2417;
  --walnut-dark: #24150d;
  --glass: #1b2330;
  --glass-edge: #2c3746;
  --amber: #ffb347;
  --cherry: #e0405a;
  --brass: #c9a15a;
  --cream: #f3e6cf;
  --muted: #bfae92;
  --display: "Bungee", "Impact", "Arial Black", sans-serif;
  --body: "Chivo", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--body);
  color: var(--cream);
  background-color: var(--walnut-dark);
  /* walnut grain */
  background-image:
    repeating-linear-gradient(92deg, rgba(0,0,0,.18) 0 2px, transparent 2px 9px, rgba(255,220,180,.03) 9px 11px, transparent 11px 23px),
    repeating-linear-gradient(88deg, rgba(0,0,0,.12) 0 1px, transparent 1px 37px),
    radial-gradient(120% 80% at 50% 0%, #5a3822 0%, var(--walnut) 45%, var(--walnut-dark) 100%);
  background-attachment: fixed;
  line-height: 1.5;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }

.screen { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---------- menu ---------- */
.rail { text-align: center; padding: 18px 0 8px; }
.marquee {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.4rem, 8vw, 5.2rem);
  line-height: .9;
  margin: 0;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255,179,71,.45), 0 3px 0 #8a4f12;
  display: flex; flex-direction: column; align-items: center;
}
.marquee span:last-child {
  /* the second player's side of a cocktail cabinet reads upside down */
  transform: rotate(180deg);
  color: var(--cherry);
  text-shadow: 0 0 18px rgba(224,64,90,.45), 0 -3px 0 #6b1424;
  margin-top: .08em;
}
.tagline { max-width: 34em; margin: 14px auto 0; color: var(--muted); font-size: 1.05rem; }

.tabletop {
  margin: 28px auto 0;
  padding: clamp(14px, 3vw, 34px);
  border-radius: 38px;
  background: linear-gradient(160deg, #26303e, var(--glass) 60%, #141a23);
  box-shadow: inset 0 0 0 3px var(--brass), inset 0 0 0 10px #1a120b, inset 0 0 60px rgba(0,0,0,.6), 0 18px 40px rgba(0,0,0,.45);
}
.deck { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.cab {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center;
  text-align: left; cursor: pointer;
  padding: 14px 14px 14px 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  transition: border-color .15s, background .15s;
}
.cab:hover { border-color: var(--amber); background: rgba(255,179,71,.06); }
.cab svg { width: 64px; height: 64px; }
.cab h3 { font-family: var(--display); font-weight: 400; margin: 0; font-size: 1.25rem; color: var(--cream); letter-spacing: .02em; }
.cab p { margin: 2px 0 0; font-size: .9rem; color: var(--muted); line-height: 1.35; }

.foot { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 20px; color: var(--muted); font-size: .9rem; }

.chip {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--brass);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
}
.chip:hover { background: rgba(201,161,90,.18); }
.chip.primary { background: var(--amber); color: #2a1606; border-color: var(--amber); }
.chip.primary:hover { background: #ffc671; }
.chip:disabled { opacity: .45; cursor: default; }

/* ---------- game ---------- */
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-title { font-family: var(--display); font-weight: 400; margin: 0; flex: 1; text-align: center; font-size: clamp(1.4rem, 4vw, 2.2rem); color: var(--amber); text-shadow: 0 0 12px rgba(255,179,71,.35); }
.topbar-actions { display: flex; gap: 8px; }

.roles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 10px; }
.role {
  border: 1px solid var(--glass-edge); background: rgba(0,0,0,.28); border-radius: 10px;
  padding: 7px 14px; cursor: pointer; font-size: .92rem;
}
.role[aria-checked="true"] { border-color: var(--amber); background: rgba(255,179,71,.14); color: #fff; box-shadow: 0 0 0 1px var(--amber) inset; }

.plates { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; max-width: 900px; margin: 0 auto 8px; }
.plate { background: linear-gradient(#d9b877, var(--brass) 55%, #9c7a3c); color: #2a1606; border-radius: 6px; padding: 5px 12px; font-weight: 800; font-size: .95rem; box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 2px 4px rgba(0,0,0,.4); min-height: 1.9em; }
.plate.left { text-align: left; }
.plate.mid { text-align: center; }
.plate.right { text-align: right; }

.bezel {
  position: relative;
  margin: 0 auto; max-width: 900px;
  padding: 14px;
  border-radius: 26px;
  background: #0d1117;
  box-shadow: inset 0 0 0 3px var(--brass), inset 0 0 0 9px #1a120b, 0 16px 34px rgba(0,0,0,.5);
}
#screen {
  display: block; margin: 0 auto; width: 100%; height: auto;
  border-radius: 12px; background: #06080c; touch-action: none; cursor: crosshair;
}
.panel {
  min-height: 520px; border-radius: 12px; background: #0a0e14; padding: 16px; overflow: auto;
}
.bezel.with-panel #screen { display: none; }
.bezel.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr); gap: 14px; }
.bezel.split .panel { min-height: 0; }
@media (max-width: 760px) { .bezel.split { grid-template-columns: 1fr; } }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: rgba(10, 12, 18, .88); border: 2px solid var(--amber); border-radius: 14px;
  padding: 14px 26px; text-align: center; pointer-events: none; max-width: 86%;
}
.banner-title { font-family: var(--display); color: var(--amber); font-size: clamp(1.3rem, 4vw, 2rem); line-height: 1.1; }
.banner-sub { color: var(--cream); margin-top: 6px; font-size: .98rem; }
.help { text-align: center; color: var(--muted); max-width: 60em; margin: 12px auto 0; font-size: .95rem; }
.help kbd { font-family: var(--body); font-weight: 800; background: rgba(0,0,0,.35); border: 1px solid var(--glass-edge); border-radius: 4px; padding: 0 5px; color: var(--cream); }

/* ---------- shared panel widgets (Imitation, Go) ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel h4 { font-family: var(--display); font-weight: 400; color: var(--amber); margin: 0; font-size: 1.15rem; }
.panel p { margin: 0; color: var(--muted); }
.field { background: #05070b; border: 1px solid var(--glass-edge); border-radius: 8px; color: var(--cream); padding: 8px 10px; font: inherit; }
.status { color: var(--cream); }
.status.dim { color: var(--muted); }

.chat { display: flex; flex-direction: column; height: min(62vh, 560px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px 4px; }
.msg { max-width: 78%; padding: 7px 12px; border-radius: 14px; line-height: 1.35; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: #6b3b10; color: #fff3df; border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: #253041; color: var(--cream); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: .88rem; text-align: center; }
.typing { color: var(--muted); font-size: .85rem; min-height: 1.3em; padding: 0 4px; }
.chat-input { display: flex; gap: 8px; }
.chat-input .field { flex: 1; }
.timer { font-family: var(--display); color: var(--amber); font-size: 1.1rem; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--glass-edge); border-top-color: var(--amber); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .cab { transition: none; } }

@media (max-width: 560px) {
  .plates { grid-template-columns: 1fr 1fr; }
  .plate.mid { grid-column: 1 / -1; order: -1; }
}
