/* Velvet Aces: oxblood velvet room, teal felt, ivory paper, brass trim. */

@font-face {
  font-family: "Gloock";
  src: url("../assets/fonts/gloock-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../assets/fonts/instrument-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../assets/fonts/instrument-sans-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --velvet: #3b0b17;
  --velvet-deep: #14050a;
  --ink: #101a22;
  --felt: #0e4d43;
  --ivory: #efe6d2;
  --ivory-dim: rgba(239, 230, 210, 0.74);
  --line: rgba(239, 230, 210, 0.16);
  --brass: #c9a24a;
  --brass-hi: #e0bf6a;
  --red: #c4303f;
  --panel: rgba(16, 8, 11, 0.78);
  --display: "Gloock", "Times New Roman", serif;
  --ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--velvet-deep);
  color: var(--ivory);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

/* ---------------------------------------------------------------- scene */

#stage { position: fixed; inset: 0; }
#stage canvas { touch-action: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 52%, rgba(5, 1, 3, 0.62) 100%);
}
#grain {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
#boot {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--velvet-deep); font-family: var(--display); font-size: 1.6rem; color: var(--brass);
  transition: opacity 0.7s ease;
}
body:not(.is-loading) #boot { opacity: 0; pointer-events: none; }
.noscript {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
  background: var(--velvet-deep); text-align: center; font-size: 1.1rem;
}

/* ---------------------------------------------------------------- lobby */

#lobby {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; pointer-events: none;
  padding: clamp(20px, 5vw, 72px); padding-top: 72px;
}
.lobby-col { pointer-events: auto; width: min(100%, 540px); }
#lobby h1 {
  margin: 0 0 12px; font-family: var(--display); font-weight: 400;
  font-size: clamp(3.2rem, 8.4vw, 7rem); line-height: 0.94; letter-spacing: -0.01em; color: var(--ivory);
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.6);
}
#lobby .lead { margin: 0 0 28px; max-width: 34ch; font-size: 1.1rem; color: var(--ivory-dim); }
.game-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.game-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name meta" "desc meta"; column-gap: 20px; align-items: center;
  padding: 16px 6px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none;
  transition: padding-left 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.game-row:hover, .game-row:focus-visible { padding-left: 16px; border-bottom-color: var(--brass); background: linear-gradient(90deg, rgba(201, 162, 74, 0.1), transparent 70%); }
.game-name { grid-area: name; font-family: var(--display); font-size: 1.85rem; line-height: 1.1; }
.game-desc { grid-area: desc; font-size: 0.95rem; color: var(--ivory-dim); }
.game-meta { grid-area: meta; font-size: 0.9rem; color: var(--brass-hi); text-align: right; }
.lobby-foot { margin-top: 24px; font-size: 0.85rem; color: var(--ivory-dim); max-width: 46ch; }
.lobby-foot p { margin: 0 0 8px; }
.lobby-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.lobby-foot a { color: var(--ivory); text-underline-offset: 3px; }
.lobby-foot a:hover { color: var(--brass-hi); }

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

#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
#labels { pointer-events: none; position: absolute; inset: 0; overflow: hidden; }
#labels > * { pointer-events: none; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; background: linear-gradient(rgba(10, 3, 6, 0.82), transparent);
}
.brand { font-family: var(--display); font-size: 1.3rem; color: var(--ivory); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--brass-hi); }
.game-title { color: var(--ivory-dim); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.balance {
  display: flex; align-items: baseline; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px);
}
.balance-label { font-size: 0.8rem; color: var(--ivory-dim); }
.balance b { font-family: var(--display); font-weight: 400; font-size: 1.25rem; font-variant-numeric: tabular-nums; color: var(--brass-hi); }
.icon-btn {
  min-width: 40px; height: 40px; padding: 0 12px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px);
}
.icon-btn:hover { border-color: var(--brass); }
.home-btn { color: var(--ivory); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 0.95rem; white-space: nowrap; }
.home-btn:hover, .home-btn:focus-visible { border-color: var(--brass); color: var(--brass-hi); }
body.is-lobby .brand, body.is-lobby .game-title, body.is-lobby .home-btn { visibility: hidden; }
body.is-lobby .dock { display: none; }

.popover {
  position: absolute; top: 58px; right: 16px; width: 240px; padding: 14px; border-radius: 14px; z-index: 20;
  background: #1b0c12; border: 1px solid rgba(201, 162, 74, 0.35); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  display: grid; gap: 8px;
}
.pop-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95rem; }
.pop-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brass); }
.popover input[type="range"] { width: 100%; accent-color: var(--brass); margin: 0 0 6px; }
.select-row { justify-content: space-between; }
.select-row select { background: #2a1219; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

#status {
  position: absolute; left: 50%; bottom: calc(168px + var(--safe-b)); transform: translateX(-50%);
  max-width: min(92vw, 640px); padding: 10px 20px; border-radius: 14px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px);
  font-size: 1.05rem; font-weight: 600; pointer-events: none;
}
#status.tone-win { border-color: var(--brass); color: var(--brass-hi); }
#status.tone-lose { border-color: rgba(196, 48, 63, 0.6); color: #f0b4ba; }
#status.tone-info { color: var(--ivory); }

.dock {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 28px 16px calc(14px + var(--safe-b)); background: linear-gradient(transparent, rgba(8, 2, 5, 0.9) 45%);
}
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 48px; }
.btn {
  min-height: 48px; padding: 0 22px; border-radius: 12px; border: 1px solid var(--line); background: rgba(239, 230, 210, 0.08);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  font-weight: 600; font-size: 1rem; transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn small { font-size: 0.72rem; font-weight: 400; color: inherit; opacity: 0.75; }
.btn:hover:not(:disabled) { border-color: var(--brass); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #e0bf6a, #b88f3a); color: #2a070f; border-color: #e8cd86; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ecd078, #c49a42); }
.btn-danger { background: #6f1824; border-color: #a02c3b; }

/* betting */
#bet-panel { display: grid; gap: 10px; justify-items: center; }
.spots { display: flex; gap: 8px; }
.spot-btn {
  display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: 6px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line);
}
.spot-btn span { font-size: 0.85rem; color: var(--ivory-dim); }
.spot-btn b { font-family: var(--display); font-weight: 400; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.spot-btn.active { border-color: var(--brass); background: rgba(201, 162, 74, 0.16); }
.bet-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px 22px; }
.chip-picker { display: flex; gap: 10px; }
.chip-btn {
  position: relative; z-index: 0; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 0; padding: 0;
  background: repeating-conic-gradient(var(--chip-stripe) 0 22.5deg, var(--chip) 22.5deg 45deg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); font-family: var(--display); font-size: 0.95rem; color: var(--chip-text);
  transition: transform 0.12s ease;
}
.chip-btn::after {
  content: ""; position: absolute; inset: 7px; z-index: 0; border-radius: 50%; background: var(--chip); border: 1.5px solid var(--chip-stripe);
}
.chip-btn span { position: relative; z-index: 1; }
.chip-btn:hover:not(:disabled) { transform: translateY(-4px); }
.chip-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.bet-meta { display: flex; align-items: center; gap: 14px; }
.bet-total { display: flex; flex-direction: column; line-height: 1.1; }
.bet-total span { font-size: 0.8rem; color: var(--ivory-dim); }
.bet-total b { font-family: var(--display); font-weight: 400; font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--brass-hi); }
.link-btn { background: none; border: 0; padding: 6px 4px; color: var(--ivory); text-decoration: underline; text-underline-offset: 3px; font-size: 0.95rem; }
.link-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* labels pinned to the 3D table */
.seat-label {
  position: absolute; left: 0; top: 0; padding: 5px 12px; border-radius: 12px; text-align: center; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(4px); font-size: 0.85rem; line-height: 1.2;
}
.seat-label b { display: block; font-weight: 600; }
.seat-label span { display: block; color: var(--ivory-dim); font-size: 0.8rem; }
.seat-label.active { border-color: var(--brass); box-shadow: 0 0 0 2px rgba(201, 162, 74, 0.35); }
.seat-label.folded { opacity: 0.5; }
.seat-label.win { border-color: var(--brass-hi); background: rgba(201, 162, 74, 0.25); }
.seat-label.score b { font-family: var(--display); font-weight: 400; font-size: 1.1rem; }

/* side panel (video poker pay table, baccarat road) */
#side-panel {
  position: absolute; top: 72px; left: 16px; max-width: 250px; padding: 12px 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px); font-size: 0.9rem;
}
#side-panel table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
#side-panel td { padding: 2px 4px; }
#side-panel td:not(:first-child) { text-align: right; color: var(--ivory-dim); }
#side-panel tr.hit td { color: var(--ink); background: var(--brass-hi); }
#side-panel tr.col td.on { color: var(--brass-hi); }
#side-panel h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 1.05rem; }
.road { display: flex; flex-wrap: wrap; gap: 5px; max-width: 220px; }
.road i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 0.65rem; font-weight: 600; color: #fff; }
.road i.p { background: #2d5f9a; }
.road i.b { background: var(--red); }
.road i.t { background: #2f7d55; }

/* raise control for hold'em */
.raise-box { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.raise-box input[type="range"] { width: min(46vw, 260px); accent-color: var(--brass); }
.raise-box output { min-width: 64px; text-align: right; font-family: var(--display); font-size: 1.15rem; color: var(--brass-hi); font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- overlays */

#modal-root { position: fixed; inset: 0; z-index: 40; }
.modal-back { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 2, 5, 0.74); backdrop-filter: blur(4px); }
.modal {
  width: min(100%, 520px); max-height: 86vh; overflow: auto; padding: 24px; border-radius: 18px;
  background: #1b0c12; border: 1px solid rgba(201, 162, 74, 0.4); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal h2 { margin: 0 0 10px; font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1.1; }
.modal-body { color: var(--ivory-dim); }
.modal-body p { margin: 0 0 12px; }
.modal-body h3 { margin: 16px 0 6px; color: var(--ivory); font-size: 1rem; }
.modal-body ul { margin: 0 0 12px; padding-left: 20px; }
.modal-body li { margin: 3px 0; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
#toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 45; max-width: 92vw; padding: 10px 18px; border-radius: 12px;
  background: #1b0c12; border: 1px solid var(--brass); font-weight: 600; font-size: 0.95rem; text-align: center;
}
#toast.show { animation: toast-in 0.25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------------------------- small */

@media (max-width: 760px) {
  #lobby { align-items: flex-end; padding: 16px 18px 20px; background: linear-gradient(transparent 20%, rgba(10, 3, 6, 0.88) 62%); }
  #lobby h1 { font-size: 3rem; margin-bottom: 6px; }
  #lobby .lead { margin-bottom: 14px; font-size: 1rem; }
  .game-row { padding: 11px 4px; }
  .game-name { font-size: 1.45rem; }
  .game-desc { font-size: 0.85rem; }
  .lobby-foot { margin-top: 14px; font-size: 0.78rem; }
  .game-title { display: none; }
  .brand { display: none; }
  .balance-label { display: none; }
  #side-panel { top: 62px; left: 10px; max-width: 190px; font-size: 0.8rem; padding: 8px 10px; }
  .dock { padding-left: 8px; padding-right: 8px; }
  .btn { min-height: 46px; padding: 0 16px; font-size: 0.95rem; }
  .chip-btn { width: 46px; height: 46px; font-size: 0.85rem; }
  .chip-btn::after { inset: 6px; }
  .chip-picker { gap: 7px; }
  #status { bottom: calc(176px + var(--safe-b)); font-size: 0.95rem; }
}
@media (max-height: 560px) and (orientation: landscape) {
  #status { bottom: calc(112px + var(--safe-b)); }
  .dock { padding-top: 14px; gap: 6px; }
  .chip-btn { width: 42px; height: 42px; }
  .chip-btn::after { inset: 5px; }
  #lobby { padding-top: 56px; }
  #lobby h1 { font-size: 2.6rem; }
  #lobby .lead { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.road i.rd { background: var(--red); }
.road i.bk { background: #121214; box-shadow: inset 0 0 0 1px var(--line); }
.road i.gr { background: #2f7d55; }
.road i { width: 22px; height: 22px; }
.chip-btn.sel { outline: 2px solid var(--brass-hi); outline-offset: 3px; }

.price-tag { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 10px 14px; border: 1px solid var(--brass); border-radius: 10px; background: rgba(20, 5, 10, 0.55); }
.price-tag div { display: flex; flex-direction: column; }
.price-tag b { font-family: var(--display); font-size: 1.5rem; color: var(--brass-hi); font-weight: 400; line-height: 1.1; }
.price-tag span { font-size: 0.8rem; color: var(--ivory-dim); }
.price-btn { color: var(--velvet-deep); background: var(--brass); padding: 8px 16px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.price-btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }
