:root {
  --bg: #F0E1F2;
  --surface: #FFFFFF;
  --surface-2: #F7ECF8;
  --border: #E6CFEA;
  --border-strong: #D3B3DA;
  --text: #1D1626;
  --soft: #4A4058;
  --mute: #6B607A;
  --burgundy: #E5336B;
  --burgundy-light: #FF4D7E;
  --violet: #8B5CC9;
  --rose: #E5336B;
  --gold: #FF9A5B;
  --peach: #FFD9B8;
  --blush: #FFD0DC;
  --ink: #1D1626;
  --display: "Sora", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { 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 {
  --gc: #7c45c4; --gcInk: #fff;
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 14px 16px; border-radius: 6px; border: 2px solid #fff; background: var(--gc); color: var(--gcInk);
  font: inherit; cursor: pointer; box-shadow: 5px 5px 0 #000; transition: transform .12s ease, box-shadow .12s ease;
}
.game-card:hover { transform: translate(-2px, -2px) rotate(-.4deg); box-shadow: 8px 8px 0 #000; }
.game-card:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 #000; }
.game-card:disabled { opacity: .6; cursor: wait; }
.game-card:focus-visible { outline: 3px solid #ffc247; outline-offset: 3px; }
.gc-ico {
  flex: none; display: grid; place-items: center; width: 56px; height: 56px; font-style: normal; font-size: 30px;
  background: rgba(0, 0, 0, .28); border: 2px solid #fff; border-radius: 4px; transform: rotate(-6deg);
}
.game-card:hover .gc-ico { transform: rotate(5deg) scale(1.06); }
.gc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.game-card strong { font: 800 20px/1 var(--display); text-transform: uppercase; letter-spacing: .01em; }
.game-card .gc-blurb { font-size: 13.5px; line-height: 1.3; opacity: .92; }
.gc-tag {
  align-self: flex-start; margin-top: 4px; padding: 2px 7px; font: 800 10.5px/1.4 var(--body); font-style: normal;
  text-transform: uppercase; letter-spacing: .08em; background: #000; color: #fff; border-radius: 2px;
}
.game-card[data-game="tictactoe"] { --gc: #2fb67a; --gcInk: #04281a; }
.game-card[data-game="connect4"]  { --gc: #ffc247; --gcInk: #2a1800; }
.game-card[data-game="rps"]       { --gc: #4cc9f0; --gcInk: #03212b; }
.game-card[data-game="draw"]      { --gc: #ff5c7a; --gcInk: #2b0010; }
.game-card[data-game="wyr"]       { --gc: #b68cf0; --gcInk: #1c0838; }
.game-card[data-game="trivia"]    { --gc: #ff8a3d; --gcInk: #2b1000; }
.game-card[data-game="unscramble"]{ --gc: #c8f169; --gcInk: #1a2600; }
.game-card[data-game="party"]     { --gc: #f6eef8; --gcInk: #240a3a; }
.game-card[data-game="party"] .gc-tag { background: #9b1c45; }
.game-card[data-game="party"] .gc-ico { background: rgba(124, 69, 196, .25); border-color: #240a3a; }
.game-card[data-game="party"] { border-color: #ffc247; }
@media (prefers-reduced-motion: reduce) { .game-card, .gc-ico { transition: none; } .game-card:hover, .game-card:hover .gc-ico { transform: none; } }

.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: #fff; 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 { box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.dg-color.on { border-color: #fff; box-shadow: 0 0 0 2px var(--rose); }
.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; }

/* How to play + back-to-chat (embedded games) */
.howto { margin: 14px 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.howto summary { cursor: pointer; padding: 14px 16px; min-height: 44px; font-weight: 700; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: '+'; font-size: 22px; color: var(--rose); }
.howto[open] summary::after { content: '\2212'; }
.howto ol { margin: 0; padding: 0 18px 16px 36px; color: var(--soft); }
.howto li { margin: 6px 0; }
.btn-back { min-height: 52px; font-size: 17px; }
body.embed { padding-bottom: 96px; }
body.embed .actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); display: flex; gap: 10px; }
body.embed .actions .btn { flex: 1; min-height: 52px; }

/* Themed game backgrounds: soft colour glow plus slowly floating symbols. Pure decoration. */
.panel { position: relative; z-index: 1; }
.bgfx { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background:
  radial-gradient(60% 45% at 15% 0%, var(--g1, rgba(194,37,95,.30)), transparent 70%),
  radial-gradient(55% 45% at 100% 100%, var(--g2, rgba(110,60,200,.30)), transparent 70%); }
.bgfx span { position: absolute; bottom: -60px; font-size: 28px; opacity: .13; animation: bgfloat 18s linear infinite; will-change: transform; }
@keyframes bgfloat { to { transform: translateY(-115vh) rotate(40deg); } }
body[data-game="tictactoe"] { --g1: rgba(255,107,154,.30); --g2: rgba(80,120,255,.28); }
body[data-game="connect4"] { --g1: rgba(255,200,60,.22); --g2: rgba(230,40,90,.30); }
body[data-game="rps"] { --g1: rgba(60,220,170,.22); --g2: rgba(255,120,60,.26); }
body[data-game="draw"] { --g1: rgba(255,120,200,.26); --g2: rgba(60,180,255,.26); }
body[data-game="wyr"] { --g1: rgba(190,90,255,.32); --g2: rgba(255,90,140,.26); }
body[data-game="trivia"] { --g1: rgba(80,160,255,.30); --g2: rgba(160,80,255,.28); }
body[data-game="unscramble"] { --g1: rgba(120,230,120,.22); --g2: rgba(255,170,60,.26); }
@media (prefers-reduced-motion: reduce) { .bgfx span { animation: none; bottom: auto; top: 30%; } }
