/* Tomb of Anubis — self-contained slot UI (no external assets, NFR-03). */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #d4af37;
  --gold-bright: #ffd968;
  --sand: #c2a24b;
  --bg-deep: #0d0a14;
  --bg-panel: #171126;
  --bg-cell: #1d1530;
  --text: #efe6cf;
  --text-dim: #9a8f78;
  --danger: #e0564b;
  --ok: #6fce77;
}

html, body {
  height: 100%;
  background: radial-gradient(ellipse at 50% -20%, #2a1f45 0%, var(--bg-deep) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}

.hidden { display: none !important; }

.game {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 12px;
  gap: 6px;
}

/* ---------- Header ---------- */
.header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 3.4vw, 30px);
  letter-spacing: 3px;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(212, 175, 55, .55), 0 2px 0 #6b510f;
  white-space: nowrap;
}
.brand-of { font-size: .6em; color: var(--sand); letter-spacing: 1px; }
.header-stats { display: flex; gap: 14px; flex: 1; justify-content: center; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 72px; }
.stat-label { font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim); text-transform: uppercase; }
.stat-value { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.header-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--bg-panel); color: var(--text);
  border: 1px solid #37294f; border-radius: 8px;
  width: 36px; height: 36px; font-size: 16px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--gold); }

/* ---------- Free spins HUD ---------- */
.fs-hud { display: flex; gap: 10px; justify-content: center; }
.fs-chip {
  background: linear-gradient(180deg, #3d2c10, #241a08);
  border: 1px solid var(--gold); border-radius: 20px;
  padding: 4px 14px; font-size: 12px; letter-spacing: 1px; color: var(--sand);
}
.fs-chip b { color: var(--gold-bright); margin-left: 6px; font-size: 14px; }

/* ---------- Stage / reels ---------- */
.stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.reel-frame {
  position: relative;
  border: 3px solid #58421a;
  outline: 1px solid #2c210d;
  border-radius: 14px;
  background: linear-gradient(180deg, #241a3c 0%, #120d20 100%);
  box-shadow: 0 0 40px rgba(0,0,0,.7), inset 0 0 30px rgba(0,0,0,.6), 0 0 26px rgba(212,175,55,.12);
  overflow: hidden;
}
.reel-frame canvas { display: block; }
#lines-canvas { position: absolute; inset: 0; pointer-events: none; }

.win-plate {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  background: rgba(13, 10, 20, .85);
  border: 1px solid var(--gold); border-radius: 24px;
  padding: 6px 22px; font-size: 20px; font-weight: 800; color: var(--gold-bright);
  text-shadow: 0 0 12px rgba(212,175,55,.8);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ---------- Controls ---------- */
.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}
.bet-block { display: flex; align-items: center; gap: 8px; justify-self: start; }
.bet-display { display: flex; flex-direction: column; align-items: center; min-width: 84px; }
.bet-label { font-size: 9px; letter-spacing: 1.5px; color: var(--text-dim); }
#bet-value { font-size: 18px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.ctl-btn {
  background: var(--bg-panel); color: var(--text);
  border: 1px solid #37294f; border-radius: 10px;
  min-width: 40px; height: 40px; font-size: 18px; font-weight: 700; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.ctl-btn.wide { min-width: 66px; font-size: 12px; letter-spacing: 1px; }
.ctl-btn:hover:not(:disabled) { border-color: var(--gold); }
.ctl-btn.active { border-color: var(--gold); color: var(--gold-bright); box-shadow: 0 0 12px rgba(212,175,55,.35); }
.ctl-btn:disabled { opacity: .4; cursor: default; }

.spin-block { display: flex; align-items: center; gap: 12px; justify-self: center; }
.spin-btn {
  width: 84px; height: 84px; border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #f4d97b 0%, #c99b23 45%, #7a5c10 100%);
  color: #241a05; font-size: 17px; font-weight: 900; letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.55), 0 0 26px rgba(212,175,55,.35);
  transition: transform .08s, filter .15s;
}
.spin-btn:hover:not(:disabled) { filter: brightness(1.1); }
.spin-btn:active:not(:disabled) { transform: scale(.94); }
.spin-btn:disabled { filter: grayscale(.6) brightness(.7); cursor: default; }
.msg-block { justify-self: end; font-size: 12px; color: var(--text-dim); max-width: 26ch; text-align: right; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(8, 5, 14, .8); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.overlay-card {
  background: linear-gradient(180deg, #221741, #120d20);
  border: 1px solid #4a3a6b; border-radius: 16px;
  padding: 28px 34px; max-width: min(480px, 92vw);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  text-align: center;
}
.overlay-card.gold { border-color: var(--gold); box-shadow: 0 0 50px rgba(212,175,55,.25); }
.overlay-card.wide-card { max-width: min(640px, 94vw); max-height: 86dvh; overflow-y: auto; }
.overlay-title { font-family: Georgia, serif; font-size: 22px; letter-spacing: 2px; color: var(--gold-bright); }
.overlay-text { color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.btn {
  background: var(--bg-panel); color: var(--text);
  border: 1px solid #37294f; border-radius: 10px;
  padding: 10px 26px; font-size: 14px; font-weight: 700; letter-spacing: 1px; cursor: pointer;
}
.btn-gold {
  background: linear-gradient(180deg, #e8c65a, #a87f18);
  border-color: var(--gold); color: #241a05;
}
.btn:hover { filter: brightness(1.1); }
.btn-row { display: flex; gap: 12px; }

.fs-intro-count { font-size: 30px; font-weight: 900; color: var(--text); }
.fs-intro-symbol { font-size: 54px; filter: drop-shadow(0 0 14px rgba(212,175,55,.7)); }

/* ---------- Big win banner ---------- */
.bigwin {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: radial-gradient(ellipse at center, rgba(212,175,55,.20) 0%, rgba(8,5,14,.75) 70%);
  animation: bigwin-in .35s ease-out;
}
.bigwin-title {
  font-family: Georgia, serif; font-size: clamp(38px, 9vw, 84px); font-weight: 900; letter-spacing: 6px;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(212,175,55,.9), 0 4px 0 #6b510f;
  animation: bigwin-pulse 0.9s ease-in-out infinite alternate;
}
.bigwin-amount {
  font-size: clamp(26px, 6vw, 54px); font-weight: 900; color: #fff;
  text-shadow: 0 0 22px rgba(212,175,55,.9);
  font-variant-numeric: tabular-nums;
}
@keyframes bigwin-in { from { opacity: 0; transform: scale(1.15); } to { opacity: 1; transform: scale(1); } }
@keyframes bigwin-pulse { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ---------- Paytable ---------- */
.paytable-body { width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.paytable-row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #2b2145; padding-bottom: 8px; }
.paytable-sym { font-size: 30px; width: 46px; text-align: center; }
.paytable-pays { display: flex; gap: 14px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.paytable-pays b { color: var(--text); }
.paytable-note { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.paytable-lines { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.payline-mini { background: var(--bg-cell); border-radius: 6px; padding: 4px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; }
.payline-mini i { display: block; aspect-ratio: 1; border-radius: 2px; background: #2b2145; }
.payline-mini i.on { background: var(--gold); }

/* ---------- Debug panel ---------- */
.debug-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(380px, 94vw);
  background: #100b1d; border-left: 1px solid #37294f;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; overflow-y: auto;
  box-shadow: -12px 0 30px rgba(0,0,0,.6);
  font-size: 13px;
}
.debug-header { display: flex; justify-content: space-between; align-items: center; color: var(--gold-bright); font-weight: 700; }
.debug-section { display: flex; flex-direction: column; gap: 6px; }
.debug-label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim); }
.debug-select, .debug-btn {
  background: var(--bg-panel); color: var(--text);
  border: 1px solid #37294f; border-radius: 8px; padding: 8px 10px;
  font-size: 12px; text-align: left; cursor: pointer;
}
.debug-btn:hover { border-color: var(--gold); }
.debug-mini-btn {
  background: none; border: 1px solid #37294f; border-radius: 6px;
  color: var(--text-dim); font-size: 11px; cursor: pointer; padding: 2px 8px;
}
.debug-links a { color: var(--sand); }
.callback-log { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.log-entry { background: var(--bg-panel); border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.log-entry-head { display: flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.log-dir-out { color: #7db4ff; } .log-dir-in { color: #c58bff; }
.log-ok { color: var(--ok); } .log-err { color: var(--danger); }
.log-sig-bad { color: var(--danger); font-weight: 700; }
.log-json {
  display: none; white-space: pre-wrap; word-break: break-all;
  font-family: ui-monospace, Menlo, monospace; font-size: 10.5px;
  color: var(--text-dim); margin-top: 6px; border-top: 1px solid #2b2145; padding-top: 6px;
}
.log-entry.open .log-json { display: block; }

/* ---------- Toasts ---------- */
.toast-area {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 70; pointer-events: none;
  width: min(440px, 92vw);
}
.toast {
  background: rgba(23, 17, 38, .95); border: 1px solid #37294f; border-left: 4px solid var(--gold);
  border-radius: 8px; padding: 10px 14px; font-size: 13px;
  animation: toast-in .25s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Mobile (FR-45) ---------- */
@media (max-width: 720px), (max-height: 560px) {
  .game { padding: 4px 6px; gap: 4px; }
  .header { gap: 8px; }
  .header-stats { gap: 8px; }
  .stat { min-width: 58px; }
  .stat-value { font-size: 13px; }
  .controls { grid-template-columns: 1fr; justify-items: center; gap: 6px; }
  .bet-block, .msg-block { justify-self: center; }
  .msg-block { text-align: center; }
  .spin-btn { width: 68px; height: 68px; font-size: 14px; }
}
body.mobile .brand { font-size: 16px; }
