/* --------------------------------------------------------------------------
   The board client. The 3D scene owns the whole viewport; everything else is
   a slab of HUD floating over it. Same block chrome as the site.
   -------------------------------------------------------------------------- */

:root {
  --gold:   #ffd23f;
  --grass:  #4caf3f;
  --red:    #e02020;
  --ink:    rgba(13, 10, 22, .84);
  --ink-2:  rgba(31, 25, 48, .92);
  --edge:   #000;
  --text:   #eceaf6;
  --muted:  #a7a3c0;
  --mono: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #5c94fc;
  font-family: var(--mono);
  color: var(--text);
  letter-spacing: .02em;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: rgba(255, 210, 63, .28);
}

#stage {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;      /* the orbit controls want the gestures */
}

img { image-rendering: pixelated; }

/* ---- loading ------------------------------------------------------------- */

.boot {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: #5c94fc;
  transition: opacity .5s ease;
}
.boot.gone { opacity: 0; pointer-events: none; }
.boot-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: #0d0a16; border: 4px solid var(--gold);
  box-shadow: 0 0 0 4px #000, 0 12px 0 rgba(0,0,0,.45);
  padding: 26px 36px;
}
.boot-card b { color: var(--gold); letter-spacing: .18em; font-size: 15px; }
.boot-card span { color: var(--muted); font-size: 11px; letter-spacing: .14em; }

/* ---- HUD slabs ----------------------------------------------------------- */

.hud {
  position: fixed; z-index: 40;
  width: 292px;
  background: var(--ink);
  border: 4px solid var(--edge);
  box-shadow: inset 3px 3px 0 rgba(255,255,255,.10),
              inset -3px -3px 0 rgba(0,0,0,.5), 0 8px 0 rgba(0,0,0,.35);
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column;
}
.hud-tl { top: 58px; left: 14px; max-height: min(52vh, 430px); }
.hud-tr { top: 58px; right: 14px; }

.hud-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink-2); border-bottom: 4px solid var(--edge);
  padding: 7px 10px;
  font-size: 10px; font-weight: bold; letter-spacing: .2em; color: var(--gold);
}
.hud-body { padding: 11px; }
.hud-note {
  padding: 6px 10px 8px; font-size: 9px; letter-spacing: .08em;
  color: #7b769a; border-top: 2px dotted #37325a;
}

.hud.collapsed .chat-log,
.hud.collapsed .chat-form,
.hud.collapsed .hud-body,
.hud.collapsed .hud-note { display: none; }

/* ---- chat ---------------------------------------------------------------- */

.chat-log {
  flex: 1; overflow-y: auto; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11.5px; line-height: 1.5;
  scrollbar-width: thin;
}
.msg { display: flex; gap: 6px; animation: msgIn .25s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateX(-6px); } }
.msg .who { flex: 0 0 auto; font-weight: bold; }
.msg .txt { min-width: 0; word-wrap: break-word; }
.msg.sys .txt { color: var(--gold); }
.msg.good .txt { color: #9ae88a; }
.msg.bad .txt { color: #ff8a8a; }
.msg.jail .txt { color: #ffab5e; }
.msg.card .txt { color: #b39bff; }
.msg.you .who { color: var(--gold); }
.msg.talk .txt { color: #dcd9ee; }

.chat-form { display: flex; gap: 5px; padding: 8px; border-top: 4px solid var(--edge); }
.chat-form input {
  flex: 1; min-width: 0;
  background: #000; color: var(--text);
  border: 3px solid #3a3358; padding: 7px 8px;
  font-family: var(--mono); font-size: 12px;
}
.chat-form input:focus { outline: none; border-color: var(--gold); }

/* ---- stats --------------------------------------------------------------- */

.bigclock {
  font-size: 33px; font-weight: bold; color: var(--gold);
  text-shadow: 3px 3px 0 #000; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clockbar { height: 10px; background: #000; border: 3px solid #3a3358; margin: 8px 0 11px; }
.clockbar i { display: block; height: 100%; background: var(--grass); transition: width .5s linear; }

.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 11px; }
.statrow div { background: #000; border: 2px solid #322c52; padding: 6px 7px; }
.statrow b { display: block; font-size: 14px; color: var(--gold); }
.statrow span { font-size: 8px; letter-spacing: .1em; color: var(--muted); }

.seatlist { display: flex; flex-direction: column; gap: 3px; }
.seat3 {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 6px; border: 2px solid transparent;
}
.seat3.active { border-color: var(--gold); background: rgba(255,210,63,.10); }
.seat3.you .nm::after { content: " (YOU)"; color: var(--gold); font-size: 9px; }
.seat3 img { width: 24px; height: 24px; }
.seat3 .nm {
  flex: 1; min-width: 0; font-size: 11px; font-weight: bold;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat3 .bg { font-size: 12px; font-weight: bold; color: var(--grass); }
.seat3 .jl { font-size: 9px; color: var(--red); margin-left: 5px; }

/* ---- dock ---------------------------------------------------------------- */

.dock {
  position: fixed; z-index: 40; left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); border: 4px solid var(--edge);
  box-shadow: inset 3px 3px 0 rgba(255,255,255,.10), 0 8px 0 rgba(0,0,0,.35);
  padding: 10px 14px;
}
.dock-turn { display: flex; align-items: center; gap: 9px; }
.dock-turn b { display: block; font-size: 13px; letter-spacing: .1em; }
.dock-turn span { font-size: 9.5px; letter-spacing: .12em; color: var(--muted); }
.dock-dice { display: flex; gap: 6px; }
.dock-dice span {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: #000; border: 3px solid #3a3358;
  font-size: 16px; font-weight: bold; color: var(--gold);
}

/* ---- buttons ------------------------------------------------------------- */

.btn, .mini {
  position: relative; overflow: hidden;
  font-family: var(--mono); font-weight: bold; text-transform: uppercase;
  letter-spacing: .1em; color: #fff; background: #2a2340;
  border: 3px solid var(--edge); cursor: pointer;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.18),
              inset -2px -2px 0 rgba(0,0,0,.5), 0 4px 0 #000;
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn { padding: 12px 20px; font-size: 14px; }
.mini { padding: 6px 9px; font-size: 10px; }
.btn::after, .mini::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 34%, rgba(255,255,255,.5) 47%, transparent 60%);
  transform: translateX(-130%);
}
.btn:hover::after, .mini:hover::after { animation: shine .6s ease-out; }
@keyframes shine { to { transform: translateX(130%); } }
.btn:hover, .mini:hover { filter: brightness(1.15); transform: translateY(-2px); }
.btn:active, .mini:active { transform: translateY(3px); box-shadow: inset 2px 2px 0 rgba(255,255,255,.18); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; animation: none; }
.btn:disabled::after { display: none; }
.btn-gold { background: var(--gold); color: #241a00; animation: bulbs 2.4s ease-in-out infinite; }
.btn-gold:hover, .btn-gold:disabled { animation: none; }
@keyframes bulbs {
  0%, 100% { box-shadow: inset 2px 2px 0 rgba(255,255,255,.18), 0 4px 0 #000, 0 0 0 rgba(255,210,63,0); }
  50%      { box-shadow: inset 2px 2px 0 rgba(255,255,255,.18), 0 4px 0 #000, 0 0 26px rgba(255,210,63,.65); }
}
.mini.ghost { background: rgba(13,10,22,.8); }
.mini.ghost.on { background: var(--grass); color: #06240a; }
.send { background: var(--gold); color: #241a00; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---- top nav ------------------------------------------------------------- */

.topnav {
  position: fixed; z-index: 45; top: 12px; left: 14px; right: 14px;
  display: flex; align-items: center; gap: 8px;
}
.back {
  font-size: 11px; font-weight: bold; letter-spacing: .14em;
  color: var(--gold); text-decoration: none;
  background: var(--ink); border: 3px solid var(--edge); padding: 7px 11px;
}
.back:hover { filter: brightness(1.2); }
.pill {
  font-size: 9.5px; font-weight: bold; letter-spacing: .14em;
  background: var(--gold); color: #241a00;
  border: 3px solid var(--edge); padding: 5px 8px;
}
.topnav .mini { margin-left: 0; }
.topnav #btnView { margin-left: auto; }

/* ---- tile readout -------------------------------------------------------- */

.tilecard {
  position: fixed; z-index: 40; right: 14px; bottom: 16px; width: 250px;
  background: var(--ink); border: 4px solid var(--edge);
  box-shadow: inset 3px 3px 0 rgba(255,255,255,.10), 0 8px 0 rgba(0,0,0,.35);
  padding: 11px;
  animation: msgIn .2s ease-out;
}
.tc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.tc-head img { width: 34px; height: 34px; }
.tc-head b { font-size: 15px; color: var(--gold); letter-spacing: .06em; }
.tc-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 10.5px; padding: 4px 0; border-bottom: 2px dotted #37325a;
}
.tc-row span { color: var(--muted); letter-spacing: .08em; }
.tc-row b { color: #fff; }
.tc-note { font-size: 9.5px; color: var(--muted); line-height: 1.6; margin-top: 7px; }

/* ---- toast --------------------------------------------------------------- */

.toast3d {
  position: fixed; z-index: 50; left: 50%; top: 62px;
  transform: translateX(-50%);
  background: #000; color: var(--gold);
  border: 4px solid var(--gold);
  padding: 10px 18px; font-size: 13px; font-weight: bold; letter-spacing: .08em;
  max-width: min(560px, 78vw); text-align: center; pointer-events: none;
  box-shadow: 0 6px 0 rgba(0,0,0,.5);
  animation: msgIn .3s ease-out;
}

/* ---- narrow -------------------------------------------------------------- */

@media (max-width: 900px) {
  .hud { width: 250px; }
  .hud-tl { max-height: 34vh; }
}

@media (max-width: 720px) {
  .hud { width: calc(50vw - 20px); }
  .hud-tl, .hud-tr { top: 54px; max-height: 25vh; }
  .chat-log { font-size: 10.5px; }
  .seat3 { padding: 3px 4px; }
  .seat3 img { width: 20px; height: 20px; }
  .hud-tl { left: 10px; }
  .hud-tr { right: 10px; }
  .statrow { grid-template-columns: 1fr 1fr; }
  .statrow div:last-child { display: none; }
  .bigclock { font-size: 24px; }
  .seat3 .bg { font-size: 11px; }
  .tilecard { display: none; }
  .dock { bottom: 10px; gap: 9px; padding: 8px 10px; width: calc(100vw - 20px); }
  .dock .btn { flex: 1; padding: 13px 8px; font-size: 12px; }
  .dock-dice { display: none; }
  .topnav { gap: 6px; }
  .topnav .pill { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
