/* ============================================================
   Skip-Bo — game board layout
   Complements style.css (card rendering). Cards are scaled down
   to ~0.58× gallery size via the --card-scale variable.
   ============================================================ */

:root {
  --scale: 0.62;
  --game-card-w: calc(160px * var(--scale));
  --game-card-h: calc(224px * var(--scale));

  --felt-a: #1a6a3c;
  --felt-b: #0e3f22;
  --felt-edge: #082a15;
  --gold: #e8c060;
  --slot-bg: rgba(0,0,0,0.22);
  --slot-border: rgba(255,255,255,0.14);
  --slot-border-hot: rgba(255,215,100,0.85);
  --slot-border-bad: rgba(255,90,80,0.7);
}

html, body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, #1e7543 0%, var(--felt-b) 55%, var(--felt-edge) 100%);
  overflow-x: hidden;
}

.page-game {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f4f7f5;
  min-height: 100vh;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.view.hidden { display: none; }

/* ============================================================
   Landing view
   ============================================================ */

.view-landing {
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.landing-card {
  width: 100%;
  max-width: 460px;
  background: linear-gradient(180deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.45) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  text-align: center;
}
.landing-logo {
  margin: 0 0 4px;
  display: flex;
  flex-direction: column;
  line-height: 0.9;
}
.landing-logo-line {
  font-family: "Archivo Black", sans-serif;
  font-style: italic;
  font-size: 68px;
  color: #EC5A2C;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.25),
    0 4px 14px rgba(0,0,0,0.4);
}
.landing-tag {
  margin: 10px 0 22px;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
}

.landing-name {
  margin-bottom: 18px;
  text-align: left;
}
.landing-name label {
  display: block;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 700;
}
.landing-name input,
.landing-join input,
.lobby-link-row input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.landing-name input:focus,
.landing-join input:focus,
.lobby-link-row input:focus {
  border-color: var(--gold);
  background: rgba(0,0,0,0.45);
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn.btn-big {
  padding: 13px 18px;
  font-size: 14px;
  border-radius: 12px;
}

.landing-join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.landing-join input {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 700;
  text-align: center;
}

.landing-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 4px 0;
}
.landing-or::before, .landing-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}

.landing-error, .lobby-error {
  margin: 14px 0 0;
  min-height: 1em;
  color: #ff8a78;
  font-size: 13px;
}

.landing-foot {
  margin-top: 22px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}
.landing-foot a { color: var(--gold); text-decoration: none; }
.landing-foot a:hover { text-decoration: underline; }
.landing-foot-sep { margin: 0 8px; color: rgba(255,255,255,0.25); }

.lobby-foot {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
}
.lobby-foot a {
  color: var(--gold);
  text-decoration: none;
}
.lobby-foot a:hover { text-decoration: underline; }

/* ============================================================
   Lobby view
   ============================================================ */

.view-lobby {
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  gap: 8px;
}

/* Shared brand strip — appears above the lobby card so the game name is
   visible on every screen, not just the landing hero. */
.brand-header {
  text-align: center;
  margin-bottom: 18px;
}
.brand-link { text-decoration: none; display: inline-block; }
.brand-logo {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-style: italic;
  font-size: 44px;
  letter-spacing: 2px;
  color: #EC5A2C;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.25),
    0 4px 14px rgba(0,0,0,0.45);
  line-height: 0.9;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.brand-link:active .brand-logo { transform: scale(0.96); }
.lobby-card {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.45) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}
.lobby-title {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-style: italic;
  font-size: 24px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
}
.lobby-code {
  color: var(--gold);
  margin-left: 6px;
  letter-spacing: 6px;
  font-size: 28px;
}
.lobby-sub {
  margin: 4px 0 16px;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
}

.lobby-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 22px;
}

.lobby-heading {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}
.lobby-players {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lobby-players li {
  padding: 10px 14px;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.lobby-player-name { flex: 1; font-weight: 700; }

.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
}
.tag-host { background: rgba(236,90,44,0.25); color: #f8a383; border: 1px solid rgba(236,90,44,0.4); }
.tag-you  { background: rgba(232,192,96,0.2); color: var(--gold); border: 1px solid rgba(232,192,96,0.4); }
.tag-off  { background: rgba(255,90,80,0.2); color: #ff8a78; border: 1px solid rgba(255,90,80,0.35); }

.lobby-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}
.lobby-actions .btn-primary { flex: 1; }

/* ============================================================
   Game view: container
   ============================================================ */
.view-game {
  flex-direction: column;
}

/* ============================================================
   Header
   ============================================================ */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15));
  border-bottom: 1px solid rgba(0,0,0,0.3);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.game-logo {
  margin: 0;
  font-family: "Archivo Black", "Helvetica Neue", Arial, sans-serif;
  font-style: italic;
  font-size: 30px;
  letter-spacing: 1px;
  color: #EC5A2C;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0,0,0,0.18), 0 1px 0 rgba(255,255,255,0.25);
  line-height: 1;
}
.logo-sep { display: inline-block; width: 4px; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.turn-indicator {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: var(--gold);
  background: rgba(0,0,0,0.35);
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,215,100,0.3);
}

/* Turn-timer chip — sits next to the turn indicator, pulses red in
   the last 5 seconds. */
.timer-chip {
  font-weight: 800;
  font-family: "Archivo Black", sans-serif;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--gold);
  background: rgba(0,0,0,0.35);
  padding: 7px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,215,100,0.3);
  min-width: 44px;
  text-align: center;
}
.timer-chip.hidden { display: none; }
.timer-chip.warning {
  color: #fff;
  background: rgba(220, 50, 40, 0.95);
  border-color: rgba(255, 120, 110, 0.9);
  animation: timerPulse 0.9s ease-in-out infinite;
}
@keyframes timerPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(255,60,60,0.45); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(255,60,60,0); }
}

/* Timer option chooser in the lobby */
.timer-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.timer-opt {
  font-family: inherit;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.28);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
              transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
              color 0.15s ease;
}
.timer-opt:hover:not(:disabled) { background: rgba(0,0,0,0.45); }
.timer-opt:active:not(:disabled) { transform: scale(0.95); }
.timer-opt:disabled { cursor: not-allowed; opacity: 0.55; }
.timer-opt.selected {
  background: rgba(232,192,96,0.22);
  border-color: var(--gold);
  color: var(--gold);
}

.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.3);
  color: #f4f7f5;
  padding: 8px 16px;
  border-radius: 18px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease,
              transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn:hover { background: rgba(0,0,0,0.5); border-color: rgba(255,255,255,0.35); }
.btn:active { transform: scale(0.94) translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #E4571C 0%, #B53C10 100%);
  border-color: #F4A15E;
  color: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #F06B2E 0%, #C24914 100%); }
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   Board
   ============================================================ */

.board {
  flex: 1;
  padding: 18px 26px 4px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 14px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.player-area {
  display: grid;
  grid-template-columns: 140px auto 1fr;
  gap: 14px;
  align-items: start;
  background: rgba(0,0,0,0.18);
  border-radius: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.06);
  position: relative;
}
.player-bottom {
  grid-template-areas:
    "label stock discards"
    "hand  hand  hand";
}
.player-area .hand         { grid-area: hand; }
.player-area .stock-slot   { grid-area: stock; }
.player-area .discard-row  { grid-area: discards; }

/* ============================================================
   Opponent strip — compact, one row per non-viewer player.
   Same anatomy (label · stock · discards · hand) but with
   smaller cards and tighter spacing so 5 opponents still fit.
   ============================================================ */

.opponents-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opponent-strip {
  /* Shrink all card sizing inside this subtree. */
  --game-card-w: 84px;
  --game-card-h: 118px;

  grid-template-columns: 130px auto 1fr auto;
  grid-template-areas: "label stock discards hand";
  padding: 8px 14px;
  gap: 12px;
  align-items: center;
}
.opponent-strip .hand {
  grid-area: hand;
  min-height: 0;
  padding: 0;
  flex-wrap: nowrap;
  max-width: 220px;
  justify-content: flex-end;
  gap: 0;
}
.opponent-strip .hand-opp .card {
  margin-left: -44px;
  transform: rotate(2deg);
}
.opponent-strip .hand-opp .card:first-child { margin-left: 0; }
.opponent-strip .hand-opp .card:nth-child(odd) { transform: rotate(-2deg); }

.opponent-strip .discard-row { gap: 8px; }

.opponent-strip .player-label { padding-top: 0; gap: 2px; }
.opponent-strip .player-name  { font-size: 13px; }
.opponent-strip .stock-count  { font-size: 11px; }

/* Shrink label/badge text inside the compact cards */
.opponent-strip .face-num             { font-size: 56px; letter-spacing: -2px; }
.opponent-strip .card-num[data-digits="2"] .face-num { font-size: 46px; letter-spacing: -3px; }
.opponent-strip .corner-num           { font-size: 12px; }
.opponent-strip .corner-br .corner-num{ font-size: 11px; }
.opponent-strip .corner-dots .dot     { width: 4px; height: 4px; }
.opponent-strip .corner-tl            { top: 4px; left: 5px; }
.opponent-strip .corner-br            { bottom: 4px; right: 5px; }
.opponent-strip .wild-mark-line       { font-size: 18px; }
.opponent-strip .wild-center::before  { width: 80px; height: 80px; }
.opponent-strip .wild-dot             { width: 3px; height: 3px; }
.opponent-strip .corner-wordmark      { font-size: 4.5px; }
.opponent-strip .back-mark-line       { font-size: 14px; }

/* Discard / stock slot labels are too big at this scale — hide them. */
.opponent-strip .slot-label,
.opponent-strip .stock-slot .slot-label,
.opponent-strip .discard-pile::after { display: none; }

.player-label {
  grid-area: label;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding-top: 6px;
}
.player-name {
  font-size: 15px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.stock-count {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
}

/* Active player highlight */
.player-area.active {
  border-color: rgba(255,215,100,0.55);
  box-shadow: 0 0 0 1px rgba(255,215,100,0.25), 0 6px 16px rgba(0,0,0,0.25);
  background: rgba(0,0,0,0.3);
}
.player-area.active .player-name { color: var(--gold); }

.stock-slot { grid-area: stock; }

.discard-row {
  grid-area: discards;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hand {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 6px 0 2px;
  min-height: calc(var(--game-card-h) + 4px);
}

/* Opponent's hand (face-down cards) — compact/overlapping */
.hand-opp .card {
  margin-left: -28px;
  transform: rotate(2deg);
}
.hand-opp .card:first-child { margin-left: 0; }
.hand-opp .card:nth-child(odd) { transform: rotate(-2deg); }

/* ============================================================
   Centre: draw, build, completed
   ============================================================ */

.center-area {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.06);
}

.build-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   Slots (empty placeholders for any pile)
   ============================================================ */

.slot {
  width: var(--game-card-w);
  height: var(--game-card-h);
  border-radius: 10px;
  background: var(--slot-bg);
  border: 2px dashed var(--slot-border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.slot-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  font-weight: 700;
}

.stock-slot,
.draw-slot,
.completed-slot {
  width: var(--game-card-w);
  height: var(--game-card-h);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stock-slot .slot-label,
.draw-slot .slot-label,
.completed-slot .slot-label {
  position: absolute;
  bottom: -18px;
  left: 0;
  right: 0;
  text-align: center;
}

.build-pile {
  width: var(--game-card-w);
  height: var(--game-card-h);
  border-radius: 10px;
  background: var(--slot-bg);
  border: 2px dashed var(--slot-border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
}
.build-pile::after {
  content: "Build";
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  font-weight: 700;
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}
.build-pile.has-card::after { display: none; }

.discard-pile {
  width: var(--game-card-w);
  height: var(--game-card-h);
  border-radius: 10px;
  background: var(--slot-bg);
  border: 2px dashed var(--slot-border);
  position: relative;
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
}
.discard-pile::after {
  content: "Discard";
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  font-weight: 700;
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
}
.discard-pile.has-card::after { display: none; }

/* Valid drop target highlight */
.build-pile.drop-ok,
.discard-pile.drop-ok {
  border-color: var(--slot-border-hot);
  box-shadow: 0 0 0 3px rgba(255,215,100,0.18);
  background: rgba(255,215,100,0.05);
}

/* ============================================================
   Cards in play — scaled via CSS variable override
   ============================================================ */

.page-game .card {
  --card-w: var(--game-card-w);
  --card-h: var(--game-card-h);
  --card-radius: 8px;
  width: var(--game-card-w);
  height: var(--game-card-h);
  border-radius: var(--card-radius);
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.18s ease;
}
.page-game .card:active {
  transform: scale(0.94);
}

/* Clickable wrappers around cards also react to the press. */
.page-game .hand-slot,
.page-game .stacked,
.page-game .build-pile,
.page-game .discard-pile {
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.page-game .hand-slot:active,
.page-game .stacked:active,
.page-game .build-pile:active,
.page-game .discard-pile:active {
  transform: scale(0.95);
}

/* Scale the interior text for game-sized cards */
.page-game .face-num { font-size: 82px; letter-spacing: -3px; }
.page-game .card-num[data-digits="2"] .face-num { font-size: 66px; letter-spacing: -4px; }
.page-game .corner-num { font-size: 17px; }
.page-game .corner-br .corner-num { font-size: 15px; }
.page-game .corner-dots .dot { width: 6px; height: 6px; }
.page-game .corner-tl { top: 6px; left: 8px; }
.page-game .corner-br { bottom: 6px; right: 8px; }
.page-game .wild-mark-line { font-size: 26px; }
.page-game .wild-center::before { width: 110px; height: 110px; }
.page-game .wild-dot { width: 4px; height: 4px; }
.page-game .corner-wordmark { font-size: 6px; }

/* Stacked piles — show only top, with a small shadow implying depth */
.stacked {
  position: relative;
  width: var(--game-card-w);
  height: var(--game-card-h);
  cursor: pointer;
}
.stacked::before, .stacked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
  z-index: 0;
}
.stacked::before { transform: translate(2px, 2px); }
.stacked::after  { transform: translate(4px, 4px); }
.stacked > .card { position: relative; z-index: 1; }

.stacked-count {
  position: absolute;
  bottom: -16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  z-index: 2;
}

/* Selected source card — visual cue via outline + shadow only so the
   transform property stays free for tap/jump animations. */
.card.selected {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  box-shadow:
    0 10px 22px rgba(0,0,0,0.45),
    0 0 0 2px rgba(0,0,0,0.25),
    inset 0 0 0 1px rgba(255,215,100,0.2);
}
.hand-slot:has(.card.selected),
.stacked:has(.card.selected),
.discard-pile:has(.card.selected) {
  transform: translateY(-8px);
}

/* "Jump" animation — applied on the build-pile element after a
   successful play so you get a satisfying bounce. */
@keyframes playJump {
  0%   { transform: scale(0.5) translateY(-30px); opacity: 0.5; }
  55%  { transform: scale(1.12) translateY(0);    opacity: 1; }
  75%  { transform: scale(0.96) translateY(0); }
  100% { transform: scale(1)    translateY(0); }
}
.just-played > .card {
  animation: playJump 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 50% 70%;
}

/* Completed-pile flourish */
@keyframes pileFlash {
  0%   { box-shadow: 0 0 0 0 rgba(255,215,100,0.8); }
  50%  { box-shadow: 0 0 0 14px rgba(255,215,100,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,215,100,0); }
}
.build-pile.just-completed {
  animation: pileFlash 0.6s ease-out;
}

/* Playable hints: pulse around any card the current player could play */
.card.hint {
  animation: hintPulse 1.8s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,215,100,0); }
  50%      { box-shadow: 0 0 0 4px rgba(255,215,100,0.35); }
}

/* ============================================================
   Card back
   ============================================================ */

.card-back .card-face.card-back-face {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,215,100,0.04) 0 6px,
      transparent 6px 12px
    ),
    linear-gradient(140deg, #8a1c17 0%, #521009 100%);
}
.back-frame {
  position: absolute;
  inset: 6px;
  border-radius: calc(var(--card-radius) - 3px);
  border: 1.5px solid rgba(245, 207, 90, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.35);
}
.back-mark {
  display: flex;
  flex-direction: column;
  line-height: 0.85;
  transform: rotate(-14deg);
}
.back-mark-line {
  font-family: "Archivo Black", "Helvetica Neue", Arial, sans-serif;
  font-style: italic;
  font-size: 22px;
  color: #f2c74a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

/* ============================================================
   Wild "played as N" badge (visible after being placed on a build pile)
   ============================================================ */

.wild-played-as {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.78);
  color: var(--gold);
  font-family: "Archivo Black", sans-serif;
  font-weight: 900;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  border: 1.5px solid var(--gold);
}

/* ============================================================
   Action bar
   ============================================================ */

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 26px 18px;
  gap: 16px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.action-hint {
  font-size: 14px;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.3px;
}

/* ============================================================
   Overlays (pass-device + win)
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
.overlay-card {
  background: linear-gradient(180deg, #1e7543 0%, #0e3f22 100%);
  border: 2px solid var(--gold);
  border-radius: 18px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-width: 420px;
}
.overlay-card h2 {
  margin: 0 0 8px;
  font-family: "Archivo Black", sans-serif;
  font-style: italic;
  color: var(--gold);
  font-size: 32px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.overlay-card p {
  margin: 0 0 20px;
  color: rgba(255,255,255,0.85);
  font-size: 15px;
}

/* ============================================================
   Game log drawer — collapsible bottom-right panel
   ============================================================ */

.log-drawer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 380px;
  max-width: calc(100vw - 36px);
  height: 56vh;
  max-height: 500px;
  background: rgba(8, 20, 14, 0.96);
  border: 1px solid rgba(255,215,100,0.25);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  transform: translateY(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  z-index: 80;
  backdrop-filter: blur(10px);
}
.log-drawer.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.25);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}
.log-title {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}
.log-close {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.log-close:hover  { background: rgba(0,0,0,0.55); }
.log-close:active { transform: scale(0.9); }

.log-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255,255,255,0.88);
  scroll-behavior: smooth;
}
.log-empty {
  color: rgba(255,255,255,0.45);
  font-style: italic;
  padding: 12px 4px;
}

.log-entry {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}
.log-entry:last-child { border-bottom: none; }
.log-time {
  color: rgba(255,255,255,0.38);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  white-space: nowrap;
  padding-top: 2px;
  min-width: 60px;
}
.log-text strong { color: #fff; }

/* Inline coloured card pips inside log entries */
.log-card {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  font-weight: 900;
  font-size: 12px;
  color: #fff;
  min-width: 20px;
  text-align: center;
  vertical-align: 1px;
}
.log-card-red    { background: var(--red); }
.log-card-yellow { background: var(--yellow); color: #3a2400; }
.log-card-green  { background: var(--green); }
.log-card-wild {
  background: linear-gradient(90deg, var(--red) 0%, var(--yellow) 50%, var(--green) 100%);
  color: #fff;
  padding: 0 8px;
  font-size: 11px;
}

.log-kind-pileComplete .log-text { color: var(--gold); }
.log-kind-win          .log-text { color: var(--gold); font-weight: 700; }
.log-kind-timeout      .log-text { color: #ff8a78; }

@media (max-width: 640px) {
  .log-drawer {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    height: 52vh;
  }
}

/* ============================================================
   Rules modal (shared across landing / lobby / game)
   ============================================================ */

.rules-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  animation: fadeIn 0.18s ease-out;
}
.rules-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.rules-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  background: linear-gradient(180deg, #1e7543 0%, #0e3f22 100%);
  border: 2px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rulesPop 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes rulesPop {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.rules-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.15);
}
.rules-title {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  font-style: italic;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.rules-close {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease;
}
.rules-close:hover  { background: rgba(0,0,0,0.5); }
.rules-close:active { transform: scale(0.9); }

.rules-body {
  padding: 18px 24px 22px;
  overflow-y: auto;
  color: rgba(255,255,255,0.92);
  line-height: 1.5;
  font-size: 14px;
}
.rules-body section { margin-bottom: 18px; }
.rules-body section:last-child { margin-bottom: 4px; }
.rules-body h3 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}
.rules-body p { margin: 0 0 8px; }
.rules-body ul, .rules-body ol {
  margin: 0;
  padding-left: 22px;
}
.rules-body li { margin-bottom: 4px; }
.rules-body li ul, .rules-body li ol { margin-top: 4px; }
.rules-body strong { color: #fff; }

@media (max-width: 640px) {
  .rules-head { padding: 12px 16px; }
  .rules-title { font-size: 18px; }
  .rules-body { padding: 14px 18px 18px; font-size: 13px; }
}

/* ============================================================
   Shake on illegal move
   ============================================================ */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX( 6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX( 4px); }
}
.shake { animation: shake 0.35s ease-in-out; }

/* ============================================================
   Small-screen layout
   ============================================================ */

@media (max-width: 900px) {
  :root { --scale: 0.46; }
  .board { padding: 10px 12px; }
  .player-area { grid-template-columns: 100px auto 1fr; padding: 8px 10px; gap: 10px; }
  .game-logo { font-size: 24px; }
  .turn-indicator { font-size: 12px; padding: 5px 10px; }
  .btn { padding: 6px 12px; font-size: 12px; }
  .action-bar { padding: 10px 14px 14px; }
  .center-area { gap: 10px; padding: 8px 10px; }
  .build-row { gap: 8px; }
}
