:root {
  --bg: #12071c;
  --surface: #1c0e2b;
  --surface-2: #281540;
  --border: #3a2354;
  --border-strong: #5a3a7e;
  --text: #f6eef8;
  --soft: #cdbbdc;
  --mute: #b9a5ca;
  --burgundy: #9b1c45;
  --burgundy-light: #c2305f;
  --violet: #7c45c4;
  --rose: #f08aae;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

.panel { max-width: 520px; margin: 0 auto; padding: 24px 20px 40px; }
h1, h2 { font-family: var(--display); letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 10px; }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; margin-top: 28px; }
.lead { color: var(--soft); margin: 0 0 20px; }
.fine { color: var(--mute); font-size: 13px; margin: 16px 0 0; }
.msg { min-height: 1.4em; color: var(--rose); font-size: 14px; margin: 10px 0 0; }
.note { color: var(--mute); font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.field { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
input[type="text"] {
  width: 100%; height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 16px var(--body);
}
input[type="text"]:focus-visible, button:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }

.btn {
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 2px solid transparent;
  font: 700 16px var(--body); cursor: pointer; color: var(--text);
}
.btn-primary { background: var(--burgundy); color: #fff; }
.btn-primary:hover { background: var(--burgundy-light); }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.game-list { display: grid; gap: 10px; }
.game-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%;
  padding: 16px 18px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; cursor: pointer;
}
.game-card:hover { background: var(--surface-2); border-color: var(--border-strong); }
.game-card strong { font: 700 18px var(--display); }
.game-card span { color: var(--soft); font-size: 14px; }

.join { display: flex; gap: 10px; }
.join input { text-transform: uppercase; letter-spacing: .18em; font-weight: 700; }

/* Game view */
.game-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.game-head h1 { margin: 0; font-size: 28px; }
.code-chip { padding: 6px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; color: var(--soft); }
.code-chip strong { color: var(--text); letter-spacing: .18em; }
.invite { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }

.players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.player { padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.player.turn { border-color: var(--rose); background: var(--surface-2); }
.player .who { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.player .who span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex: none; }
.dot.on { background: var(--rose); }
.sub { color: var(--mute); font-size: 13px; }
.mark { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.mark-0 { background: var(--burgundy-light); }
.mark-1 { background: var(--violet); }

.status { font: 700 20px var(--display); margin: 8px 0 16px; min-height: 1.4em; }
.board-wrap { display: flex; justify-content: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* Tic-Tac-Toe */
.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 360px); }
.ttt button {
  aspect-ratio: 1; border-radius: 18px; border: 1px solid var(--border); background: var(--surface);
  font: 800 52px var(--display); color: var(--text); cursor: pointer; padding: 0;
}
.ttt button:hover:not(:disabled) { background: var(--surface-2); }
.ttt button:disabled { cursor: default; }
.ttt .c0 { color: var(--burgundy-light); }
.ttt .c1 { color: #a982e6; }
.ttt .win { border-color: var(--rose); background: var(--surface-2); }

/* Connect Four */
.c4 { width: min(100%, 420px); }
.c4-drops { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.c4-drops button {
  height: 40px; border-radius: 12px; border: 1px solid var(--border-strong); background: transparent;
  color: var(--soft); font: 700 14px var(--body); cursor: pointer; padding: 0;
}
.c4-drops button:hover:not(:disabled) { background: var(--surface-2); }
.c4-drops button:disabled { opacity: .35; cursor: default; }
.c4-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 8px; border-radius: 20px; background: #2e1550; border: 1px solid var(--border-strong); }
.c4-cell { aspect-ratio: 1; border-radius: 50%; background: var(--bg); }
.c4-cell.p0 { background: var(--burgundy-light); }
.c4-cell.p1 { background: var(--violet); }
.c4-cell.win { box-shadow: 0 0 0 3px var(--rose); }
.c4-cell.last { outline: 2px solid #fff; outline-offset: -4px; }

/* Rock Paper Scissors */
.rps { width: min(100%, 420px); text-align: center; }
.rps-score { display: flex; justify-content: space-around; font: 800 40px var(--display); margin-bottom: 4px; }
.rps-round { color: var(--mute); font-size: 14px; margin-bottom: 14px; }
.rps-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rps-picks button {
  padding: 18px 6px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 700 16px var(--body); cursor: pointer;
}
.rps-picks button:hover:not(:disabled) { background: var(--surface-2); }
.rps-picks button.chosen { border-color: var(--rose); background: var(--surface-2); }
.rps-picks button:disabled { cursor: default; opacity: .7; }
.rps-last { margin-top: 16px; color: var(--soft); font-size: 15px; min-height: 1.5em; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .game-card, .ttt button { transition: background .12s ease, border-color .12s ease; }
}

/* Would You Rather */
.wyr { width: min(100%, 440px); }
.wyr-round { color: var(--mute); font-size: 14px; margin-bottom: 10px; text-align: center; }
.wyr-choices { display: grid; gap: 12px; }
.wyr-choice { display: flex; align-items: center; gap: 14px; text-align: left; padding: 18px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 18px/1.3 var(--body); cursor: pointer; }
.wyr-choice:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.wyr-choice.chosen { border-color: var(--rose); background: var(--surface-2); }
.wyr-choice:disabled { cursor: default; opacity: .85; }
.wyr-letter { flex: none; width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--burgundy); color: #fff; font: 800 18px var(--display); }
.wyr-choice:nth-child(2) .wyr-letter { background: var(--violet); }
.wyr-note { margin-top: 12px; color: var(--soft); text-align: center; }
.wyr-final { font: 800 64px var(--display); text-align: center; }
.wyr-history { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 8px; }
.wyr-history li { padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; }
.wyr-history li.same { border-color: var(--rose); }
.wyr-q { color: var(--soft); }
.wyr-a { margin-top: 2px; font-weight: 700; }

/* Draw & Guess */
.dg { width: min(100%, 440px); display: flex; flex-direction: column; gap: 10px; }
.dg-banner { display: flex; align-items: baseline; gap: 10px; padding: 10px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-strong); }
.dg-label { color: var(--mute); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.dg-banner strong { font: 800 26px var(--display); }
.dg-hint { letter-spacing: .2em; }
.dg-meta { color: var(--soft); font-size: 14px; }
.dg-canvas { width: 100%; aspect-ratio: 1; border-radius: 20px; background: #170a26; border: 1px solid var(--border); touch-action: none; }
.dg-canvas.dg-live { cursor: crosshair; border-color: var(--rose); }
.dg-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dg-color { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.dg-color.on { border-color: #fff; }
.dg-width { width: 40px; height: 34px; border-radius: 12px; border: 1px solid var(--border-strong); background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.dg-width.on { background: var(--surface-2); border-color: var(--rose); }
.dg-dot { display: block; background: var(--text); border-radius: 50%; }
.dg-dot-0 { width: 5px; height: 5px; } .dg-dot-1 { width: 10px; height: 10px; } .dg-dot-2 { width: 16px; height: 16px; }
.dg-guess { display: flex; gap: 8px; }
.dg-guess input { flex: 1; min-width: 0; }
.dg-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; color: var(--soft); font-size: 14px; }

.tv-q { font: 700 22px/1.25 var(--display); text-align: center; margin: 4px 0 16px; }
.us-word { font: 800 40px/1.2 var(--display); text-align: center; letter-spacing: .06em; margin: 12px 0 4px; word-break: break-word; }
.unscramble .dg-guess { margin-top: 14px; }
.unscramble .btn-ghost { margin: 12px auto 0; display: block; }
