:root {
  --felt-0: #14513c;
  --felt-1: #0d3b2e;
  --felt-2: #0a2c22;
  --gold: #d9b45b;
  --gold-dim: #9c8244;
  --ink: #1c1c1c;
  --red: #c0392b;
  --cream: #f4ecd8;
  --panel: rgba(0, 0, 0, 0.28);
  --card-w: 78px;
  --card-h: 112px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--cream);
  background:
    radial-gradient(ellipse at 50% 12%, var(--felt-0) 0%, var(--felt-1) 42%, var(--felt-2) 100%);
  transition: background 0.6s ease;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 18px 28px;
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-areas:
    "hud       hud"
    "artifacts artifacts"
    "table     log"
    "controls  log";
  gap: 16px;
}
#artifacts-bar {
  grid-area: artifacts;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* ---------- HUD ---------- */
#hud {
  grid-area: hud;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
}
#strikes { letter-spacing: 0.12em; }
#strikes.has-strike { color: #ff8b7a; }
.hud-item { display: flex; flex-direction: column; gap: 2px; position: relative; }
.hud-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}
.hud-value { font-size: 20px; font-weight: bold; }
#casino-name { font-style: italic; }

/* ---------- Table ---------- */
#table {
  grid-area: table;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,255,255,0.05), transparent 70%),
    var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 430px;
  position: relative;
}

/* ---------- Outcome flourish ---------- */
#outcome-banner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 68px;
  font-weight: bold;
  letter-spacing: 0.12em;
  pointer-events: none;
  z-index: 6;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.65);
}
#outcome-banner.hidden { display: none; }
#outcome-banner.win { color: #8ee6a8; }
#outcome-banner.lose { color: #ff8b7a; }
#outcome-banner.push { color: var(--gold); }
#outcome-banner.show { animation: bannerPop 1.3s ease-out forwards; }
@keyframes bannerPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
  30%  { transform: translate(-50%, -50%) scale(1.0); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.06); }
}
.hand-zone { display: flex; flex-direction: column; gap: 8px; }
.hand-label {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--gold);
}
.hand-total {
  font-size: 22px;
  font-weight: bold;
  color: var(--cream);
  min-width: 34px;
  text-align: center;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 0 8px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.hand-zone { transition: opacity 0.2s; }
.hand-zone.leading .hand-total {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(217, 180, 91, 0.55);
  transform: scale(1.08);
}
.hand-zone.leading .hand-label { color: var(--cream); }
.hand-zone.leading .hand-label > span:first-child { text-shadow: 0 0 10px rgba(217, 180, 91, 0.5); }
.cards { display: flex; gap: 10px; min-height: var(--card-h); }

#shoe-zone {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 0;
}
.shoe {
  width: 52px; height: 74px;
  border-radius: 7px;
  background:
    repeating-linear-gradient(45deg, #6b2b2b 0 6px, #7d3333 6px 12px);
  border: 2px solid var(--gold-dim);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.35), inset 0 0 0 3px rgba(0,0,0,0.15);
}
#peek-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  align-items: center;
  min-height: 22px;
  color: var(--gold);
}
.pk-hand { display: flex; align-items: center; gap: 8px; }
.pk-hand-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); opacity: 0.85; min-width: 46px;
}
.pk-ghosts { display: flex; gap: 5px; }
.ghost-card {
  width: 30px; height: 42px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed var(--gold-dim);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cream);
  line-height: 1;
}
.ghost-card.red { color: #ff8b7a; }
.ghost-card .gc-rank { font-size: 14px; font-weight: bold; }
.ghost-card .gc-suit { font-size: 11px; }
.ghost-card.unknown { color: var(--gold-dim); border-style: dotted; }
.ghost-card .gc-q { font-size: 18px; font-weight: bold; }
.pk-total { font-size: 15px; font-weight: bold; color: var(--cream); }

/* ---------- Cards ---------- */
.card {
  width: var(--card-w);
  height: var(--card-h);
  background: linear-gradient(160deg, #ffffff, #f0ead8);
  border-radius: 8px;
  position: relative;
  color: var(--ink);
  box-shadow: 2px 3px 6px rgba(0,0,0,0.4);
  border: 1px solid #d8cdb0;
  animation: deal 0.28s ease-out;
}
.card.red { color: var(--red); }
.card .corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-weight: bold;
}
.card .corner.tl { top: 6px; left: 7px; }
.card .corner.br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.card .corner .rank { font-size: 17px; }
.card .corner .suit { font-size: 13px; }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  opacity: 0.92;
}
.card.dim { opacity: 0.55; filter: grayscale(0.3); }
.card.disguised { box-shadow: 0 0 0 2px #b98cff, 2px 3px 8px rgba(123, 79, 206, 0.5); }
.card .veil-badge {
  position: absolute;
  top: 4px; right: 5px;
  min-width: 16px; height: 16px;
  padding: 0 3px;
  background: #7a4fce;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.veil-choice { padding: 5px 10px; font-size: 13px; }
.veil-note { font-size: 12px; }
.veil-note.caught { color: #ff8b7a; }
.veil-note.ok { color: #8ee6a8; }

@keyframes deal {
  from { transform: translateY(-16px) rotate(-4deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------- Controls ---------- */
#controls {
  grid-area: controls;
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bet-row, .action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ctl-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  min-width: 58px;
}
.seat-buttons { display: flex; gap: 8px; }
.stake-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px;
}
.stake-set { padding: 7px 16px; font-size: 14px; min-width: 60px; }
.stake-add { padding: 5px 16px; font-size: 12px; min-width: 60px; opacity: 0.9; }

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--gold-dim);
  background: rgba(0,0,0,0.25);
  color: var(--cream);
  padding: 8px 14px;
  font-size: 14px;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { border-color: var(--gold); background: rgba(217,180,91,0.15); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.seat { display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.seat em { font-size: 11px; font-style: normal; color: var(--gold); opacity: 0.8; }
.seat.selected { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.seat.selected em { color: var(--ink); }
.stake-set.selected { background: var(--gold); color: var(--ink); border-color: var(--gold); }

.stake-display { font-size: 18px; font-weight: bold; margin-left: auto; }

.action-row { margin-top: 4px; }
button.primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  font-weight: bold;
  font-size: 16px;
  padding: 10px 26px;
  margin-left: auto;
}
button.ghost { border-style: dashed; }

/* ---------- Log ---------- */
#log-panel {
  grid-area: log;
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  max-height: 560px;
}
.log-title {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--gold-dim);
  padding-bottom: 6px;
}
#log {
  list-style: none;
  margin: 0; padding: 0;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
}
#log li { padding: 3px 0; border-bottom: 1px dotted rgba(217,180,91,0.2); }
#log li.win  { color: #8ee6a8; }
#log li.lose { color: #ff9b8b; }
#log li.push { color: #d9b45b; }

/* ---------- Overlay ---------- */
#overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
#overlay.hidden { display: none; }
.overlay-card {
  background: var(--felt-1);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 28px 34px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.overlay-card h2 { color: var(--gold); margin: 0 0 10px; font-size: 26px; }
.overlay-card p { font-size: 15px; line-height: 1.5; margin: 0 0 20px; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Tooltips ---------- */
[data-tip] { cursor: help; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  width: max-content;
  max-width: 250px;
  white-space: normal;
  background: #0c1f18;
  color: var(--cream);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  z-index: 30;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}
[data-tip].tip-right:hover::after { left: auto; right: 0; }

/* ---------- Start screen ---------- */
#start-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 30px 18px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% 0%, #14513c 0%, var(--felt-1) 45%, var(--felt-2) 100%);
}
.start-inner { max-width: 900px; text-align: center; }
.game-title {
  font-size: 52px;
  letter-spacing: 0.04em;
  margin: 0 0 6px;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
}
.start-sub {
  max-width: 620px;
  margin: 0 auto 26px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--cream);
  opacity: 0.9;
  font-style: italic;
}
.start-foot { margin-top: 20px; font-size: 12px; color: var(--gold); opacity: 0.6; }

.discipline-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.disc-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.disc-card:hover { transform: translateY(-3px); border-color: var(--gold); background: rgba(217,180,91,0.1); }
.disc-card .school {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); opacity: 0.8;
}
.disc-card .disc-name { font-size: 24px; color: var(--cream); }
.disc-card .cantrip-name { font-size: 14px; color: var(--gold); font-style: italic; }
.disc-card .disc-blurb { font-size: 13px; line-height: 1.45; color: var(--cream); opacity: 0.85; }
.disc-card .disc-cta {
  margin-top: 6px; align-self: flex-start;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 5px 12px; border: 1px solid var(--gold); border-radius: 6px; color: var(--gold);
}
.disc-card.locked { cursor: not-allowed; opacity: 0.5; filter: grayscale(0.4); }
.disc-card.locked:hover { transform: none; border-color: var(--gold-dim); background: var(--panel); }
.disc-card.locked .disc-cta { border-color: var(--gold-dim); color: var(--gold-dim); }

/* ---------- Shop (between cars) ---------- */
#shop-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 30px 18px; overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% 0%, var(--felt-0) 0%, var(--felt-1) 45%, var(--felt-2) 100%);
}
.shop-inner { max-width: 900px; width: 100%; text-align: center; }
.shop-title { font-size: 42px; color: var(--gold); margin: 0 0 6px; }
.shop-sub { font-size: 15px; color: var(--cream); opacity: 0.9; margin: 0 0 26px; }
.shop-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; text-align: left; }
.shop-col-title {
  font-size: 15px; color: var(--gold); margin: 0 0 10px;
  font-weight: normal; letter-spacing: 0.06em;
}
.shop-col-note { color: var(--cream); opacity: 0.6; font-size: 12px; font-style: italic; }
.shop-cards { display: flex; flex-direction: column; gap: 10px; }
.shop-card {
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 5px;
}
.shop-card-name { font-size: 16px; color: var(--cream); }
.shop-card-desc { font-size: 13px; color: var(--cream); opacity: 0.82; line-height: 1.4; }
.shop-card button { align-self: flex-start; margin-top: 4px; }
#board-btn { margin-top: 24px; }
.veil-num { min-width: 30px; padding: 5px 9px; }
@media (max-width: 720px) { .shop-cols { grid-template-columns: 1fr; } }

/* ---------- Mid-coup prompt ---------- */
#coup-prompt {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: rgba(217,180,91,0.1);
  border: 1px dashed var(--gold);
  border-radius: 10px;
}
#coup-prompt .prompt-text { font-size: 14px; color: var(--cream); margin-right: auto; }
#coup-prompt .prompt-text b { color: var(--gold); }

/* ---------- Artifacts / relics ---------- */
.owned-lead {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); opacity: 0.7;
}
.relic-chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  background: rgba(0, 0, 0, 0.28);
  color: var(--cream);
  cursor: help;
}
.relic-chip.rarity-rare { border-color: #6aa9ff; color: #cfe2ff; }
.relic-chip.rarity-legendary { border-color: #d9b45b; color: #ffe9a8; background: rgba(217, 180, 91, 0.14); }

#artifact-section { text-align: left; margin-bottom: 18px; }
.artifact-offers { flex-direction: row !important; flex-wrap: wrap; }
.artifact-offers .shop-card { flex: 1 1 240px; }
.artifact-card.rarity-rare { border-color: #6aa9ff; }
.artifact-card.rarity-legendary { border-color: #d9b45b; box-shadow: 0 0 0 1px rgba(217, 180, 91, 0.4); }
.rarity-tag {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  opacity: 0.75; margin-left: 6px;
}
.artifact-card.rarity-rare .rarity-tag { color: #9cc3ff; }
.artifact-card.rarity-legendary .rarity-tag { color: #ffe9a8; }
.owned-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 18px; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "hud" "artifacts" "table" "controls" "log"; }
  .stake-display { margin-left: 0; }
  .discipline-grid { grid-template-columns: 1fr; }
  .game-title { font-size: 40px; }
}
