:root {
  color-scheme: dark;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: #fff9f5;
  background: #171424;
  --surface: #211c31;
  --raised: #2d263e;
  --line: #463d5a;
  --muted: #c5bad4;
  --coral: #ff927f;
  --lavender: #c7baff;
  --focus: #ffe6a4;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
a, button, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
[hidden] { display: none !important; }
.wrap { width: min(1160px, calc(100% - 48px)); margin-inline: auto; }
.site-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; min-height: 86px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 1.45rem; font-weight: 800; }
.mark { width: 27px; aspect-ratio: 1; background: var(--coral); border-radius: 8px 8px 15px 8px; transform: rotate(-12deg); }
nav { display: flex; align-items: center; gap: clamp(12px, 4vw, 28px); }
nav a { font-weight: 700; }
nav a:hover { color: var(--coral); }
.nav-join { padding: 10px 15px; border: 1px solid var(--line); border-radius: 10px; }

.hero {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  min-height: 438px;
  border: 1px solid #5c4878;
  border-radius: 28px;
  background: linear-gradient(135deg, #35284d, #221b34 64%);
  overflow: hidden;
}
.hero-copy { align-self: center; padding: clamp(28px, 6vw, 75px); padding-inline-end: 10px; }
h1 { font-size: clamp(2.6rem, 5.8vw, 5.15rem); line-height: 1.14; margin: 0; font-weight: 850; }
h1 span { color: var(--coral); }
.intro { color: #ece0f9; line-height: 1.8; max-width: 28rem; font-size: clamp(1rem, 2vw, 1.22rem); margin: 20px 0 26px; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--coral);
  color: #231525;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}
.button:hover { background: #ffaf9f; }
.secondary { border-color: #615477; background: var(--raised); color: #fff9f5; }
.secondary:hover { background: #443653; }
.hero-art {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  min-width: 0;
  overflow: hidden;
  background-color: #a996ed;
  background-image: linear-gradient(#32244c19 1px, transparent 1px), linear-gradient(90deg, #32244c19 1px, transparent 1px);
  background-size: 26px 26px;
}
.art-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(5px, 1vw, 10px);
  width: min(67%, 310px);
  padding: clamp(9px, 1.4vw, 15px);
  border-radius: 22px;
  border: 2px solid #4f3a6a;
  background: #261c38;
  box-shadow: -12px 15px #6b55a0;
  transform: rotate(-11deg);
}
.art-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 11px;
  background: #433457;
  color: #dbcfff;
  font: 800 clamp(1.65rem, 5vw, 4.35rem)/1 Arial, sans-serif;
}
.art-grid span:nth-child(4n + 1) { color: #271a2e; background: var(--coral); }
.art-spark { position: absolute; inset-inline-end: 12%; top: 11%; color: #fff0bd; font-size: clamp(2.2rem, 5vw, 4rem); }

.library { margin-block: 42px 26px; }
h2 { margin: 0 0 12px; font-size: clamp(1.65rem, 4vw, 2.4rem); line-height: 1.25; }
.library-grid, .room-options, .instructions { display: grid; gap: 14px; }
.library-grid, .room-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.game-card { min-width: 0; display: block; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.game-card:hover { border-color: var(--lavender); background: var(--raised); }
.card-thumbnail.hero-art { width: 100%; min-height: 0; aspect-ratio: 16 / 10; container-type: inline-size; }
.card-thumbnail .art-grid, .flight-art { width: 47%; max-width: 250px; transform: rotate(-11deg); }
.card-thumbnail .art-grid span { font-size: clamp(1.1rem, 10cqi, 3.25rem); }
.card-thumbnail .art-spark { top: 14%; inset-inline-end: 74%; font-size: clamp(1.7rem, 7cqi, 3rem); }
.flight-art {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid #4f3a6a;
  border-radius: 22px;
  background: radial-gradient(circle, #68557f 1px, transparent 1.5px) 0 0 / 22px 22px, #261c38;
  box-shadow: -12px 15px #6b55a0;
}
.flight-rock, .flight-ship, .flight-gem { position: absolute; }
.flight-rock {
  width: 31%;
  aspect-ratio: 1;
  background: #544264;
  clip-path: polygon(18% 7%, 67% 0%, 96% 34%, 88% 76%, 55% 100%, 16% 84%, 0 41%);
}
.flight-rock-top { top: 9%; right: 12%; }
.flight-rock-bottom { bottom: 10%; left: 11%; transform: rotate(37deg) scale(0.85); }
.flight-ship {
  width: 42%;
  aspect-ratio: 1.18;
  top: 35%;
  left: 29%;
  background: var(--coral);
  clip-path: polygon(100% 50%, 0 100%, 25% 50%, 0 0);
}
.flight-gem { color: var(--focus); top: 58%; right: 12%; font: 750 clamp(1.15rem, 8cqi, 2.75rem)/1 Arial, sans-serif; }
.bluff-art { display: grid; grid-template-columns: 1fr 1fr; width: 50%; max-width: 270px; }
.bluff-art span { display: grid; place-items: center; aspect-ratio: 0.7; border-radius: 15%; border: 3px solid #261c38; background: var(--coral); color: #261c38; transform: rotate(16deg); box-shadow: 5px 8px #6b55a0; font-size: clamp(1.5rem, 9cqi, 3rem); font-weight: 800; }
.bluff-art span:last-child { background: #49365e; color: var(--focus); transform: rotate(-15deg); }
.bluff-join { border: 1px solid var(--line); background: #281f38; border-radius: 14px; padding: 18px; }
#bluff-code, #closest-code { width: 11ch; }
#bluff-invite, #closest-invite { width: min(100%, 540px); margin-bottom: 12px; }
#bluff-status, #closest-status { color: var(--coral); font-weight: 750; min-height: 1.75em; }
#bluff-scores, #closest-scores { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
#bluff-scores li, #closest-scores li { padding: 7px 12px; border-radius: 8px; background: var(--raised); }
.closest-art span:first-child { background: var(--focus); }
#closest-scores .closest-point { color: var(--focus); }
#closest-number { width: 12ch; }
.bluff-card { min-height: 70px; padding: 9px; border: 2px solid transparent; border-radius: 10px; color: #231525; font: inherit; font-weight: 750; cursor: pointer; background: var(--coral); }
.bluff-card[data-color="purple"] { background: var(--lavender); }
.bluff-card[aria-pressed="true"] { border-color: #231525; outline: 2px solid var(--focus); }
.bluff-colors, #bluff-message:not(:empty) { margin-top: 14px; }
#bluff button:disabled, #closest button:disabled { opacity: 0.55; }
.card-info { display: block; padding: 15px 18px; }
.game-card strong, .game-card small { display: block; }
.game-card strong { font-size: 1.18rem; }
.game-card small { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }
.about, .game { margin-block: 26px; padding: clamp(18px, 3.2vw, 36px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.about p, .game-controls p { color: var(--muted); margin: 0; line-height: 1.75; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--lavender); font-weight: 700; }
.back-link:hover { text-decoration: underline; }
.room-options { margin-block: 20px; }
.room-options article, #join-form, .instructions li { border: 1px solid var(--line); background: #281f38; border-radius: 14px; padding: clamp(14px, 2vw, 22px); }
.room-options article { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.room-options h3, #invite-title { margin: 0; }
#invite-title { margin-bottom: 12px; }
.room-options article > :last-child { margin-top: auto; }
.mode-actions, .room-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.room-actions { margin-block: 10px; }
.rooms input { min-width: 0; max-width: 100%; min-height: 44px; border-radius: 10px; padding: 9px 12px; border: 1px solid #695a82; background: #171424; color: inherit; font: inherit; }
#room-code { width: 11ch; letter-spacing: 0.12em; text-transform: uppercase; }
#invite-url { width: min(100%, 540px); margin-bottom: 12px; }
#active-code { background: #3d3057; color: #f5e9ff; padding: 4px 8px; border-radius: 6px; }
#board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 350px); margin-block: 16px; }
#board button { aspect-ratio: 1; border-radius: 12px; border: 1px solid #62527b; background: #30253f; color: var(--lavender); font: bold clamp(1.8rem, 6vw, 3.6rem) Arial, sans-serif; cursor: pointer; }
#board button[data-symbol="X"] { color: var(--coral); }
#board button:disabled { cursor: default; }
#board button:not(:disabled):hover { background: #513d6b; }
#board[data-display] { width: min(100%, 520px); margin-inline: auto; }
#room-session:fullscreen { background: #171424; padding: 20px; overflow: auto; }
#room-session:fullscreen #board { width: min(100%, 48vh, 520px); }
#round-status { color: var(--coral); font-weight: 750; }
#room-message:not(:empty) { margin-top: 12px; }

.instructions { grid-template-columns: repeat(3, minmax(0, 1fr)); list-style: none; padding: 0; margin: 18px 0 0; }
.instructions strong, .instructions span { display: block; }
.instructions span { margin-top: 8px; color: var(--muted); line-height: 1.65; }
.game { max-width: 800px; margin-inline: auto; }
.scoreboard, .game-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.scoreboard { padding: 14px 16px; background: #322749; border-radius: 12px 12px 0 0; }
output { color: var(--coral); margin-inline-start: 5px; font-weight: 750; }
.arena { position: relative; overflow: hidden; border-radius: 0 0 12px 12px; background: #1c1630; }
canvas { display: block; width: 100%; height: auto; }
.arena[data-playing] canvas { touch-action: none; }
canvas:focus-visible { outline-offset: -4px; }
.game-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 12px; background: #1a132bdc; text-align: center; }
.game-overlay p { font-size: clamp(1.1rem, 3vw, 1.6rem); margin: 0 0 14px; }
.game-controls { padding-top: 12px; }
.game-controls button { min-height: 44px; cursor: pointer; color: inherit; font: inherit; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.game-controls button:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 740px) {
  .wrap { width: calc(100% - 28px); }
  .site-header { min-height: 72px; }
  .hero { grid-template-columns: 1fr; min-height: auto; border-radius: 20px; }
  .hero-copy { padding: 30px 22px; }
  .hero-art { min-height: 244px; }
  .art-grid { width: min(50%, 200px); }
  .art-grid span { font-size: clamp(1.6rem, 7vw, 3rem); }
  .instructions { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .library-grid, .room-options { grid-template-columns: 1fr; }
}
