/* Ludi Don — rum-shop-at-night UI around a hand-painted plywood board. */

@font-face {
  font-family: 'Anton';
  src: url('/fonts/anton.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito';
  src: url('/fonts/nunito.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --yardnight: #14100b;   /* warm near-black: the rum shop after dark */
  --yardnight-2: #1e1811; /* raised surfaces */
  --wood-1: #c89b5e;      /* plywood, lit */
  --wood-2: #a87840;      /* plywood, shade */
  --golden: #f7b500;      /* enamel gold */
  --irie:   #1d9e4f;      /* enamel green */
  --scotch: #e5322d;      /* enamel red */
  --cream:  #f5e9d0;      /* aged painted white */
  --ink:    #241a10;      /* paint outlines on wood */
  --muted:  #a89877;

  --display: 'Anton', 'Arial Narrow', sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(120% 90% at 50% 0%, #221a10 0%, var(--yardnight) 58%);
  color: var(--cream);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}
input, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
:focus-visible { outline: 3px solid var(--golden); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  overflow-y: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------------- HOME ---------------- */

.home-wrap {
  width: min(430px, 100%);
  padding: 4vh 20px 24px;
  display: flex; flex-direction: column; gap: 18px;
}

.logo { text-align: center; line-height: 0.86; margin-top: 1vh; }
.logo-word {
  font-family: var(--display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.logo-ludi {
  font-size: clamp(64px, 21vw, 96px);
  color: var(--golden);
  text-shadow: 0.045em 0.045em 0 var(--scotch), 0.09em 0.09em 0 rgba(0,0,0,.55);
  transform: rotate(-2.5deg);
}
.logo-don {
  font-size: clamp(64px, 21vw, 96px);
  color: var(--irie);
  text-shadow: 0.045em 0.045em 0 var(--cream), 0.09em 0.09em 0 rgba(0,0,0,.55);
  transform: rotate(1.6deg) translateX(0.06em);
  margin-top: 0.04em;
}
.logo-tag {
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 12px;
  text-transform: uppercase;
}

.home-card, .rooms-panel {
  background: var(--yardnight-2);
  border: 1px solid #3a2d1c;
  border-radius: 18px;
  padding: 16px;
}
.home-card { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
input[type="text"], input[type="password"] {
  background: #0d0a06;
  border: 2px solid #3a2d1c;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  width: 100%;
}
input[type="text"]:focus { border-color: var(--golden); outline: none; }

.home-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* Chunky screen-print buttons */
.btn {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 17px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .06s ease, box-shadow .06s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.7) brightness(.6); pointer-events: none; }
.btn-gold  { background: var(--golden); }
.btn-green { background: var(--irie); color: #08130c; }
.btn-line  { background: transparent; color: var(--cream); border-color: #4a3a24; box-shadow: 0 4px 0 #4a3a24; }
.btn-big   { font-size: 21px; padding: 15px 18px; }

.join-row { display: flex; gap: 10px; }
.join-row input {
  text-transform: uppercase; letter-spacing: .35em; text-align: center;
  font-family: var(--display); font-size: 22px; flex: 1.4;
}
.join-row .btn { flex: 1; }
.join-row input::placeholder {
  text-transform: none; letter-spacing: .04em; font-size: 18px;
  font-family: inherit; font-weight: 700;
}
.btn-wa { background: #25d366; color: #08130c; }

.rooms-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.rooms-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rooms-empty { color: #6d6049; font-size: 14px; padding: 6px 2px; }
.start-one {
  color: var(--golden); font: inherit; font-weight: 800;
  text-decoration: underline; text-underline-offset: 2px;
}
.room-item {
  display: flex; align-items: center; gap: 10px;
  background: #0d0a06; border: 1px solid #3a2d1c; border-radius: 12px;
  padding: 10px 12px; width: 100%;
  text-align: left;
}
.room-item b { font-family: var(--display); letter-spacing: .08em; color: var(--golden); }
.room-item .ri-host { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .ri-count { color: var(--muted); font-weight: 800; font-size: 13px; }

.home-record {
  text-align: center; color: var(--muted); font-weight: 700; font-size: 13px;
}
.home-record b { color: var(--golden); }

/* account overlay (claim guest account / log in) */
.acct-card { text-align: left; }
.acct-card .over-title { text-align: center; font-size: 34px; }
.acct-blurb { color: var(--muted); font-weight: 700; font-size: 14px; text-align: center; }
.acct-blurb b { color: var(--golden); }
#acct-form { display: flex; flex-direction: column; gap: 12px; }
.acct-err {
  color: #ff8a7a; font-weight: 800; font-size: 13px; text-align: center;
}

.home-foot { display: flex; justify-content: center; gap: 12px; }
.mini-btn {
  background: #0d0a06; border: 1px solid #3a2d1c; border-radius: 10px;
  color: var(--muted); font-weight: 800; font-size: 13px;
  padding: 8px 12px;
}

/* ---------------- LOBBY ---------------- */

.room-wrap {
  width: min(430px, 100%);
  padding: 14px 20px 30px;
  display: flex; flex-direction: column; gap: 16px;
}
.room-head { display: flex; align-items: center; gap: 12px; }
.room-code-box { flex: 1; text-align: center; }
.room-code-label {
  display: block; font-size: 10px; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
}
.room-code {
  font-family: var(--display); font-size: 30px; letter-spacing: .18em;
  color: var(--golden); padding: 2px 8px; white-space: nowrap;
}
.room-vis { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

.member-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.member {
  display: flex; align-items: center; gap: 12px;
  background: var(--yardnight-2); border: 1px solid #3a2d1c;
  border-radius: 14px; padding: 10px 14px;
}
.member .dot { width: 12px; height: 12px; border-radius: 50%; background: #555; flex: none; }
.member .dot.on { background: var(--irie); box-shadow: 0 0 8px var(--irie); }
.member .m-name { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .m-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); background: var(--golden); border-radius: 6px; padding: 2px 7px;
}
.member .m-tag.bot { background: #5c4a2e; color: var(--cream); }
.member .m-tag.star { background: transparent; color: var(--golden); font-size: 13px; padding: 0; }
.member .m-kick { color: #7a6a4d; font-size: 18px; padding: 2px 6px; }

.host-panel {
  background: var(--yardnight-2); border: 1px solid #3a2d1c;
  border-radius: 18px; padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.cfg-row { display: flex; align-items: center; gap: 10px; }
.cfg-label {
  width: 84px; flex: none;
  font-size: 11px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.seg { display: flex; flex: 1; background: #0d0a06; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border-radius: 8px; padding: 7px 4px;
  font-weight: 800; font-size: 13px; color: var(--muted);
}
.seg button.on { background: var(--golden); color: var(--ink); }
.seg button:disabled { opacity: .35; pointer-events: none; }
.lobby-actions { margin-top: 4px; }
.guest-note, .board-note { text-align: center; color: var(--muted); font-weight: 700; font-size: 14px; }
.look-row {
  margin-top: 2px; padding: 10px 14px;
  background: var(--yardnight-2); border: 1px solid #3a2d1c; border-radius: 14px;
}

/* ---------------- GAME ---------------- */

.game-wrap {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
}
.game-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 4px;
}
.seatbar {
  flex: 1; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap;
}
.seat-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--yardnight-2); border: 2px solid transparent;
  border-radius: 999px; padding: 3px 9px 3px 5px;
  font-size: 12px; font-weight: 800;
  transition: border-color .2s, box-shadow .2s;
}
.seat-chip .sc-swatch {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.5); flex: none;
}
.seat-chip .sc-name { max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-chip .sc-home { color: var(--muted); font-size: 11px; }
.seat-chip.turn { border-color: var(--golden); box-shadow: 0 0 10px rgba(247,181,0,.45); }
.seat-chip.gone { opacity: .45; }
.seat-chip .sc-emote {
  position: absolute; font-size: 22px; transform: translateY(-26px);
  opacity: 0; pointer-events: none;
}
.seat-chip { position: relative; }

.board-holder {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 6px 10px;
}
.board-holder svg {
  width: 100%; height: 100%;
  max-width: min(96vw, 92vh - 210px);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* big stamped patois callouts */
.callout {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font-family: var(--display);
  font-size: clamp(44px, 13vw, 84px);
  text-transform: uppercase;
  color: var(--golden);
  text-shadow: 0.05em 0.05em 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
  opacity: 0;
  z-index: 5;
}
.callout.stamp { animation: stamp 1.05s cubic-bezier(.2,1.6,.35,1) forwards; }
.callout.red { color: var(--scotch); }
.callout.green { color: var(--irie); }
@keyframes stamp {
  0%   { opacity: 0; transform: scale(2.4) rotate(-9deg); }
  18%  { opacity: 1; transform: scale(1) rotate(-6deg); }
  70%  { opacity: 1; transform: scale(1) rotate(-6deg); }
  100% { opacity: 0; transform: scale(.92) rotate(-6deg); }
}

.game-dock {
  padding: 4px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.turn-line {
  font-weight: 800; font-size: 14px; color: var(--muted);
  min-height: 20px; text-align: center;
}
.turn-line b { color: var(--cream); }
.turn-line .clock { color: var(--golden); font-variant-numeric: tabular-nums; }

.dice-dock { display: flex; align-items: center; gap: 14px; }
.die {
  width: 58px; height: 58px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 4px 0 var(--ink), inset 0 -4px 0 rgba(0,0,0,.12);
  position: relative;
  display: grid; grid-template: repeat(3,1fr)/repeat(3,1fr);
  padding: 8px; gap: 2px;
  transition: transform .12s, opacity .2s, box-shadow .2s;
}
.die .pip { width: 100%; aspect-ratio: 1; border-radius: 50%; background: var(--ink); align-self: center; justify-self: center; opacity: 0; transform: scale(.85); }
.die .pip.on { opacity: 1; }
.die.used { opacity: .28; transform: scale(.9); }
.die.pick { box-shadow: 0 0 0 3px var(--golden), 0 4px 0 var(--ink); }
.die.rolling { animation: tumble .55s ease-in-out; }
@keyframes tumble {
  0% { transform: rotate(0) translateY(0); }
  25% { transform: rotate(210deg) translateY(-16px) scale(1.08); }
  55% { transform: rotate(420deg) translateY(-4px); }
  80% { transform: rotate(560deg) translateY(-8px); }
  100% { transform: rotate(720deg) translateY(0); }
}
.die[hidden] { display: none; }

.btn-roll { font-size: 22px; padding: 13px 26px; border-radius: 16px; }
.btn-roll.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 0 var(--ink), 0 0 0 0 rgba(247,181,0,.55); }
  50%      { box-shadow: 0 4px 0 var(--ink), 0 0 0 12px rgba(247,181,0,0); }
}

.emote-row { display: flex; gap: 8px; }
.emote-row button {
  font-size: 19px; background: var(--yardnight-2);
  border: 1px solid #3a2d1c; border-radius: 10px; padding: 4px 9px;
}

/* ---------------- BOARD SVG ---------------- */

.cell-tappable { cursor: pointer; }
.piece { transition: filter .2s; cursor: pointer; }
.piece.legal { filter: drop-shadow(0 0 5px var(--golden)); }
.piece .halo { opacity: 0; }
.piece.legal .halo { opacity: 1; animation: halo 1s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes halo { 0%,100% { transform: scale(1); } 50% { transform: scale(1.35); } }

/* ---------------- OVERLAYS ---------------- */

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 7, 4, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.over-card {
  width: min(420px, 100%);
  max-height: 88vh; overflow-y: auto;
  background: var(--yardnight-2); border: 2px solid #4a3a24;
  border-radius: 20px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
}
.over-title {
  font-family: var(--display); font-size: 42px; letter-spacing: .04em;
  color: var(--golden);
  text-shadow: 3px 3px 0 var(--scotch);
  transform: rotate(-2deg);
}
.over-chant { color: var(--muted); font-weight: 700; font-style: italic; }
.standings { list-style: none; display: flex; flex-direction: column; gap: 7px; text-align: left; }
.standings li {
  display: flex; align-items: center; gap: 10px;
  background: #0d0a06; border-radius: 12px; padding: 9px 12px;
  font-weight: 800;
}
.standings .st-place { font-family: var(--display); width: 30px; color: var(--muted); }
.standings li:first-child .st-place { color: var(--golden); }
.standings .st-swatch { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(0,0,0,.5); }
.standings .st-name { flex: 1; }
.standings .st-homes { color: var(--muted); font-size: 13px; text-align: right; line-height: 1.3; }
.standings .st-stats { font-size: 11px; color: #6d6049; }

.over-series { color: var(--cream); font-weight: 700; font-size: 14px; }
.over-series b { color: var(--golden); }
.over-motm { color: var(--muted); font-weight: 700; font-size: 14px; }
.over-motm b { color: var(--golden); }
.over-next { color: var(--cream); font-weight: 700; font-size: 14px; }
.over-next b { color: var(--golden); font-variant-numeric: tabular-nums; }

.confirm-card { width: min(340px, 100%); }
.confirm-title { font-size: 34px; }
.confirm-msg { color: var(--cream); font-weight: 700; }

.how-card { text-align: left; }
.how-card .over-title { text-align: center; }
.how-body { font-size: 15px; display: flex; flex-direction: column; gap: 10px; }
.how-body ul { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.how-body b { color: var(--golden); }

/* ---------------- toast / banner / chat ---------------- */

.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--scotch); color: #fff;
  text-align: center; font-weight: 800; font-size: 14px;
  padding: 8px calc(10px + env(safe-area-inset-right)) 8px calc(10px + env(safe-area-inset-left));
}
.toast {
  position: fixed; left: 50%; bottom: 130px; z-index: 70;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--cream);
  border: 1px solid #4a3a24; border-radius: 12px;
  padding: 10px 16px; font-weight: 800; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.chat-fab {
  position: fixed; right: 14px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 30;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--yardnight-2); border: 1px solid #3a2d1c;
  font-size: 20px;
}
.chatlog {
  position: fixed; left: 10px; bottom: calc(200px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; flex-direction: column; gap: 4px;
  max-width: 68vw; pointer-events: none;
}
.chat-msg {
  background: rgba(20, 15, 9, .92); border: 1px solid #3a2d1c;
  border-radius: 10px; padding: 5px 10px;
  font-size: 13px; font-weight: 700;
  animation: chatfade 6s forwards;
}
.chat-msg b { color: var(--golden); }
@keyframes chatfade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }
.chatbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 65;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--yardnight-2); border-top: 1px solid #3a2d1c;
}
.chatbar-row { display: flex; gap: 8px; }
.chatbar input { flex: 1; }

/* one-tap trash talk */
.taunt-row {
  display: flex; gap: 6px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.taunt-row::-webkit-scrollbar { display: none; }
.taunt-chip {
  flex: none;
  background: #0d0a06; border: 1px solid #4a3a24; border-radius: 999px;
  color: var(--golden); font-weight: 800; font-size: 13px;
  padding: 6px 12px; white-space: nowrap;
}
.taunt-chip:active { background: var(--golden); color: var(--ink); }

@media (min-width: 700px) {
  .game-wrap { max-width: 720px; }
  .board-holder svg { max-width: min(70vw, 92vh - 230px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  /* these rely on an animation's END state to stay visible — with animations
     collapsed they'd vanish instantly; show them statically (JS removes them) */
  .chat-msg { animation: none !important; }
  .callout.stamp { animation: none !important; opacity: 1; transform: scale(1) rotate(-6deg); }
}
