/* ==========================================================
   The Game Bar — western saloon theme
   ========================================================== */

:root {
  --wood-900: #1f130b;
  --wood-800: #2e1c11;
  --wood-700: #3d2616;
  --wood-600: #553520;
  --wood-500: #6e4529;

  --parchment: #f3e6c9;
  --parchment-2: #e8d6af;
  --parchment-3: #d4bd8f;
  --ink: #2b1d12;
  --ink-soft: #6b5540;

  --sage: #7a9a55;
  --rust: #b8442e;
  --gold: #d9a23a;
  --sky: #4f7aa8;
  --ember: #d0692f;
  --turquoise: #3a8f89;
  --brass: #c9a45c;

  --font-sign: "Rye", Georgia, serif;
  --font-type: "Special Elite", "Courier New", monospace;
  --font-body: "Zilla Slab", Georgia, serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--parchment);
  background-color: var(--wood-700);
  /* Lamp glow, floor shadow, plank seams, grain, plank tones */
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(255, 190, 110, 0.16), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.55), transparent 60%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.5) 0 3px, rgba(255, 255, 255, 0.05) 3px 4px, transparent 4px 150px),
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(0, 0, 0, 0.07) 9px 10px, transparent 10px 21px, rgba(255, 255, 255, 0.03) 21px 22px, transparent 22px 31px),
    repeating-linear-gradient(90deg, #4b2e1b 0 150px, #42281a 150px 300px, #54341f 300px 450px, #3f2616 450px 600px);
  background-attachment: fixed;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Menu ---------- */

.saloon-header {
  text-align: center;
  padding: 56px 16px 4px;
}

.sign {
  position: relative;
  display: inline-block;
  max-width: 100%;
  padding: 16px clamp(20px, 6vw, 44px) 14px;
  border: 3px solid #1f120a;
  border-radius: 10px;
  background:
    radial-gradient(circle at 12px 12px, var(--brass) 0 3px, transparent 4px),
    radial-gradient(circle at calc(100% - 12px) 12px, var(--brass) 0 3px, transparent 4px),
    radial-gradient(circle at 12px calc(100% - 12px), var(--brass) 0 3px, transparent 4px),
    radial-gradient(circle at calc(100% - 12px) calc(100% - 12px), var(--brass) 0 3px, transparent 4px),
    repeating-linear-gradient(180deg, transparent 0 30px, rgba(0, 0, 0, 0.35) 30px 32px),
    repeating-linear-gradient(90deg, transparent 0 13px, rgba(0, 0, 0, 0.06) 13px 14px),
    linear-gradient(180deg, #6e4529, #4f311c);
  box-shadow:
    inset 0 0 0 2px rgba(201, 164, 92, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 16px 34px rgba(0, 0, 0, 0.55);
  transform: rotate(-1.2deg);
}

/* Ropes the sign hangs from */
.sign::before,
.sign::after {
  content: "";
  position: absolute;
  top: -58px;
  width: 4px;
  height: 58px;
  background: repeating-linear-gradient(180deg, #b89a64 0 5px, #8a7045 5px 8px);
  border-radius: 2px;
}

.sign::before { left: 18%; }
.sign::after { right: 18%; }

.sign h1 {
  margin: 2px 0;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: clamp(2.1rem, 9vw, 4.2rem);
  line-height: 1.1;
  color: var(--parchment);
  text-shadow: 0 3px 0 #1a0f08, 0 0 22px rgba(217, 162, 58, 0.35);
}

.sign-small {
  margin: 0;
  font-family: var(--font-type);
  font-size: clamp(0.65rem, 2.6vw, 0.8rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--brass);
}

.tagline {
  margin: 22px 0 0;
  font-family: var(--font-type);
  font-size: clamp(0.9rem, 3.5vw, 1.05rem);
  color: var(--parchment-3);
}

.counter-panel {
  max-width: 980px;
  margin: 26px auto 24px;
  padding: 18px;
  border-radius: 14px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.35), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(120, 80, 30, 0.12), transparent 55%),
    linear-gradient(180deg, #eadbb9, #dcc699);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    inset 0 -6px 16px rgba(120, 80, 30, 0.18),
    0 18px 40px rgba(0, 0, 0, 0.5);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px 14px;
  border: 1px solid rgba(80, 50, 20, 0.25);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  background: linear-gradient(180deg, #fbf3e0, #efe0bf);
  box-shadow: 0 2px 0 rgba(60, 35, 15, 0.25), 0 6px 14px rgba(60, 35, 15, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow: 0 4px 0 rgba(60, 35, 15, 0.25), 0 12px 22px rgba(60, 35, 15, 0.2);
}

.game-card:active {
  transform: translateY(0);
}

.card-kicker {
  font-family: var(--font-type);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.card-title {
  font-weight: 700;
  font-size: 1.2rem;
}

.card-blurb {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-soft);
}

.card-roles {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(80, 50, 20, 0.25);
  font-family: var(--font-type);
  font-size: 0.78rem;
  color: var(--ink);
}

.panel-rule {
  margin: 18px 0 10px;
  border-top: 1px dashed rgba(80, 50, 20, 0.35);
}

.panel-foot {
  margin: 0;
  text-align: center;
  font-family: var(--font-type);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.site-footer {
  padding: 0 16px 28px;
  text-align: center;
  font-family: var(--font-type);
  font-size: 0.8rem;
  color: var(--parchment-3);
  opacity: 0.75;
}

@media (max-width: 1012px) {
  .counter-panel {
    margin-left: 16px;
    margin-right: 16px;
  }
}

@media (max-width: 440px) {
  .counter-panel { padding: 12px; }
  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .card-blurb { font-size: 0.82rem; }
  .card-roles { font-size: 0.7rem; }
}

/* ---------- Shared bits ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 16px 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

#mute-btn {
  min-width: 2.6em;
  text-align: center;
}

.back-link,
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid rgba(60, 35, 15, 0.35);
  border-radius: 6px;
  font-family: var(--font-type);
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--ink);
  background: linear-gradient(180deg, var(--parchment), var(--parchment-2));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  white-space: nowrap;
}

.back-link:hover,
.btn:hover {
  background: var(--parchment);
}

.btn.primary {
  color: var(--parchment);
  background: linear-gradient(180deg, var(--rust), #8a3020);
}

.kicker {
  margin: 0;
  font-family: var(--font-type);
  font-size: 0.78rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
}

.game-heading {
  margin: 4px 0 14px;
  text-align: center;
}

.game-heading h1 {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: clamp(1.9rem, 7vw, 3rem);
  line-height: 1.15;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}

/* ---------- Seat picker ---------- */

.setup {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 32px;
  text-align: center;
}

.setup-sub {
  margin: 4px 0 0;
  font-family: var(--font-type);
  color: var(--parchment-3);
}

.howto {
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 12px 16px 12px 34px;
  border-radius: 10px;
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink);
  background: linear-gradient(180deg, #fbf3e0, #e9d7b0);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.howto li + li {
  margin-top: 4px;
}

.seats {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 12px;
  text-align: left;
}

.vs {
  align-self: center;
  text-align: center;
  font-family: var(--font-sign);
  font-size: 1.6rem;
  color: var(--brass);
}

.seat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
  border-top: 4px solid var(--accent);
  border-radius: 10px;
  color: var(--ink);
  background: linear-gradient(180deg, #fbf3e0, #e9d7b0);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 10px 24px rgba(0, 0, 0, 0.3);
}

.seat-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seat-card-emoji {
  font-size: 2rem;
  line-height: 1;
}

.seat-card h2 {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: 1.5rem;
}

.seat-goal {
  margin: 0;
  flex: 1;
  font-size: 0.98rem;
  line-height: 1.4;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(60, 35, 15, 0.45);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  padding: 9px 8px;
  border: none;
  font-family: var(--font-type);
  font-size: 0.92rem;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.seg button + button {
  border-left: 1px solid rgba(60, 35, 15, 0.45);
}

.seg button[aria-pressed="true"] {
  color: var(--parchment);
  background: var(--wood-500);
}

.seat-who {
  margin: 0;
  font-family: var(--font-type);
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.seat-keys {
  margin: 0;
  font-family: var(--font-type);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.deal-btn {
  display: inline-block;
  margin: 22px 0 10px;
  padding: 12px 34px;
  border-radius: 10px;
  font-family: var(--font-sign);
  font-size: 1.4rem;
  text-decoration: none;
  color: var(--parchment);
  background: linear-gradient(180deg, var(--rust), #8a3020);
  box-shadow: 0 4px 0 #5a1f14, 0 12px 24px rgba(0, 0, 0, 0.4);
}

.deal-btn:hover {
  filter: brightness(1.08);
}

.deal-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #5a1f14;
}

.setup-note {
  margin: 0;
  font-family: var(--font-type);
  font-size: 0.85rem;
  color: var(--parchment-3);
}

@media (max-width: 640px) {
  .seats {
    grid-template-columns: 1fr;
  }
}

/* ---------- The table ---------- */

.play-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  text-align: center;
}

.play-title {
  font-family: var(--font-sign);
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  line-height: 1.1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.table {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 28px;
  /* Vertical space taken by everything around the game screen */
  --reserve: 290px;
}

.seat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 640px);
  padding: 6px 12px;
  border-left: 4px solid var(--seat);
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--parchment), var(--parchment-2));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.seat-emoji {
  font-size: 1.4rem;
  line-height: 1;
}

.seat-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.seat .seat-who {
  flex: 1;
}

.seat-pips {
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  color: var(--accent);
}

/* Wooden frame around the canvas. Width is capped so the whole game fits on screen. */
.screen {
  position: relative;
  width: min(var(--w, 480px), 100%, calc(max(240px, 100dvh - var(--reserve)) * var(--aspect, 1)));
  padding: 10px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--wood-500), var(--wood-600) 60%, var(--wood-800));
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 16px 40px rgba(0, 0, 0, 0.55);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.screen.aims {
  cursor: crosshair;
}

.screen canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.overlay {
  position: absolute;
  inset: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  border-radius: 6px;
  text-align: center;
  background: rgba(28, 17, 10, 0.8);
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 400;
  font-size: clamp(1.3rem, 5.5vw, 2.2rem);
  color: var(--parchment);
}

.overlay p {
  margin: 0;
  font-family: var(--font-type);
  font-size: clamp(0.82rem, 3.2vw, 1rem);
  line-height: 1.6;
  white-space: pre-line;
  color: var(--parchment-2);
}

.overlay-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.overlay-buttons:empty {
  display: none;
}

.status {
  margin: 0;
  font-family: var(--font-type);
  font-size: 0.9rem;
  text-align: center;
  color: var(--parchment-2);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 640px;
  margin: 2px 0 0;
  text-align: center;
  font-family: var(--font-type);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--parchment-3);
}

/* ---------- On-screen touch pads ---------- */

.touch-pad {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 480px);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* The far player's pad faces them, like sitting across a cocktail table */
.touch-pad.flipped {
  transform: rotate(180deg);
}

.pad-label {
  font-family: var(--font-type);
  font-size: 0.75rem;
  color: var(--parchment-3);
}

.pad-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pad-group {
  display: flex;
  gap: 10px;
}

.pad-btn {
  width: 60px;
  height: 60px;
  border: 1px solid rgba(60, 35, 15, 0.5);
  border-radius: 14px;
  font-size: 1.4rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--parchment), var(--parchment-3));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.pad-btn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

.pad-btn.wide {
  width: 88px;
  font-family: var(--font-sign);
  font-size: 1rem;
  color: var(--parchment);
  background: linear-gradient(180deg, var(--rust), #8a3020);
}

.pad-btn.wide.alt {
  background: linear-gradient(180deg, var(--wood-500), var(--wood-700));
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 5px;
}

.dpad .pad-btn { width: 54px; height: 54px; }
.dpad [data-dir="up"] { grid-area: 1 / 2; }
.dpad [data-dir="left"] { grid-area: 2 / 1; }
.dpad [data-dir="right"] { grid-area: 2 / 3; }
.dpad [data-dir="down"] { grid-area: 3 / 2; }

@media (hover: none) and (pointer: coarse) {
  .touch-pad { display: flex; }
  .table.has-pad { --reserve: 440px; }
  .table.two-pads { --reserve: 640px; }
  .table.two-pads .dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
  }
  .table.two-pads .dpad .pad-btn,
  .table.two-pads .pad-btn { width: 44px; height: 44px; }
  .table.two-pads .pad-btn.wide { width: 76px; }
}

@media (max-width: 480px) {
  .topbar { padding: 10px 12px 0; }
  .back-link { padding: 6px 10px; font-size: 0.8rem; }
  .table { padding: 8px 12px 20px; gap: 8px; --reserve: 260px; }
  .screen { padding: 7px; }
  .overlay { inset: 7px; padding: 12px; }
  .seat { padding: 4px 10px; gap: 8px; }
  .seat-name { font-size: 0.95rem; }
}

/* One-player games: a single seat card, centred */
.seats.solo {
  grid-template-columns: minmax(0, 420px);
  justify-content: center;
}

.level-select {
  font: inherit;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--ink-soft);
  background: var(--parchment);
  color: var(--ink);
}

.cheats {
  max-width: 560px;
  margin: 8px auto 0;
  text-align: left;
  font-family: var(--font-type);
  font-size: 0.9rem;
  color: var(--parchment-2);
}

.cheats summary {
  cursor: pointer;
  text-align: center;
}

.cheats code {
  color: var(--gold);
  font-weight: bold;
}
