/* Sudoku — English Room Games */


:root {
  --bg: #1d2452;
  --bg-2: #252d63;
  --ink: #fff8e7;
  --muted: #b9c0ea;
  --muted-2: #8790c4;
  --line: rgba(255, 255, 255, .14);
  --gold: #ffc93c;
  --gold-dark: #c99a1c;
  --red: #ef6461;
  --red-dark: #b8393a;
  --yellow: #ffc93c;
  --yellow-dark: #c99a1c;
  --blue: #2f6fd8;
  --blue-dark: #1d4ea3;
  --display: 'Fredoka', 'Nunito', sans-serif;
  --body: 'Nunito', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body); color: var(--ink); background-color: var(--bg);
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%);
  background-size: 64px 64px; background-position: 0 0, 32px 32px;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: rgba(20, 26, 64, .8); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font: 700 26px var(--display); white-space: nowrap; }
.brand .site { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); text-decoration: none; white-space: nowrap; }
.brand .site:hover { color: var(--gold); }
.spacer { flex: 1; }
.iconbtn { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; text-decoration: none; }
.iconbtn:hover { color: var(--ink); border-color: var(--gold); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="false"] .wave { display: none; }

.controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 1rem; cursor: pointer; min-height: 44px; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,.13); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--gold); color: var(--bg); border-color: transparent; box-shadow: 0 4px 0 var(--gold-dark); font-family: var(--display); font-weight: 600; font-size: 1.12rem; }
.btn.primary:hover { background: #ffd35e; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-dark); }
.btn.wide { width: 100%; margin-top: 8px; }
.tip { margin: 0; color: var(--muted-2); font-size: .9rem; text-align: center; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 40, .75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 14px; }
.card { position: relative; width: min(480px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 30px 70px rgba(0,0,0,.5); }
.card h2 { margin: 0 0 6px; font: 700 2rem var(--display); }
.card h3 { margin: 16px 0 6px; font: 600 1.15rem var(--display); color: var(--gold); }
.card p { line-height: 1.5; margin: 0 0 12px; }
.card .big { font-size: 1.08rem; }
.kicker { font: 600 .8rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.kicker a { color: inherit; text-decoration: none; }
.close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
.field { margin-bottom: 14px; }
.label { display: flex; align-items: center; gap: 6px; font: 600 .8rem var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { text-align: left; padding: 11px 14px; border-radius: 14px; cursor: pointer; border: 2px solid var(--line); background: rgba(0,0,0,.25); }
.choice button b { display: block; font-size: 1.05rem; }
.choice button span { color: var(--muted); font-size: .88rem; }
.choice button[aria-pressed="true"] { border-color: var(--gold); background: rgba(255, 201, 60, .1); }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.names input { width: 100%; font: 700 1rem var(--body); color: var(--ink); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.names input:focus { outline: none; border-color: var(--gold); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: rgba(0,0,0,.25); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.steps { padding-left: 20px; margin: 4px 0; line-height: 1.55; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (max-width: 520px) {
  .brand .site { display: none; }
  .brand h1 { font-size: 22px; }
  .names { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media (max-width: 430px) {
  .topbar { gap: 7px; padding-left: 10px; padding-right: 10px; }
  .brand h1 { font-size: 19px; }
}

/* ---------- Sudoku ---------- */
.layout { --w: min(500px, calc(100vw - 20px), calc(100dvh - 300px)); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 10px 20px; }
.hud { display: flex; gap: 8px; width: var(--w); min-width: 290px; }
.hud div { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 5px 8px; border-radius: 12px; background: rgba(255,255,255,.07); border: 1px solid var(--line); }
.hud span { font: 600 .7rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hud b { font: 700 1.3rem var(--display); color: var(--gold); line-height: 1.1; white-space: nowrap; }
.board { --n: 4; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: repeat(var(--n), minmax(0, 1fr)); width: var(--w); height: var(--w); min-width: 290px; min-height: 290px; background: #1d2452; border: 3px solid #1d2452; border-radius: 12px; overflow: hidden; gap: 1px; box-shadow: 0 16px 34px rgba(0,0,0,.4); user-select: none; -webkit-user-select: none; }
.cell { position: relative; border: 0; padding: 0; min-width: 0; min-height: 0; background: #fff8e7; color: #1d2452; font: 700 var(--fs, 2rem) var(--display); cursor: pointer; display: grid; place-items: center; }
.cell.bx { border-right: 2px solid #1d2452; } .cell.by { border-bottom: 2px solid #1d2452; }
.cell.given { color: #1d2452; background: #f1e6c8; }
.cell.user { color: #2563eb; }
.cell.wrong { color: #dc2626; background: #fee2e2; }
.cell.peer { background: #fdf0c8; }
.cell.given.peer { background: #ecdcae; }
.cell.same { background: #fde68a; }
.cell.sel { background: #fcd34d; box-shadow: inset 0 0 0 3px #d97706; }
.cell.hinted { animation: hint .8s ease-out; }
@keyframes hint { 0% { background: #86efac; } 100% { } }
.cell:focus-visible { outline: none; box-shadow: inset 0 0 0 3px #2563eb; }
.notes { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(var(--nc, 2), 1fr); font: 700 var(--nfs, .7rem)/1 var(--body); color: #6b7280; pointer-events: none; }
.notes span { display: grid; place-items: center; }
.board.done .cell { animation: wave .6s ease-out both; }
@keyframes wave { 40% { background: #bbf7d0; transform: scale(1.06); } }
.pad { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; width: var(--w); min-width: 290px; }
.key { border: 0; border-radius: 12px; background: #3b4387; color: var(--ink); cursor: pointer; padding: 6px 0 5px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.key b { font: 700 1.6rem/1 var(--display); }
.key small { font: 700 .66rem var(--body); color: var(--muted); letter-spacing: .02em; }
.key:hover:not(:disabled) { background: #4f58a8; }
.key:active:not(:disabled) { transform: translateY(2px); }
.key:disabled { opacity: .3; cursor: default; }
.pad.notes-on .key { background: #4c1d95; }
.tools { display: flex; gap: 6px; width: var(--w); min-width: 290px; }
.btn.tool { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; min-height: 52px; font-size: .78rem; }
.btn.tool[aria-pressed="true"] { background: #7c3aed; border-color: #a78bfa; }
.seg.four { grid-template-columns: repeat(4, 1fr); }
.seg button small { display: block; font-size: .7rem; font-weight: 700; opacity: .75; }
.card .btn.wide + .btn.wide { margin-top: 10px; }
@media (max-width: 420px) { .key b { font-size: 1.3rem; } .key small { font-size: .58rem; } .btn.tool span { font-size: .7rem; } }
.cell.wrong.peer, .cell.wrong.same { background: #fee2e2; }
