/* ============================================================
   Hawk's Nest Casino: shared look
   Colors live in the variables below so they're easy to tweak.
   ============================================================ */
:root {
  --felt-light: #1c7a47;
  --felt: #0f5132;
  --felt-dark: #0b3d24;
  --felt-deepest: #052115;
  --gold: #d4af37;
  --gold-light: #f3d77a;
  --gold-dark: #9c7a1c;
  --ink: #f4efe1;
  --ink-soft: #c9d8cd;
  --red: #c0392b;
  --win: #7ee2a0;
  --loss: #ff8a7a;
  --panel: rgba(3, 25, 15, 0.55);
  --panel-border: rgba(212, 175, 55, 0.35);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--felt-dark);
  /* Felt: a soft spotlight plus a very fine woven texture */
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.015) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.04) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 0%, var(--felt-light) 0%, var(--felt) 35%, var(--felt-dark) 70%, var(--felt-deepest) 100%);
  background-attachment: fixed;
}

a { color: var(--gold-light); }

[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(3, 20, 12, 0.95), rgba(3, 20, 12, 0.8));
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--gold-light);
  min-width: 0;
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--gold);
  font-size: 18px;
  color: var(--gold-light);
  background: radial-gradient(circle at 30% 30%, #1a5e3a, #062a18);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.balance {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: rgba(0, 0, 0, 0.35);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
.balance-label {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* A casino chip drawn with CSS */
.chip-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--gold-light) 0 28%, var(--gold-dark) 29% 36%, transparent 37%),
    repeating-conic-gradient(var(--red) 0 30deg, #fff 30deg 45deg);
  box-shadow: 0 0 0 2px var(--gold-dark), 0 2px 4px rgba(0,0,0,0.5);
}

#chip-count { display: inline-block; }
.flash-up { animation: flashUp 0.7s ease; }
.flash-down { animation: flashDown 0.7s ease; }
@keyframes flashUp {
  0% { color: var(--win); transform: scale(1.18); }
  100% { color: inherit; transform: scale(1); }
}
@keyframes flashDown {
  0% { color: var(--loss); transform: scale(0.9); }
  100% { color: inherit; transform: scale(1); }
}

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

h1, h2 { font-family: var(--font-display); }

.lobby-head { text-align: center; margin-bottom: 24px; }
.lobby-head h1 {
  margin: 0 0 6px;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  color: var(--gold-light);
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.sub { margin: 0; color: var(--ink-soft); }

.broke-note {
  margin: 0 auto 20px;
  max-width: 560px;
  padding: 12px 16px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--loss);
  background: rgba(120, 20, 10, 0.35);
}

/* ---------- Game cards ---------- */
.games {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 18px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.25)), var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 14px 34px rgba(0,0,0,0.55), 0 0 0 1px var(--gold);
  outline: none;
}
.game-card h2 {
  margin: 14px 0 6px;
  font-size: 1.5rem;
  color: var(--gold-light);
}
.game-card p {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.4;
}

.play-pill {
  margin-top: auto;
  padding: 8px 26px;
  border-radius: 999px;
  font-weight: 700;
  color: #2a1e00;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  box-shadow: 0 3px 0 var(--gold-dark);
}

/* Little pictures on each card, drawn with CSS */
.game-art {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 96px;
}

.mini-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 80px;
  border-radius: 7px;
  background: #fbf8f0;
  color: #111;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.mini-card i { font-style: normal; display: block; font-size: 1.2rem; }
.mini-card.red { color: var(--red); }
.art-blackjack .mini-card:first-child { transform: rotate(-8deg) translateX(6px); }
.art-blackjack .mini-card:last-child { transform: rotate(8deg) translateX(-6px); }

.art-slots span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 64px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ddd 0%, #fff 30%, #fff 70%, #ccc 100%);
  border: 2px solid var(--gold);
  color: var(--red);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2rem;
}

.wheel {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  background:
    radial-gradient(circle, var(--gold-light) 0 9%, #3b2a10 10% 34%, transparent 35%),
    conic-gradient(#0a8f3c 0 9.73deg, transparent 0),
    repeating-conic-gradient(#b8231a 0 9.73deg, #141414 9.73deg 19.46deg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  animation: spinSlow 18s linear infinite;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }

/* ---------- Stats ---------- */
.stats {
  margin-top: 28px;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
}
.stats h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: var(--gold-light);
}
.stats dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0;
}
.stat {
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  text-align: center;
}
.stat dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.stat dd {
  margin: 6px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat dd.up { color: var(--win); }
.stat dd.down { color: var(--loss); }

.lobby-actions {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

/* ---------- Buttons ---------- */
.btn {
  min-height: 44px; /* comfortable tap size on phones */
  padding: 10px 20px;
  border-radius: 999px;
  font: 600 1rem var(--font-body);
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }

.btn-gold {
  border: none;
  color: #2a1e00;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  box-shadow: 0 3px 0 var(--gold-dark);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.08); }

.btn-outline {
  border: 1px solid var(--gold);
  color: var(--gold-light);
  background: rgba(0, 0, 0, 0.25);
}
.btn-outline:hover:not(:disabled) { background: rgba(212, 175, 55, 0.12); }

/* ---------- Game screen ---------- */
.back-link {
  display: inline-block;
  margin-bottom: 10px;
  text-decoration: none;
  font-weight: 600;
}
.back-link:hover { text-decoration: underline; }

#game-title {
  margin: 0 0 16px;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  color: var(--gold-light);
}

.table-felt {
  padding: 28px 20px;
  border-radius: 28px;
  border: 6px solid #5a3a1a; /* wooden rail */
  box-shadow: inset 0 0 0 2px var(--gold-dark), inset 0 0 60px rgba(0,0,0,0.5), var(--shadow);
  background: radial-gradient(ellipse at center, var(--felt-light), var(--felt) 60%, var(--felt-dark));
  text-align: center;
}
.coming {
  margin: 10px 0 24px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--gold-light);
}

/* ---------- Dialog ---------- */
.dialog {
  width: min(92vw, 400px);
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--gold);
  color: var(--ink);
  background: linear-gradient(180deg, #0f4a2c, #072b19);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog h2 { margin: 0 0 8px; color: var(--gold-light); }
.dialog p { margin: 0 0 18px; color: var(--ink-soft); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-top: 1px solid rgba(212, 175, 55, 0.2);
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  main { padding-top: 20px; }
  .games { grid-template-columns: 1fr; gap: 14px; }
  .game-card {
    display: grid;
    grid-template-columns: 96px 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 14px;
    align-items: center;
    text-align: left;
    padding: 14px;
  }
  .game-art { grid-row: 1 / span 3; height: 90px; transform: scale(0.8); }
  .art-slots { gap: 4px; }
  .art-slots span { width: 34px; height: 50px; font-size: 1.5rem; }
  .game-card h2 { margin: 0; font-size: 1.3rem; }
  .game-card p { margin: 4px 0 10px; font-size: 0.9rem; }
  .play-pill { justify-self: start; padding: 6px 20px; font-size: 0.9rem; }
  .stats dl { gap: 8px; }
  .stat { padding: 10px 6px; }
  .stat dd { font-size: 1.2rem; }
}

@media (max-width: 420px) {
  .brand-name { font-size: 1.05rem; }
  .balance-label { display: none; }
  .stat dt { font-size: 0.68rem; letter-spacing: 0.03em; }
}

/* Respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   Game screens (shared)
   ============================================================ */
.game-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}
.game-head h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  color: var(--gold-light);
}
.game-head .back-link { margin: 0; }

.table-rules {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--gold-light);
  opacity: 0.85;
}
.table-note {
  margin: 14px auto 0;
  max-width: 640px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

kbd {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid currentColor;
  font: 600 0.7rem var(--font-body);
  opacity: 0.6;
  vertical-align: middle;
}
@media (hover: none) { kbd { display: none; } }

/* ---------- Playing cards ---------- */
.cards {
  --card-w: 76px;
  --card-h: 108px;
  display: flex;
  justify-content: center;
  min-height: var(--card-h);
  perspective: 800px;
}
.card {
  position: relative;
  flex: none;
  width: var(--card-w);
  height: var(--card-h);
}
.card + .card { margin-left: calc(var(--card-w) * -0.42); }
.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}
.card.down .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
}
.card-front {
  background: linear-gradient(160deg, #ffffff, #f3eee0);
  color: #151515;
  font-family: var(--font-display);
  font-weight: 700;
}
.card.red .card-front { color: #b8231a; }
.corner {
  position: absolute;
  font-size: calc(var(--card-w) * 0.22);
  line-height: 1;
  text-align: center;
}
.corner.tl { top: 6px; left: 6px; }
.corner.br { bottom: 6px; right: 6px; transform: rotate(180deg); }
.pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--card-w) * 0.5);
}
.card-back {
  transform: rotateY(180deg);
  border: 4px solid #fbf8f0;
  background:
    repeating-linear-gradient(45deg, rgba(212,175,55,0.35) 0 3px, transparent 3px 9px),
    repeating-linear-gradient(-45deg, rgba(212,175,55,0.35) 0 3px, transparent 3px 9px),
    linear-gradient(160deg, #7a1d16, #4a0f0b);
}
.card.dealing { animation: dealIn 0.38s cubic-bezier(.2,.8,.3,1) both; }
@keyframes dealIn {
  from { transform: translate(38vw, -32vh) rotate(-25deg) scale(0.7); opacity: 0; }
  60% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

/* ---------- Blackjack table ---------- */
.bj-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 420px;
  padding: 18px 12px 22px;
  border-radius: 28px 28px 50% 50% / 28px 28px 70px 70px;
}
.bj-label, .bj-hand-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.bj-hand-info { margin: 8px 0 0; text-transform: none; letter-spacing: 0; }
.total {
  min-width: 2.2em;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}
.total:empty { display: none; }

.bj-message {
  min-height: 1.6em;
  margin: 14px 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.bj-message.good { color: var(--win); }
.bj-message.bad { color: var(--loss); }

.bj-hands {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: 100%;
}
.bj-hand {
  position: relative;
  padding: 10px 10px 8px;
  border-radius: 14px;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.bj-hand.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
}
.hand-bet { font-size: 0.8rem; }

.result-badge {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.result-badge.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.result-badge.win, .result-badge.blackjack { background: var(--gold); color: #2a1e00; box-shadow: 0 0 18px rgba(243, 215, 122, 0.7); }
.result-badge.push { background: #e8e2cf; color: #222; }
.result-badge.lose, .result-badge.bust { background: #7a1d16; color: #fff; }

/* ---------- Controls under the table ---------- */
.bj-controls { margin-top: 16px; }
.bet-controls, .play-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.bet-display {
  min-width: 110px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.35);
  text-align: center;
  color: var(--ink-soft);
}
.bet-display strong { margin-left: 6px; color: var(--ink); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.chip-row { display: flex; gap: 10px; }
.bet-buttons { display: flex; gap: 10px; }
.play-controls .btn { min-width: 110px; }

/* Casino chips as buttons */
.chip {
  --chip: #1f5fbf;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  font: 700 0.9rem var(--font-body);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  background:
    radial-gradient(circle, var(--chip) 0 52%, #fff 53% 56%, transparent 57%),
    repeating-conic-gradient(var(--chip) 0 30deg, #f4f4f4 30deg 45deg);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35), 0 4px 0 rgba(0,0,0,0.45);
  transition: transform 0.12s ease, filter 0.15s ease;
}
.chip:hover:not(:disabled) { transform: translateY(-3px); }
.chip:active:not(:disabled) { transform: translateY(1px); }
.chip:disabled { filter: grayscale(0.8) brightness(0.6); cursor: not-allowed; }
.chip:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 3px; }
.chip-10 { --chip: #1f5fbf; }
.chip-50 { --chip: #c0392b; }
.chip-100 { --chip: #1b1b1b; }
.chip-500 { --chip: #6c2bb3; }

@media (max-width: 720px) {
  .cards { --card-w: 60px; --card-h: 86px; }
  .bj-table { min-height: 360px; border-radius: 22px 22px 40% 40% / 22px 22px 50px 50px; }
  .bj-hands.split .cards { --card-w: 50px; --card-h: 72px; }
  .bj-hands { gap: 8px; }
  .play-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .play-controls .btn { min-width: 0; }
  .bet-controls { gap: 12px; }
  .chip { width: 50px; height: 50px; }
}

/* ---------- Hand history ---------- */
.lobby-actions { gap: 12px; flex-wrap: wrap; }
.dialog-wide { width: min(96vw, 860px); }
.dialog-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--ink-soft);
  font-size: 1rem;
  cursor: pointer;
}
.icon-btn:hover { color: var(--gold-light); border-color: var(--gold); }
.history-summary { margin: 4px 0 12px; }
.history-scroll {
  max-height: min(60vh, 520px);
  overflow: auto;
  margin-bottom: 16px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
}
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history-table th, .history-table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(212,175,55,0.12); }
.history-table th {
  position: sticky; top: 0;
  background: #0a3520;
  color: var(--gold-light);
  font-weight: 600;
  white-space: nowrap;
}
.history-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-table .up { color: var(--win); }
.history-table .down { color: var(--loss); }
.history-table .muted { color: var(--ink-soft); opacity: 0.8; }
.history-table .cards-cell { min-width: 180px; line-height: 1.45; }
.history-table tr.bad td { background: rgba(160, 30, 20, 0.35); }
.history-table tr.note td { color: var(--gold-light); font-style: italic; }
@media (max-width: 720px) {
  .history-table th:nth-child(1), .history-table td:nth-child(1),
  .history-table th:nth-child(3), .history-table td:nth-child(3) { display: none; }
  .history-table th, .history-table td { padding: 6px; }
}
