:root {
  --bg: radial-gradient(circle at 20% 20%, #2a3930 0%, #1e2822 35%, #0f1411 100%);
  --panel: #f2e9d8;
  --panel-ink: #1f1e1a;
  --accent: #c24f2a;
  --accent-2: #2f7f69;
  --border: #1f1e1a;
  --shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: #f8f2e7;
  background: var(--bg);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.gate {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 9, 0.74);
  backdrop-filter: blur(3px);
  z-index: 100;
  padding: 1rem;
}

.gate.open {
  display: flex;
}

.gate-card {
  width: min(560px, 100%);
  background: var(--panel);
  color: var(--panel-ink);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.gate-card h2 {
  margin: 0 0 0.3rem;
}

.gate-row {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.7rem;
}

.gate-form {
  display: grid;
  gap: 0.35rem;
}

.gate-card {
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.gate-title {
  margin: 0;
  font-size: 1.6rem;
}

.gate-subtitle {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.92rem;
  opacity: 0.8;
}

.setup-steps {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.8rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
  font-size: 0.78rem;
}

.setup-steps li {
  flex: 1;
  padding-top: 0.35rem;
  border-top: 3px solid rgba(31, 30, 26, 0.15);
  opacity: 0.6;
  counter-increment: step;
}

.setup-steps li::before {
  content: counter(step) ". ";
}

.setup-steps li.done,
.setup-steps li.active {
  border-top-color: var(--accent-2);
  opacity: 1;
}

.setup-steps li.done::before {
  content: "✓ ";
  color: var(--accent-2);
  font-weight: 700;
}

.setup-steps li.active {
  border-top-color: var(--accent);
  font-weight: 700;
}

.gate-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 0.8rem;
  border-radius: 12px;
  background: rgba(31, 30, 26, 0.08);
}

.gate-tab {
  flex: 1;
  background: transparent;
  color: var(--panel-ink);
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 700;
}

.gate-tab.active {
  background: #fffaf0;
  border-color: rgba(31, 30, 26, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.tab-count {
  display: inline-block;
  margin-left: 0.35rem;
  min-width: 1.3rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.3rem;
}

.name-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.name-row input {
  margin: 0;
}

.icon-btn {
  flex: none;
  background: #fffaf0;
  color: var(--panel-ink);
  padding: 0.35rem 0.55rem;
}

.choice-group {
  border: none;
  margin: 0.5rem 0 0;
  padding: 0;
  min-width: 0;
}

.choice-group legend,
.slider-field label {
  padding: 0;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.mode-option input,
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card {
  display: grid;
  gap: 0.2rem;
  height: 100%;
  padding: 0.5rem 0.55rem;
  border: 1px solid rgba(31, 30, 26, 0.25);
  border-radius: 10px;
  background: #fffaf0;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.mode-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.mode-desc {
  font-size: 0.76rem;
  opacity: 0.75;
  line-height: 1.3;
}

.mode-badge {
  display: inline-block;
  margin-left: 0.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(47, 127, 105, 0.15);
  color: var(--accent-2);
  font-size: 0.66rem;
  vertical-align: middle;
}

.mode-option input:checked + .mode-card {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px var(--accent-2);
}

.mode-option input:focus-visible + .mode-card,
.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.more-modes {
  margin-top: 0.35rem;
}

.more-modes summary {
  cursor: pointer;
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
  opacity: 0.8;
}

.slider-field {
  margin-top: 0.5rem;
}

.slider-field output {
  float: right;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  margin: 0.2rem 0 0;
  padding: 0;
  border: none;
  accent-color: var(--accent-2);
  background: transparent;
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  opacity: 0.6;
}

.segmented {
  display: flex;
  border: 1px solid rgba(31, 30, 26, 0.25);
  border-radius: 10px;
  overflow: hidden;
  background: #fffaf0;
}

.segmented label {
  flex: 1;
  position: relative;
}

.segmented span {
  display: block;
  padding: 0.45rem 0.3rem;
  text-align: center;
  font-size: 0.8rem;
  cursor: pointer;
}

.segmented label + label span {
  border-left: 1px solid rgba(31, 30, 26, 0.18);
}

.segmented input:checked + span {
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
}

.primary-cta {
  margin-top: 0.6rem;
  width: 100%;
  padding: 0.75rem;
}

.practice-link {
  justify-self: center;
  margin-top: 0.35rem;
  color: var(--accent-2);
  font-size: 0.85rem;
}

.text-link-btn.practice-link:hover {
  color: var(--panel-ink);
}

.gate-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.2rem 0 0.6rem;
}

.settings-chip {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(31, 30, 26, 0.08);
  font-size: 0.75rem;
  font-weight: 700;
}

#gatePlayers {
  margin-bottom: 0.7rem;
}

.remove-bot-btn {
  padding: 0.1rem 0.5rem;
  background: transparent;
  color: var(--panel-ink);
  border-color: rgba(31, 30, 26, 0.3);
  font-size: 0.75rem;
}

.away-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: #f0b24e;
  color: #1f1e1a;
  font-size: 0.9rem;
}

.away-banner .guess-btn {
  flex: none;
  min-width: 0;
}

.tag-away {
  background: rgba(31, 30, 26, 0.55);
  color: #fff;
}

.player-row.is-away {
  opacity: 0.6;
}

.join-hint {
  margin: 0.2rem 0 0;
}

.invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rules-tldr {
  margin-bottom: 0.4rem;
  background: #fffaf0;
}

.rules-tldr p {
  margin: 0;
}

#rulesPanel h2 {
  margin: 0.3rem 0 0;
  font-size: 1.1rem;
}

.first-turn-hint {
  margin: 0.4rem 0 0;
  color: #1f1e1a;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  background: rgba(141, 233, 110, 0.2);
  font-size: 0.85rem;
}

.noscript {
  text-align: center;
  padding: 2rem 1rem;
}

#rulesPanel {
  max-height: 75vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.35rem;
}

.create-visibility-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #9ba396;
  border-radius: 999px;
  transition: background-color 120ms ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #f2e9d8;
  border-radius: 50%;
  transition: transform 120ms ease;
}

.switch input:checked + .slider {
  background: #2f7f69;
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.join-room-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.2rem 0 0.25rem;
}

.rules-examples {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  margin: 0.5rem 0;
}

.rules-example {
  padding: 0.55rem;
}

.rules-example h4 {
  margin: 0 0 0.3rem;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  max-width: 180px;
}

.r-cell {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(31, 30, 26, 0.28);
  background: rgba(31, 30, 26, 0.08);
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.78rem;
  font-weight: 700;
}

.r-cell.card {
  background: rgba(31, 30, 26, 0.8);
  color: #f4ecd9;
}

.r-cell.candidate {
  background: rgba(255, 162, 51, 0.35);
  color: #a45300;
}

.r-cell.bad {
  background: rgba(80, 150, 255, 0.3);
  color: #1e4f8f;
}

.rules-chip {
  display: inline-block;
  min-width: 122px;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(31, 30, 26, 0.25);
  background: rgba(31, 30, 26, 0.08);
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.75rem;
}

.error {
  color: #9a2510;
  min-height: 1.2rem;
  margin: 0.45rem 0 0;
}

.transport-status {
  margin: 0.35rem 0 0;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.78rem;
  opacity: 0.9;
}

.turn-popup {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  z-index: 140;
  padding: 0.48rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(12, 16, 14, 0.92);
  color: #f8f2e7;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.miss-toast {
  position: fixed;
  top: 3.6rem;
  left: 50%;
  z-index: 141;
  max-width: calc(100% - 2rem);
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  background: rgba(150, 28, 20, 0.95);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.miss-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.endgame-card {
  width: min(480px, 100%);
  text-align: center;
}

.endgame-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}

.endgame-card h2 {
  margin: 0.15rem 0 0.2rem;
  font-size: 1.7rem;
}

.endgame-note {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  opacity: 0.75;
}

.endgame-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.endgame-stats div {
  display: grid;
  padding: 0.45rem;
  border-radius: 10px;
  background: rgba(31, 30, 26, 0.06);
}

.endgame-stats strong {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 1.1rem;
}

.endgame-stats span {
  font-size: 0.7rem;
  opacity: 0.65;
}

.endgame-list {
  text-align: left;
  margin-bottom: 0.4rem;
}

.player-row.is-winner {
  border-color: #e3b341;
  box-shadow: 0 0 0 2px rgba(227, 179, 65, 0.35);
}

.endgame-place {
  font-size: 0.85rem;
}

.endgame-actions .primary-cta {
  margin-top: 0.3rem;
}

.room-close-note {
  margin: 0 0 0.3rem;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.78rem;
  opacity: 0.75;
}

.room-close-note:empty {
  display: none;
}

.room-close-note.urgent {
  color: #b3261e;
  opacity: 1;
  font-weight: 700;
}

.text-link-btn.endgame-leave {
  margin-top: 0.2rem;
  color: var(--panel-ink);
  opacity: 0.7;
}

.text-link-btn.endgame-leave:hover {
  color: var(--panel-ink);
  opacity: 1;
}

#readyRematchBtn.is-ready {
  background: #fffaf0;
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.action-help {
  margin: 0 0 0.7rem;
  text-align: center;
  font-size: 0.82rem;
  opacity: 0.75;
}

.play-card {
  display: grid;
  place-items: center;
  width: 3.6rem;
  height: 5rem;
  border-radius: 10px;
  border: 1px solid rgba(31, 30, 26, 0.25);
  background: #fffdf8;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f1e1a;
}

.play-card.heart,
.play-card.diamond {
  color: #c22f22;
}

.turn-popup.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 0.75rem;
  width: min(1320px, 100%);
  margin: 0 auto;
}

.panel {
  background: rgba(8, 11, 9, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.board-panel {
  padding: 0.85rem;
}

/* Phone-first order: header, board, players, then streak and power-ups,
   so the board is on screen as soon as the page loads. */
.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "play"
    "side"
    "meta";
  gap: 0.75rem;
}

.board-head {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.board-head-text {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.8rem;
}

.title-row .phase {
  margin: 0;
}

.mode-line {
  margin: 0;
  font-size: 0.8rem;
  color: #b9b0a0;
}

.mode-line:empty {
  display: none;
}

.game-play {
  grid-area: play;
  min-width: 0;
}

.game-side {
  grid-area: side;
  min-width: 0;
}

.game-meta {
  grid-area: meta;
}

@media (min-width: 1000px) {
  .game-shell {
    grid-template-columns: minmax(0, 1fr) clamp(260px, 24vw, 320px);
    grid-template-areas:
      "head side"
      "play side"
      "meta side";
    grid-template-rows: auto auto 1fr;
    column-gap: 1rem;
  }

  .game-side {
    align-self: start;
    position: sticky;
    top: 0.75rem;
    max-height: calc(100svh - 1.5rem);
    overflow-y: auto;
  }
}

.board-actions {
  margin-top: 0;
}

.deck-corner {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(12, 16, 14, 0.75);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.deck-stack {
  position: relative;
  width: 60px;
  height: 78px;
}

.deck-tile {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.34);
}

.deck-tile.t2 {
  transform: translate(-4px, -4px);
  opacity: 0.9;
}

.deck-tile.t3 {
  transform: translate(-8px, -8px);
  opacity: 0.75;
}

.deck-reveal-card {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(242, 233, 216, 0.16);
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.34);
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.98rem;
  font-weight: 700;
  color: #f8f2e7;
}

.deck-reveal-card.heart {
  color: #ff8b79;
}

.deck-reveal-card.diamond {
  color: #f1d24d;
}

.deck-reveal-card.club {
  color: #64b5ff;
}

.deck-reveal-card.spade {
  color: #ffffff;
}

.deck-count {
  margin: 0;
  white-space: nowrap;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.82rem;
  color: #f5efe3;
  background: rgba(242, 233, 216, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
}

.streak-panel {
  margin-top: 0;
}

.meta-row {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr);
  gap: 0.85rem;
  align-items: start;
}

.streak-meter {
  display: flex;
  gap: 0.45rem;
  margin: 0.35rem 0 0.45rem;
}

.streak-chip {
  width: 26px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(31, 30, 26, 0.4);
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.12);
}

.streak-chip.filled {
  background: linear-gradient(120deg, #28a66b, #8cd18d);
  box-shadow: 0 0 8px rgba(40, 166, 107, 0.45);
}

h1,
.board-title {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0.2rem 0 0.5rem;
  color: #d6cbb9;
}

.share-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.text-link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: #d6cbb9;
  font: inherit;
  font-size: 0.92rem;
  text-decoration: underline;
  cursor: pointer;
}

.text-link-btn:hover {
  color: #f2e9d8;
}

.games-layout {
  width: min(980px, 100%);
  max-width: min(980px, 100%);
}

.games-panel {
  width: 100%;
}

.games-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.games-links {
  display: flex;
  gap: 0.5rem;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin: 0.4rem 0 1rem;
}

.stat-tile {
  display: grid;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.stat-tile strong {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 1.25rem;
}

.stat-tile span {
  font-size: 0.78rem;
  color: #d6cbb9;
}

.games-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.8rem;
}

.block.game-card {
  /* Cards re-render on every live update; the fade-in would flicker. */
  animation: none;
}

.game-card {
  display: grid;
  gap: 0.5rem;
  align-content: start;
}

.game-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.game-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.game-status {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: rgba(31, 30, 26, 0.08);
  font-size: 0.72rem;
  font-weight: 700;
}

.game-status.live {
  background: rgba(194, 79, 42, 0.15);
  color: #8d3417;
}

.game-meta {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.7;
}

.join-link {
  display: block;
  text-align: center;
  text-decoration: none;
  color: #f5f0e8;
  background: var(--accent-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
  /* Width follows the viewport height so the whole board fits on screen
     under the header and status bar (about 16.5rem). With 5:4 cells plus gaps,
     the board's height is roughly width / 1.2. */
  width: min(100%, calc((100svh - 16.5rem) * 1.2));
  margin: 0 auto;
}

.status-bar {
  margin-bottom: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 16, 14, 0.6);
}

.status-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.status-turn {
  flex: none;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-turn.mine {
  background: var(--accent);
  color: #fff;
}

.status-prompt {
  flex: 1;
  margin: 0;
  min-width: 0;
  font-size: 0.92rem;
}

.status-timer {
  flex: none;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: #d6cbb9;
}

.status-timer.urgent {
  color: #ff6b5a;
  animation: timerPulse 0.6s ease-in-out infinite alternate;
}

.status-sub {
  margin: 0.3rem 0 0;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.78rem;
  color: #b9b0a0;
}

.status-sub:empty {
  display: none;
}

.turn-timer {
  margin-top: 0.45rem;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.turn-timer-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: rgba(214, 203, 185, 0.55);
  transition: width 100ms linear;
}

.turn-timer.mine .turn-timer-bar {
  background: linear-gradient(90deg, #ff7b39, #d64b1f);
}

.turn-timer.urgent .turn-timer-bar {
  background: #ff3b30;
  animation: timerPulse 0.6s ease-in-out infinite alternate;
}

@keyframes timerPulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-timer.urgent,
  .turn-timer.urgent .turn-timer-bar {
    animation: none;
  }
}

.cell {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 0 0.1rem;
  aspect-ratio: 5 / 4;
  min-height: 34px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  color: #f8f2e7;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: clamp(0.78rem, 1.5vw, 1.15rem);
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.cell:focus-visible {
  outline: 3px solid #f0b24e;
  outline-offset: 2px;
}

.cell:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.cell.empty {
  color: #7f897e;
}

.cell.playable {
  border-color: rgba(240, 178, 78, 0.7);
  background: rgba(240, 178, 78, 0.12);
  animation: playableGlow 1.6s ease-in-out infinite;
}

.cell.selected {
  outline: 2px solid #f0b24e;
}

.cell.prev-turn {
  outline: 2px solid #6bc9ff;
  box-shadow: 0 0 0 2px rgba(107, 201, 255, 0.2);
}

.cell.best-placement {
  outline: 2px solid #8de96e;
  box-shadow: 0 0 0 2px rgba(141, 233, 110, 0.22);
}

.cell.populate {
  animation: populateIn 420ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

.cell.wipe {
  animation: wipePulse 520ms ease-out;
}

.cell.flash-wrong {
  animation: wrongFlash 300ms ease-in-out 3;
}

.cell.heart {
  color: #ff8b79;
}

.cell.diamond {
  color: #f1d24d;
}

.cell.club {
  color: #64b5ff;
}

.cell.spade {
  color: #ffffff;
}

.block {
  background: var(--panel);
  color: var(--panel-ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem;
  animation: lift 280ms ease;
}

.block h2 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.phase,
.muted {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.84rem;
}

.scoreboard {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.38rem;
}

.scoreboard li {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  padding: 0.32rem 0.45rem;
  font-family: "JetBrains Mono", "Courier New", monospace;
}

.score-plus {
  color: #cc2e2e;
  font-weight: 700;
}

.score-cards {
  color: #2f9f54;
  font-weight: 700;
}

.scoreboard li.current .score-cards,
.scoreboard li.current .score-plus {
  color: #fff;
}

.scoreboard-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.scoreboard-head h2 {
  margin: 0;
}

.scoreboard-goal {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.72rem;
  opacity: 0.7;
}

.rich-scoreboard {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(31, 30, 26, 0.12);
  border-radius: 12px;
  background: #fffaf0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.player-row.is-turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(194, 79, 42, 0.25);
}

.player-avatar {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}

.player-row.is-turn .player-avatar {
  box-shadow: 0 0 0 2px #fffaf0, 0 0 0 4px var(--accent);
}

.player-main {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.player-name-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-width: 0;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.9rem;
}

.player-tag {
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag-you {
  background: rgba(31, 30, 26, 0.08);
}

.tag-turn {
  background: var(--accent);
  color: #fff;
}

.tag-next {
  background: rgba(194, 79, 42, 0.12);
  color: #8d3417;
}

.tag-lead {
  background: rgba(47, 127, 105, 0.15);
  color: #1f6652;
}

.player-sub {
  font-size: 0.7rem;
  opacity: 0.65;
}

.player-bar {
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(31, 30, 26, 0.1);
}

.player-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 320ms ease;
}

.bar-race span {
  background: linear-gradient(90deg, #2f7f69, #5fb89a);
}

.bar-danger span {
  background: linear-gradient(90deg, #e0a03a, #d9682f);
}

.bar-danger.hot span {
  background: linear-gradient(90deg, #d9682f, #c42020);
}

.player-stat {
  display: grid;
  justify-items: end;
  line-height: 1.1;
}

.player-stat strong {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 1.15rem;
}

.player-stat span {
  font-size: 0.66rem;
  opacity: 0.6;
}

.scoreboard li.current {
  color: #fff;
  background: linear-gradient(120deg, #c24f2a, #db7b39);
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#powerups {
  margin-bottom: 0.45rem;
}

#actionRelevantCards {
  margin-bottom: 0.75rem;
  justify-content: center;
}

#actionRelevantCards .cell {
  min-width: 58px;
  min-height: 48px;
  cursor: default;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.22);
  background: #000000;
}

#actionModalButtons {
  justify-content: flex-start;
}

#actionModal {
  background: radial-gradient(circle at 50% 20%, rgba(65, 87, 76, 0.35), rgba(8, 10, 9, 0.82));
}

#actionModal .gate-card {
  width: min(720px, 94vw);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(165deg, rgba(242, 233, 216, 0.98), rgba(225, 212, 193, 0.96));
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  animation: modalRise 180ms ease-out;
}

#actionModalTitle {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

#actionRelevantCards {
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(31, 30, 26, 0.2);
  background: rgba(255, 255, 255, 0.35);
}

#actionModalButtons .guess-btn {
  flex: 1 1 calc(50% - 0.35rem);
  max-width: calc(50% - 0.35rem);
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
}

#actionModalButtons .guess-btn:not(.alt) {
  background: linear-gradient(135deg, #2e7e69, #49a68f);
}

#actionModalButtons .guess-btn.alt {
  background: linear-gradient(135deg, #a64524, #cf6d39);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--accent-2);
  color: #f5f0e8;
  border-radius: 10px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}

.guess-btn {
  min-width: 132px;
  padding: 0.58rem 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.guess-btn:hover {
  transform: translateY(-1px);
}

.powerups-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.powerups-head h2 {
  margin: 0;
}

.token-pill {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: rgba(194, 79, 42, 0.14);
  color: #8d3417;
  font-size: 0.76rem;
  font-weight: 700;
}

.powerup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.powerup-card {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid rgba(31, 30, 26, 0.18);
  border-radius: 12px;
  background: #fffaf0;
  color: var(--panel-ink);
  text-align: left;
  box-shadow: 0 1px 0 rgba(31, 30, 26, 0.06);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.powerup-card.ready:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(31, 30, 26, 0.14);
  border-color: var(--accent-2);
}

.powerup-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.powerup-card:disabled {
  cursor: default;
}

.powerup-card:disabled .powerup-icon,
.powerup-card:disabled .powerup-name,
.powerup-card:disabled .powerup-desc {
  opacity: 0.55;
}

.powerup-card.tone-spent {
  background: rgba(255, 250, 240, 0.5);
  border-style: dashed;
}

.powerup-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: rgba(47, 127, 105, 0.12);
  font-size: 1.05rem;
}

.powerup-body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.powerup-name {
  font-weight: 700;
  font-size: 0.88rem;
}

.powerup-desc {
  font-size: 0.75rem;
  line-height: 1.3;
  opacity: 0.8;
}

.powerup-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.powerup-chip {
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.35rem;
  white-space: nowrap;
}

.tone-free .powerup-chip {
  background: rgba(47, 127, 105, 0.16);
  color: #1f6652;
}

.tone-token .powerup-chip {
  background: rgba(194, 79, 42, 0.14);
  color: #8d3417;
}

.tone-active .powerup-chip {
  background: #2f7f69;
  color: #fff;
}

.tone-spent .powerup-chip {
  background: rgba(31, 30, 26, 0.08);
  color: rgba(31, 30, 26, 0.6);
}

.powerup-note {
  font-size: 0.68rem;
  opacity: 0.65;
}

.powerups-off {
  margin: 0;
}

.powerup-shop {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.55rem;
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  border: 1px dashed rgba(31, 30, 26, 0.25);
}

.shop-info {
  flex: 1;
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  font-size: 0.8rem;
}

.shop-info span {
  opacity: 0.8;
}

.shop-meter {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(31, 30, 26, 0.1);
}

.shop-meter-now {
  background: #cc2e2e;
}

.shop-meter-cost {
  background: repeating-linear-gradient(45deg, rgba(204, 46, 46, 0.55) 0 4px, rgba(204, 46, 46, 0.25) 4px 8px);
}

.shop-btn {
  flex: none;
  min-width: 6.5rem;
  background: #fffaf0;
  color: var(--panel-ink);
  font-weight: 700;
}

.shop-btn.confirming {
  background: var(--accent);
  color: #fff;
}

.shop-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.streak-message {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  opacity: 0.8;
}

#actionModalButtons .guess-btn.modal-odds-btn {
  flex-basis: 100%;
  max-width: 100%;
  background: transparent;
  color: var(--panel-ink);
  border-style: dashed;
  box-shadow: none;
  padding: 0.5rem;
}

.guess-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.moving-card {
  position: fixed;
  z-index: 120;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: #f8f2e7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-weight: 700;
  transform: translate(-50%, -50%) rotateY(180deg) scale(0.9);
  transform-style: preserve-3d;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.3);
  transition:
    left 620ms cubic-bezier(0.19, 0.9, 0.2, 1),
    top 620ms cubic-bezier(0.19, 0.9, 0.2, 1),
    transform 620ms cubic-bezier(0.19, 0.9, 0.2, 1),
    opacity 140ms linear;
  backface-visibility: hidden;
}

.moving-card.preflip .moving-card-text {
  transform: scaleX(-1);
}

.moving-card.heart {
  color: #ff8b79;
}

.moving-card.diamond {
  color: #f1d24d;
}

.moving-card.club {
  color: #64b5ff;
}

.moving-card.spade {
  color: #ffffff;
  background: #283335;
}

button.alt {
  background: var(--accent);
}

button.ghost {
  background: transparent;
  color: var(--panel-ink);
}

label {
  font-size: 0.85rem;
}

input {
  width: 100%;
  margin: 0.15rem 0 0.4rem;
  border: 1px solid #3f3b31;
  border-radius: 8px;
  padding: 0.4rem;
}

select {
  width: 100%;
  margin: 0.15rem 0 0.4rem;
  border: 1px solid #3f3b31;
  border-radius: 8px;
  padding: 0.4rem;
  background: #fff;
}

@keyframes lift {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalRise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes populateIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.88);
    filter: saturate(0.6);
  }

  70% {
    opacity: 1;
    transform: translateY(-2px) scale(1.04);
  }

  100% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
}

@keyframes wipePulse {
  0% {
    background: rgba(255, 76, 76, 0.9);
    box-shadow: 0 0 0 0 rgba(255, 76, 76, 0.8);
    transform: scale(1.05);
  }

  60% {
    background: rgba(255, 76, 76, 0.26);
    box-shadow: 0 0 0 8px rgba(255, 76, 76, 0.08);
  }

  100% {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    transform: scale(1);
  }
}

@keyframes playableGlow {
  50% {
    box-shadow: 0 0 0 3px rgba(240, 178, 78, 0.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell.playable {
    animation: none;
  }
}

@keyframes wrongFlash {
  0% {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
  }

  50% {
    background: rgba(255, 50, 50, 0.86);
    box-shadow: 0 0 10px rgba(255, 50, 50, 0.85);
  }

  100% {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
  }
}

@media (max-width: 700px) {
  .layout {
    padding: 0.75rem;
  }

  .mode-options {
    grid-template-columns: 1fr;
  }

  .mode-card {
    grid-template-columns: 7rem 1fr;
    align-items: baseline;
    column-gap: 0.5rem;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }

  .powerup-grid {
    grid-template-columns: 1fr;
  }

  .deck-corner {
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.5rem;
  }

  .deck-stack {
    width: 34px;
    height: 44px;
  }

  .deck-reveal-card {
    font-size: 0.75rem;
  }

  .powerup-desc {
    display: none;
  }
}
