/* farkle.party — medieval-tavern vibe, dark wood + parchment + brass */

:root {
  --bg:        #0e0a06;
  --bg-2:      #1a120a;
  --panel:     #20180d;
  --panel-2:   #2d2110;
  --ink:       #f4e8c8;
  --ink-dim:   #b9a87c;
  --ink-mute:  #7a6b48;
  --line:      #564a2c;
  --gold:      #e0b341;
  --gold-2:    #ffd966;
  --crimson:   #a51f1f;
  --crimson-2: #d83b3b;
  --moss:      #4a6a2a;
  --moss-2:    #7aa54a;
  --blue:      #3a5aa5;
  --rare:      #5b8fff;
  --legend:    #ff8a14;
  --shadow:    0 6px 20px rgba(0,0,0,.45);
  --shadow-lg: 0 14px 40px rgba(0,0,0,.6);
  --r-sm: 4px; --r-md: 8px; --r-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: 'Georgia', 'Iowan Old Style', serif; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 800px at 20% 0%, #2a1d0a 0%, transparent 60%),
    radial-gradient(900px 700px at 90% 100%, #1a0e04 0%, transparent 70%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 2px, transparent 2px 6px),
    var(--bg);
  min-height: 100vh;
}

/* ---------- layout / header ---------- */

.shell { max-width: 1180px; margin: 0 auto; padding: 18px 22px 80px; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px; margin-bottom: 22px;
}
.brand {
  font-family: 'Cinzel','Georgia',serif; font-weight: 700; font-size: 1.6rem;
  color: var(--gold); letter-spacing: .04em;
  text-decoration: none;
}
.nav { display: flex; gap: 4px; margin-left: 6px; }
.nav a {
  color: var(--ink-dim); text-decoration: none; padding: 6px 12px;
  border-radius: var(--r-sm); font-size: .95rem;
}
.nav a:hover, .nav a.active { color: var(--gold-2); background: rgba(224,179,65,.08); }
.user-block { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.coin-pill {
  background: linear-gradient(180deg, #4a3a14, #2a1f08);
  border: 1px solid var(--gold); color: var(--gold-2);
  padding: 4px 14px; border-radius: 100px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.coin-pill::before { content: "◉"; color: var(--gold-2); }

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

.btn {
  background: linear-gradient(180deg, #4a3614, #2a1f08);
  border: 1px solid var(--line); color: var(--ink);
  padding: 9px 18px; border-radius: var(--r-md);
  font-family: inherit; font-size: 1rem; cursor: pointer;
  transition: transform .08s, background .2s, border-color .2s, color .2s;
  box-shadow: var(--shadow);
}
.btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, #a51f1f, #5a0a0a);
  border-color: #5a0a0a; color: #fff7e0;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #d83b3b, #6a0a0a); border-color: var(--gold); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #2a1f08; border-color: #5a4014; font-weight: 700;
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(180deg, #ffe488, #ffc833); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { padding: 5px 11px; font-size: .85rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
  background: #1a120a; border: 1px solid var(--line); color: var(--ink);
  padding: 9px 12px; border-radius: var(--r-md);
  font-family: inherit; font-size: 1rem; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--gold); }

.input-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.input-row label { font-size: .85rem; color: var(--ink-dim); }

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 { font-family: 'Cinzel', serif; color: var(--gold); margin: 0 0 8px; letter-spacing: .03em; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- home ---------- */

.home-hero {
  position: relative;
  margin: -10px -22px 30px; /* break out of .shell padding */
  height: 380px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(224,179,65,.06), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(0,0,0,.6) 0%, transparent 60%),
    #0c0703;
}
.home-hero-bg { position: absolute; inset: 0; }
.home-hero-content {
  position: relative; z-index: 2;
  text-align: center;
  text-shadow: 0 4px 16px rgba(0,0,0,.85);
}
.home-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.5rem, 7vw, 5rem);
  letter-spacing: .08em;
  color: var(--gold-2);
  margin: 0;
  text-shadow:
    0 2px 0 #2a1f08,
    0 6px 0 #1a1208,
    0 18px 30px rgba(0,0,0,.7),
    0 0 50px rgba(255,200,80,.25);
}
.home-title-dot { color: var(--crimson-2); margin: 0 2px; }
.home-title-suffix { color: var(--ink); }
.home-subtitle {
  color: var(--ink-dim); font-size: clamp(1rem, 1.6vw, 1.2rem);
  max-width: 620px; margin: 12px auto 22px;
}
.home-cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.home-section-title {
  font-family: 'Cinzel', serif; color: var(--gold-2);
  font-size: 1.8rem; text-align: center;
  letter-spacing: .08em; margin: 30px 0 4px;
  text-transform: uppercase;
}
.home-section-sub { text-align: center; color: var(--ink-mute); margin: 0 0 22px; }
.home-guest { text-align: center; color: var(--ink-mute); margin-top: 30px; }
.home-guest .gold { color: var(--gold); text-decoration: underline; }

/* AI challenger tiles */
.ai-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 0 auto; max-width: 1000px; }
@media (max-width: 760px) { .ai-row { grid-template-columns: 1fr; } }
.ai-tile {
  background: linear-gradient(180deg, rgba(45,33,16,.85), rgba(15,10,5,.95));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; text-align: center; text-decoration: none;
  color: var(--ink);
  transition: transform .2s, border-color .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.ai-tile::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(224,179,65,.05));
  pointer-events: none;
}
.ai-tile:hover {
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: 0 12px 30px rgba(0,0,0,.6), 0 0 28px rgba(224,179,65,.2);
}
.ai-tile-frame {
  position: relative;
  border: 3px solid var(--gold); border-radius: var(--r-md);
  overflow: hidden; aspect-ratio: 1;
  background: var(--bg-2);
  box-shadow: inset 0 0 28px rgba(0,0,0,.6);
}
.ai-tile-frame img { width: 100%; height: 100%; object-fit: cover; }
.ai-tile-tier {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,.7); color: var(--gold-2);
  padding: 3px 10px; border-radius: 4px;
  font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
}
.ai-tile-name {
  font-family: 'Cinzel', serif; color: var(--gold-2);
  font-size: 1.3rem; margin: 12px 0 0; letter-spacing: .04em;
}
.ai-tile-tag { color: var(--ink-dim); font-size: .92rem; margin: 4px 0 8px; font-style: italic; }
.ai-tile-reward {
  color: var(--gold); font-weight: 700;
  background: rgba(224,179,65,.08); border-top: 1px solid rgba(224,179,65,.2);
  border-bottom: 1px solid rgba(224,179,65,.2);
  padding: 8px; margin: 0 -18px;
}
.ai-tile-cta {
  color: var(--crimson-2); font-weight: 700; margin-top: 8px;
  letter-spacing: .05em;
}

/* ---------- AI tiles ---------- */

.ai-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 28px; }
@media (max-width: 760px) { .ai-row { grid-template-columns: 1fr; } }
.ai-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px; text-align: center; transition: transform .15s, border-color .2s;
}
.ai-tile:hover { transform: translateY(-3px); border-color: var(--gold); }
.ai-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md);
  border: 2px solid var(--line); background: var(--bg-2); }
.ai-tile h3 { margin: 12px 0 4px; color: var(--gold-2); }
.ai-tile .tier { color: var(--ink-mute); font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; }
.ai-tile .reward { color: var(--gold); margin: 6px 0 12px; font-weight: 700; }

/* ---------- dice ---------- */

.table-felt {
  background:
    radial-gradient(ellipse at center, #2a3a18, #0c1604 80%);
  border: 6px solid #3a2308;
  border-radius: 24px;
  padding: 30px 20px;
  min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
  box-shadow: inset 0 0 40px rgba(0,0,0,.7);
}
.dice-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.die {
  width: 64px; height: 64px;
  background: linear-gradient(160deg, #fdf6dc, #d8c89a);
  border: 2px solid var(--line); border-radius: 10px;
  display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr;
  padding: 9px; box-shadow: 0 4px 0 #564a2c, 0 8px 16px rgba(0,0,0,.55);
  cursor: pointer; user-select: none;
  transition: transform .2s, box-shadow .15s, border-color .15s, background .15s;
  position: relative;
}
.die:hover { transform: translateY(-2px) rotate(-2deg); border-color: var(--gold); }
.die.picked {
  background: linear-gradient(160deg, #ffe488, #d8a430);
  border-color: var(--gold); transform: translateY(-6px) rotate(2deg);
  box-shadow: 0 4px 0 #5a4014, 0 0 0 3px rgba(255,217,102,.35), 0 8px 20px rgba(255,200,50,.4);
}
.die.scoring { animation: scoring-flash .9s ease-in-out infinite alternate; }
@keyframes scoring-flash {
  from { box-shadow: 0 4px 0 #564a2c, 0 0 12px rgba(255,217,102,.4); }
  to   { box-shadow: 0 4px 0 #564a2c, 0 0 22px rgba(255,217,102,.85); }
}
.die.disabled { opacity: .45; cursor: default; pointer-events: none; }
.die .pip { width: 12px; height: 12px; background: #1a1a1a; border-radius: 50%; }
.die.rolling { animation: roll-bounce .55s ease-out; }
@keyframes roll-bounce {
  0% { transform: translateY(0) rotate(0); }
  35% { transform: translateY(-22px) rotate(180deg); }
  70% { transform: translateY(-4px) rotate(330deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

/* Pip grid: face N is determined by data-face. */
.die[data-face="1"] .pip:nth-child(5) { visibility: visible; }
.die[data-face="2"] .pip:nth-child(1),
.die[data-face="2"] .pip:nth-child(9) { visibility: visible; }
.die[data-face="3"] .pip:nth-child(1),
.die[data-face="3"] .pip:nth-child(5),
.die[data-face="3"] .pip:nth-child(9) { visibility: visible; }
.die[data-face="4"] .pip:nth-child(1),
.die[data-face="4"] .pip:nth-child(3),
.die[data-face="4"] .pip:nth-child(7),
.die[data-face="4"] .pip:nth-child(9) { visibility: visible; }
.die[data-face="5"] .pip:nth-child(1),
.die[data-face="5"] .pip:nth-child(3),
.die[data-face="5"] .pip:nth-child(5),
.die[data-face="5"] .pip:nth-child(7),
.die[data-face="5"] .pip:nth-child(9) { visibility: visible; }
.die[data-face="6"] .pip:nth-child(1),
.die[data-face="6"] .pip:nth-child(3),
.die[data-face="6"] .pip:nth-child(4),
.die[data-face="6"] .pip:nth-child(6),
.die[data-face="6"] .pip:nth-child(7),
.die[data-face="6"] .pip:nth-child(9) { visibility: visible; }
.die .pip { visibility: hidden; align-self: center; justify-self: center; }

/* Dice skin overrides — applied via .skin-{slug} on parent */
.skin-iron .die { background: linear-gradient(160deg, #9aa3a8, #4d575c); }
.skin-iron .die .pip { background: #fff; }
.skin-bone .die { background: #f1e9d4; }
.skin-bloodstained .die { background: linear-gradient(160deg, #f5e9d4, #c98e8e); }
.skin-gilded .die { background: linear-gradient(160deg, #ffe88a, #7a5a14); }
.skin-onyx .die { background: linear-gradient(160deg, #383b44, #0c0d12); }
.skin-onyx .die .pip { background: #c0c6ff; }
.skin-stained_glass .die { background: linear-gradient(160deg, #1f2a55, #5b8fff); }
.skin-stained_glass .die .pip { background: #ffe9a0; }
.skin-driftwood .die { background: #a07a4a; }
.skin-saints_bones .die { background: #fff8e8; }

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

.match-shell { display: grid; grid-template-columns: 280px 1fr 280px; gap: 18px; }
@media (max-width: 1000px) { .match-shell { grid-template-columns: 1fr; } }
.player-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px;
}
.player-card.active { border-color: var(--gold); box-shadow: 0 0 22px rgba(224,179,65,.25); }
.player-card .name { font-family: 'Cinzel', serif; color: var(--gold-2); font-size: 1.1rem; }
.player-card .score { font-size: 2.2rem; color: var(--ink); font-weight: 700; margin: 4px 0; }
.player-card .turn-score { color: var(--gold); font-weight: 700; }
.portrait, .cam-slot {
  width: 100%; aspect-ratio: 1; border-radius: var(--r-md); object-fit: cover;
  background: var(--bg-2); border: 2px solid var(--line);
}
.cam-slot { position: relative; overflow: hidden; display:flex; align-items:center; justify-content:center; color: var(--ink-mute); font-size:.85rem; }
.cam-slot video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-frame-wrap { position: relative; }
.cam-frame-wrap .frame-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background-size: 100% 100%; background-repeat: no-repeat;
}

.actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  margin-top: 18px;
}
.banner {
  text-align: center; font-family: 'Cinzel', serif;
  font-size: 1.8rem; letter-spacing: .12em;
  padding: 12px 24px; border-radius: var(--r-md); margin: 14px auto;
}
.banner.hot { background: linear-gradient(180deg, #ff8a14, #a55114); color: #fff; box-shadow: 0 0 28px rgba(255,140,40,.55); }
.banner.farkle { background: linear-gradient(180deg, #5a0a0a, #1a0202); color: #ffd0d0; box-shadow: 0 0 28px rgba(220,40,40,.45); }
.banner.win { background: linear-gradient(180deg, #4a6a2a, #1c2a0a); color: #fff8e0; }
.banner.loss { background: linear-gradient(180deg, #3a3a3a, #1a1a1a); color: #b9a87c; }

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

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--gold);
  border-radius: var(--r-lg); padding: 22px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h2 { font-family: 'Cinzel', serif; color: var(--gold-2); margin-top: 0; }

#toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1200; }
.toast {
  background: var(--panel-2); border: 1px solid var(--gold);
  color: var(--ink); padding: 10px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow); animation: toast-in .25s ease-out;
}
.toast.error { border-color: var(--crimson-2); color: #ffd0d0; }
.toast.success { border-color: var(--moss-2); color: #d0f0a0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- shop ---------- */

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.item-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px; text-align: center;
  transition: border-color .2s, transform .15s;
}
.item-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.item-card.r-common    { border-left: 4px solid #b9a87c; }
.item-card.r-uncommon  { border-left: 4px solid var(--moss-2); }
.item-card.r-rare      { border-left: 4px solid var(--rare); }
.item-card.r-legendary { border-left: 4px solid var(--legend); }
.item-card.owned       { opacity: .65; }
.item-card.equipped    { box-shadow: 0 0 0 2px var(--gold); }
.item-card img { width: 80px; height: 80px; object-fit: contain; }
.item-card .name { font-weight: 700; color: var(--gold-2); margin: 6px 0 2px; font-size: .95rem; }
.item-card .rarity { font-size: .72rem; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .12em; }
.item-card .price { color: var(--gold); margin-top: 6px; font-weight: 700; }

.lootbox-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .lootbox-row { grid-template-columns: 1fr; } }
.lootbox {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; text-align: center;
}
.lootbox.common    { border-color: #b9a87c; }
.lootbox.rare      { border-color: var(--rare); }
.lootbox.legendary { border-color: var(--legend); box-shadow: 0 0 24px rgba(255,138,20,.25); }
.lootbox h3 { font-family: 'Cinzel', serif; color: var(--gold-2); margin: 0 0 6px; }
.pity-bar { background: var(--bg-2); height: 6px; border-radius: 3px; overflow: hidden; margin: 8px 0; }
.pity-bar .fill { height: 100%; background: var(--gold); }

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

.lobby-shell { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 900px) { .lobby-shell { grid-template-columns: 1fr; } }
.lobby-controls { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.wager-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.wager-row input { max-width: 140px; }

.countdown {
  font-family: 'Cinzel', serif; font-size: 6rem; text-align: center;
  color: var(--gold-2); text-shadow: 0 0 30px rgba(255,217,102,.5);
  margin: 40px 0; animation: pulse 1s ease-in-out;
}
@keyframes pulse {
  0% { transform: scale(.5); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------- leaderboard ---------- */

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.lb-table th { color: var(--gold); font-family: 'Cinzel', serif; font-weight: 600; letter-spacing: .06em; }
.lb-table tr:hover td { background: rgba(224,179,65,.05); }

/* ---------- spinner ---------- */

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--ink-mute); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--ink-mute); }
.gold  { color: var(--gold-2); }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ============================================================
   Game mode — fullscreen 3D match screen.
   `.mode-game` is set on <body> while a match is mounted.
   ============================================================ */

body.mode-game { overflow: hidden; }
body.mode-game #toast-stack { z-index: 2000; }

.game-root { width: 100vw; height: 100vh; padding: 0; margin: 0; }

.game-stage {
  position: fixed; inset: 0;
  background: #050302;
  display: block;
}

.game-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.game-canvas canvas { display: block; width: 100%; height: 100%; }

.game-hud {
  position: absolute; inset: 0;
  pointer-events: none;
}
/* Only actually interactive HUD elements eat clicks. Cards/banners are visual
   only — clicks must fall through to the 3D canvas so dice are pickable
   wherever they land. */
.hud-exit, .hud-actions { pointer-events: auto; }
.hud-card, .hud-banners { pointer-events: none; }

.hud-exit {
  position: absolute; top: 16px; right: 18px;
  color: var(--ink-dim); font-size: 1.4rem; text-decoration: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.45); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.hud-exit:hover { color: var(--crimson-2); border-color: var(--crimson-2); }

.hud-card {
  position: absolute; top: 16px;
  background: linear-gradient(180deg, rgba(45,33,16,.92), rgba(15,10,5,.88));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 18px;
  box-shadow: 0 8px 22px rgba(0,0,0,.55);
  min-width: 200px;
  transition: border-color .25s, box-shadow .25s, transform .25s;
}
.hud-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(224,179,65,.45), 0 8px 22px rgba(0,0,0,.55);
  transform: translateY(-2px);
}
.hud-me { left: 18px; }
.hud-ai { right: 18px; text-align: right; padding-right: 70px; }
.hud-card .hud-name {
  font-family: 'Cinzel','Georgia',serif;
  color: var(--gold-2); font-size: 1rem; letter-spacing: .04em;
}
.hud-card .hud-score {
  font-family: 'Cinzel','Georgia',serif; font-size: 2.6rem;
  color: var(--ink); line-height: 1; margin-top: 4px;
}
.hud-card .hud-turn { color: var(--gold); font-weight: 700; margin-top: 4px; min-height: 18px; }
.hud-card .hud-turn.dim { color: transparent; }

.hud-portrait {
  width: 56px; height: 56px; border-radius: 50%;
  position: absolute; top: 10px; right: 10px;
  border: 2px solid var(--gold); object-fit: cover;
  background: var(--bg-2);
}

.hud-banners {
  position: absolute; top: 100px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
.hud-banner {
  font-family: 'Cinzel','Georgia',serif;
  font-size: 2.2rem; letter-spacing: .16em;
  padding: 10px 28px; border-radius: var(--r-md);
  animation: banner-in .25s ease-out;
  text-shadow: 0 2px 0 #000;
}
.hud-banner.hot {
  background: linear-gradient(180deg, #ff8a14, #a55114);
  color: #fff; box-shadow: 0 0 30px rgba(255,140,40,.7);
}
.hud-banner.farkle {
  background: linear-gradient(180deg, #5a0a0a, #1a0202);
  color: #ffd0d0; box-shadow: 0 0 30px rgba(220,40,40,.5);
}
.hud-banner.score {
  background: linear-gradient(180deg, #c8a04a, #5a4014);
  color: #1a1208; font-size: 1.8rem;
}
.hud-banner.fade { opacity: 0; transform: translateY(-10px); transition: .8s; }
@keyframes banner-in {
  from { opacity: 0; transform: scale(.6); }
  to   { opacity: 1; transform: scale(1); }
}

.hud-actions {
  position: absolute; bottom: 28px; left: 0; right: 0;
  display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 0 20px;
}
.hud-thinking {
  background: rgba(15,10,5,.88); border: 1px solid var(--line);
  padding: 14px 22px; border-radius: var(--r-md); color: var(--ink-dim);
  display: flex; align-items: center; gap: 10px;
}
.hud-hint {
  flex-basis: 100%; text-align: center;
  color: var(--ink-mute); font-size: .9rem;
  margin-top: 2px;
}

.btn-game {
  font-family: 'Cinzel','Georgia',serif; font-size: 1.15rem;
  letter-spacing: .04em;
  padding: 14px 30px; border-radius: 12px;
  border: 1px solid var(--line); cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, #3a2614, #1a1006);
  box-shadow: 0 6px 0 rgba(0,0,0,.6), 0 10px 24px rgba(0,0,0,.5);
  transition: transform .08s, box-shadow .12s, background .2s, color .15s, border-color .15s;
}
.btn-game:hover:not(:disabled) { color: var(--gold-2); border-color: var(--gold); transform: translateY(-1px); box-shadow: 0 7px 0 rgba(0,0,0,.6), 0 12px 28px rgba(0,0,0,.5); }
.btn-game:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.6), 0 6px 16px rgba(0,0,0,.5); }
.btn-game:disabled { opacity: .45; cursor: not-allowed; }
.btn-game.primary {
  background: linear-gradient(180deg, #a51f1f, #4a0808);
  color: #fff8e0; border-color: #5a0a0a;
}
.btn-game.primary:hover:not(:disabled) { background: linear-gradient(180deg, #d83b3b, #6a0a0a); border-color: var(--gold-2); }
.btn-game.gold {
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #2a1f08; border-color: #5a4014; font-weight: 700;
}
.btn-game.gold:hover:not(:disabled) { background: linear-gradient(180deg, #ffe488, #ffc833); }
.btn-game.ghost {
  background: transparent;
  box-shadow: none;
}

/* Endgame overlay */
.endscreen {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(0,0,0,.6), rgba(0,0,0,.92));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 50;
  animation: endscreen-in .5s ease-out;
}
@keyframes endscreen-in { from { opacity: 0; } to { opacity: 1; } }
.endscreen-title {
  font-family: 'Cinzel','Georgia',serif; font-size: 5rem; letter-spacing: .14em;
  text-shadow: 0 0 40px currentColor, 0 4px 0 #000;
  margin: 0;
}
.endscreen-title.win  { color: var(--gold-2); }
.endscreen-title.loss { color: var(--crimson-2); }
.endscreen-score { font-size: 2rem; color: var(--ink-dim); margin: 16px 0; }
.endscreen-coins { font-size: 1.6rem; color: var(--gold); margin-bottom: 24px; font-weight: 700; }
.endscreen-actions { display: flex; gap: 14px; margin-top: 10px; }

/* Mobile tuning */
@media (max-width: 720px) {
  .hud-card { min-width: 150px; padding: 10px 14px; }
  .hud-card .hud-score { font-size: 2rem; }
  .hud-portrait { width: 44px; height: 44px; }
  .hud-ai { padding-right: 56px; }
  .btn-game { font-size: 1rem; padding: 12px 22px; }
  .endscreen-title { font-size: 3rem; }
}
