@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;800&family=Nunito:wght@400;600;800&display=swap');

:root {
  --bg: #fff6ea;
  --bg-2: #ffe9cf;
  --panel: #ffffff;
  --ink: #2a1f3d;
  --muted: #6f6485;
  --line: #ecdcc6;
  --brand: #ff6b2c;
  --brand-ink: #2a1f3d;
  --brand-text: #b3400f;
  --accent: #1fb5a6;
  --good: #19a35b;
  --bad: #c92a3e;
  --warn: #f2a516;
  --shadow: 0 6px 0 rgba(42, 31, 61, 0.12);
  --c-r: #e94545;
  --c-y: #f5b70a;
  --c-g: #26a65b;
  --c-b: #2f7de1;
  --c-w: #2a1f3d;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1428; --bg-2: #241c38; --panel: #2a2140; --ink: #f6efe6; --muted: #b5aacb;
    --line: #3d3259; --shadow: 0 6px 0 rgba(0, 0, 0, 0.35); --c-w: #0e0a18; --brand-text: #ff8a52; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1428; --bg-2: #241c38; --panel: #2a2140; --ink: #f6efe6; --muted: #b5aacb;
  --line: #3d3259; --shadow: 0 6px 0 rgba(0, 0, 0, 0.35); --c-w: #0e0a18; --brand-text: #ff8a52; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(circle at 10% 0%, var(--bg-2) 0, transparent 40%),
    radial-gradient(circle at 100% 100%, var(--bg-2) 0, transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.45 Nunito, system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, .display { font-family: 'Baloo 2', Nunito, sans-serif; line-height: 1.1; margin: 0 0 .4em; }
h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); font-weight: 800; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
a { color: var(--brand-text); }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.btn {
  font: 800 1rem Nunito, sans-serif;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform .08s, box-shadow .08s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: #d9531a; color: var(--brand-ink); box-shadow: 0 4px 0 #c24a14; }
.btn.accent { background: var(--accent); border-color: #148c80; color: #2a1f3d; box-shadow: 0 4px 0 #117a70; }
.btn.danger { background: var(--bad); border-color: #b7243a; color: #fff; box-shadow: 0 4px 0 #9c1f31; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .9rem; border-radius: 10px; }
.btn.big { min-height: 60px; font-size: 1.2rem; padding: 12px 28px; }
.btn.full { width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type=text], input[type=number], input[type=password], select {
  font: 600 1rem Nunito, sans-serif;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
label { font-weight: 800; display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 160px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; background: var(--bg-2);
  font-weight: 800; font-size: .9rem; border: 2px solid var(--line);
}
.chip button { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 0 2px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 14px;
  font-weight: 800; z-index: 100; max-width: calc(100% - 32px); text-align: center;
  animation: pop .2s ease-out;
}
@keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } }

.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo b { font-family: 'Baloo 2'; font-size: 1.5rem; font-weight: 800; }
.logo .dots { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.logo .dots i { width: 10px; height: 10px; border-radius: 3px; display: block; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 28px 0 10px; }
.hero p { font-size: 1.15rem; max-width: 520px; margin: 0 auto; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-top: 24px; }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-family: 'Baloo 2'; font-size: 1.4rem !important; text-align: center; }
.game-strip { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.game-strip .chip { font-size: 1rem; padding: 8px 14px; }

/* ---------- Room layout ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; max-width: 1100px; margin: 0 auto; }
.room-code { font-family: 'Baloo 2'; font-weight: 800; letter-spacing: .15em; font-size: 1.3rem; }
.layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
@media (max-width: 760px) {
  .players { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 4px; }
}
.player { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--bg); font-weight: 800; }
.player.away { opacity: .5; }
.player .you { font-size: .75rem; color: var(--muted); font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: 'Baloo 2'; font-size: 1rem; flex: none; }
.crown { font-size: .9rem; }

.games-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.game-card { text-align: left; padding: 16px; border-radius: var(--radius); border: 3px solid var(--line); background: var(--bg); cursor: pointer; font: inherit; color: inherit; }
.game-card.on { border-color: var(--brand); background: var(--panel); box-shadow: var(--shadow); }
.game-card:disabled { cursor: default; }
.game-card .emoji { font-size: 2rem; }
.game-card.soon { opacity: .55; }

/* ---------- Colour Clash cards ---------- */
.card {
  --w: 74px;
  width: var(--w); height: calc(var(--w) * 1.48);
  border-radius: calc(var(--w) * .16);
  background: var(--cc, var(--c-w));
  border: calc(var(--w) * .06) solid #fff;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25), 0 0 0 1px rgba(0, 0, 0, .15);
  position: relative; flex: none; color: #fff;
  font-family: 'Baloo 2'; font-weight: 800;
  display: grid; place-items: center;
  padding: 0; cursor: default;
  transition: transform .12s;
}
.card .face {
  width: 72%; aspect-ratio: 1; border-radius: 50%;
  background: #fff; color: var(--cc, var(--c-w));
  display: grid; place-items: center;
  font-size: calc(var(--w) * .42);
  box-shadow: inset 0 0 0 calc(var(--w) * .04) rgba(0, 0, 0, .08);
}
.card .corner { position: absolute; top: 3px; left: 7px; font-size: calc(var(--w) * .2); line-height: 1; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.card .corner.br { top: auto; left: auto; bottom: 3px; right: 7px; transform: rotate(180deg); }
.card.c-r { --cc: var(--c-r); } .card.c-y { --cc: var(--c-y); } .card.c-g { --cc: var(--c-g); } .card.c-b { --cc: var(--c-b); }
.card.c-w .face { background: conic-gradient(var(--c-r) 0 25%, var(--c-y) 0 50%, var(--c-g) 0 75%, var(--c-b) 0); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.card.back { background: repeating-linear-gradient(45deg, #3a2a63 0 8px, #4a3878 8px 16px); }
.card.back .face { background: var(--brand); color: #fff; font-size: calc(var(--w) * .22); width: 80%; aspect-ratio: 1.4; border-radius: 40%; transform: rotate(-12deg); }
button.card { cursor: pointer; }
button.card.playable:hover, button.card.playable:focus-visible { transform: translateY(-10px); }
button.card.playable { transform: translateY(-6px); }
button.card.dim { filter: saturate(.35) brightness(.85); }

.cc-table { display: grid; gap: 14px; }
.opps { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.opp { background: var(--bg); border: 3px solid transparent; border-radius: 16px; padding: 8px 12px; text-align: center; min-width: 96px; }
.opp.turn { border-color: var(--brand); background: var(--panel); box-shadow: var(--shadow); }
.opp .n { font-weight: 800; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .count { font-family: 'Baloo 2'; font-size: 1.4rem; font-weight: 800; }
.minicards { display: flex; justify-content: center; height: 22px; }
.minicards i { width: 14px; height: 20px; border-radius: 3px; background: #4a3878; border: 1.5px solid #fff; margin-left: -6px; }
.minicards i:first-child { margin-left: 0; }
.uno-badge { background: var(--bad); color: #fff; border-radius: 8px; padding: 0 6px; font-size: .8rem; font-weight: 800; }

.center { display: flex; align-items: center; justify-content: center; gap: 26px; padding: 18px 0; position: relative; }
.center .card { --w: 96px; }
.pile { position: relative; }
.ring { position: absolute; inset: -12px; border-radius: 26px; border: 6px solid var(--ring, transparent); pointer-events: none; }
.dir { font-size: 2rem; color: var(--muted); }
.pending { background: var(--bad); color: #fff; font-family: 'Baloo 2'; font-weight: 800; border-radius: 12px; padding: 2px 10px; position: absolute; top: -14px; right: -14px; font-size: 1.2rem; }
.status { text-align: center; font-family: 'Baloo 2'; font-size: 1.4rem; font-weight: 800; min-height: 1.6em; }
.status.mine { color: var(--brand-text); }
.hand { display: flex; gap: 6px; overflow-x: auto; padding: 16px 8px 10px; justify-content: safe center; }
.hand .card { --w: 70px; }
@media (max-width: 500px) { .hand .card { --w: 58px; } .center .card { --w: 80px; } }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.log { font-size: .9rem; color: var(--muted); text-align: center; min-height: 1.4em; }

.picker { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.picker button { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; cursor: pointer; box-shadow: var(--shadow); }

.overlay { position: fixed; inset: 0; background: rgba(20, 12, 35, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay .panel { max-width: 440px; width: 100%; text-align: center; animation: pop2 .25s ease-out; }
@keyframes pop2 { from { transform: scale(.9); opacity: 0; } }
.scores { list-style: none; padding: 0; margin: 12px 0; text-align: left; }
.scores li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; font-weight: 800; }
.scores li:nth-child(odd) { background: var(--bg); }
.scores li.first { background: #fff1c2; color: #5b3d00; }

/* ---------- NPAT ---------- */
.letter {
  font-family: 'Baloo 2'; font-weight: 800; font-size: 5rem; line-height: 1;
  width: 120px; height: 120px; border-radius: 30px; display: grid; place-items: center;
  background: var(--brand); color: #2a1f3d; box-shadow: 0 8px 0 #c24a14; margin: 0 auto;
}
.letter.spin { animation: spin .7s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes spin { from { transform: rotate(-360deg) scale(.3); } }
.timer { font-family: 'Baloo 2'; font-size: 2rem; font-weight: 800; text-align: center; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.progress { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.letters button { font: 800 1.4rem 'Baloo 2'; min-height: 52px; }
.review { width: 100%; border-collapse: separate; border-spacing: 4px; }
.review-wrap { overflow-x: auto; }
.review th { font-family: 'Baloo 2'; text-align: left; padding: 4px 8px; white-space: nowrap; }
.review td { background: var(--bg); border-radius: 10px; padding: 6px 8px; min-width: 120px; vertical-align: top; border: 2px solid transparent; }
.review td.ok { border-color: var(--good); }
.review td.no { border-color: var(--bad); opacity: .75; }
.review td .a { font-weight: 800; word-break: break-word; }
.review td .a:empty::before { content: '—'; color: var(--muted); }
.review td.no .a { text-decoration: line-through; }
.vote { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.vote button { min-height: 32px; min-width: 36px; padding: 0 8px; border-radius: 8px; border: 2px solid var(--line); background: var(--panel); cursor: pointer; font-size: .9rem; color: var(--ink); }
.vote button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.vote .tally { font-size: .8rem; color: var(--muted); }
.vote .host { border-style: dashed; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.stack { display: grid; gap: 16px; }
.hidden { display: none !important; }
