:root {
  color-scheme: light;
  --canvas: #f5f5ec;
  --paper: #fffefa;
  --ink: #153d32;
  --muted: #53685f;
  --line: #dce3d5;
  --lime: #e5eedb;
  --orange: #f8b686;
  --wrong: #a52c29;
  font-family: system-ui, "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible { outline: 2px solid #a85331; outline-offset: 3px; }
.shell { max-width: 1060px; margin: auto; padding: 0 24px; }
.masthead, footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.masthead { min-height: 84px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { font-size: 17px; letter-spacing: .06em; }
.brand small { display: block; font-size: 9px; color: var(--muted); letter-spacing: .18em; margin-top: 2px; font-weight: 800; }
.connection { display: flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; }
.connection i, .eyebrow span { display: inline-grid; place-items: center; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #af7856; }
.connection.online i { background: #519465; }
main { padding: 32px 0; }
.layout { display: grid; gap: 20px; }
.intro { display: flex; flex-direction: column; padding: 24px; border-radius: 24px; background: var(--ink); color: #f3f4e7; overflow: hidden; }
.eyebrow { font-size: 11px; letter-spacing: .14em; font-weight: 800; }
.eyebrow span { width: 25px; height: 25px; border: 1px solid #7b9c88; border-radius: 7px; margin-right: 5px; font-size: 9px; }
h1, h2, p { margin: 0; }
.intro h1 { font-size: clamp(34px, 6vw, 69px); letter-spacing: -.07em; line-height: 1.15; margin: 19px 0 14px; }
.intro em { color: #f6b98e; font-style: normal; }
.intro p { font-size: 14px; line-height: 1.75; color: #d2e4d8; }
.illustration { display: none; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.entry .eyebrow, .waiting .eyebrow, .stats-card .eyebrow { color: #56725e; }
.entry h2 { margin: 9px 0 6px; font-size: 30px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }
.nickname-note { color: var(--muted); font-size: 11px; line-height: 1.4; margin-top: 5px; }
form { margin-top: 24px; }
form label { display: block; font-size: 13px; font-weight: 750; margin-bottom: 8px; }
input { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fafbf6; color: var(--ink); min-height: 48px; padding: 0 13px; }
input::placeholder { color: #65746b; }
.tabs, .difficulty { display: flex; gap: 6px; }
.tabs { background: #eef1e7; border-radius: 10px; padding: 4px; margin: 20px 0; }
.tabs button, .difficulty button { flex: 1; min-height: 40px; border-radius: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.tabs button { border: none; background: transparent; }
.tabs button[aria-pressed="true"] { background: white; box-shadow: 0 1px 4px #244e311a; }
.difficulty button { border: 1px solid var(--line); background: transparent; }
.difficulty button[aria-pressed="true"] { border-color: #8da98c; background: var(--lime); }
.primary, .secondary, .text-button { border: 0; border-radius: 10px; min-height: 44px; font-weight: 780; color: var(--ink); }
.primary { display: flex; align-items: center; justify-content: space-between; width: 100%; background: var(--ink); color: #fff; padding: 0 15px; margin-top: 20px; min-height: 48px; }
.primary span { color: var(--orange); }
.primary:hover:not(:disabled) { background: #24604e; }
#practice-entry { margin-top: 22px; }
#practice-entry p { margin-top: 6px; }
.secondary { background: var(--lime); padding: 0 12px; }
.text-button { background: transparent; padding: 0 8px; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.notice { background: #faecd9; border: 1px solid #eddac4; border-radius: 10px; padding: 10px 13px; font-size: 14px; margin-bottom: 15px; }
.error { background: #f9e8e3; border-color: #f0d0c7; color: var(--wrong); }
.room-heading { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.room-heading h1 { font-size: clamp(28px, 6vw, 43px); line-height: 1.23; margin-top: 4px; }
.room-links { display: flex; gap: 4px; font-size: 13px; }
.series { color: var(--muted); font-size: 13px; font-weight: 750; margin: 0 0 12px; overflow-wrap: anywhere; }
.waiting { max-width: 570px; margin-inline: auto; }
.room-code { font-size: clamp(48px, 10vw, 80px); letter-spacing: .08em; line-height: 1.15; margin: 8px 0; font-weight: 790; font-variant-numeric: tabular-nums; }
.seats { display: grid; gap: 7px; margin-top: 16px; }
.seat { display: flex; justify-content: space-between; gap: 10px; background: var(--canvas); border-radius: 8px; padding: 10px 12px; font-size: 14px; overflow-wrap: anywhere; }
.seat span:last-child { color: var(--muted); flex-shrink: 0; }
.board-panel { padding: 11px; }
.board-heading { display: flex; align-items: center; gap: 10px; margin: 0 2px 8px; }
.board-heading .eyebrow { margin-right: auto; }
.board-heading time { font-size: 18px; font-weight: 790; font-variant-numeric: tabular-nums; }
#notes { font-size: 13px; }
#notes[aria-pressed="true"] { background: var(--ink); color: #fff; }
.board-wrap { position: relative; }
.board { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); border: 2px solid var(--ink); border-radius: 5px; overflow: hidden; }
.cell { aspect-ratio: 1; container-type: inline-size; padding: 0; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); color: #347655; font-size: clamp(16px, 4.5vw, 30px); font-weight: 700; }
.cell:nth-child(3n):not(:nth-child(9n)) { border-right: 2px solid var(--ink); }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+19):nth-child(-n+27), .cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--ink); }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell.given { color: var(--ink); background: #f0f2e9; }
.cell.related { background: #e6f0df; }
.cell.same { background: #c9dfc4; }
.cell:focus-visible { outline-offset: -3px; }
.cell.wrong { color: var(--wrong); background: #fde3df; }
.cell.selected { background: #ffd1a4; color: #142f24; box-shadow: inset 0 0 0 2px #703b26; }
.cell.selected.wrong { color: var(--wrong); }
.pencil-marks { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; width: 100%; height: 100%; padding: 2px; font-size: clamp(9px, 2.3vw, 12px); font-size: min(12px, 27cqi); font-weight: 750; line-height: 1; }
.board.unrevealed { visibility: hidden; }
.countdown { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #fff; background: #153d32ef; border-radius: 5px; }
.countdown strong { font-size: clamp(70px, 18vw, 120px); line-height: 1.1; color: var(--orange); }
.pad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; margin-top: 10px; }
.pad button { min-height: 44px; padding: 0; color: var(--ink); font-weight: 780; background: var(--lime); border: 0; border-radius: 7px; font-size: clamp(16px, 4vw, 23px); }
.pad button:hover:not(:disabled) { background: #c9dfc4; }
.pad button.completed { background: #f0f2ea; color: #596a61; }
.board-help { color: var(--muted); font-size: 12px; padding: 8px 2px 3px; }
.duel-strip { display: flex; overflow-x: auto; gap: 7px; margin-bottom: 5px; padding-bottom: 4px; }
.duel-strip .stat { flex: 0 0 calc((100% - 7px) / 2); }
.practice .duel-strip { display: grid; grid-template-columns: 1fr; }
.duel-strip .stat { min-width: 0; margin: 0; padding: 6px 8px; border-radius: 8px; background: var(--canvas); }
.duel-strip .stat-top { display: grid; gap: 1px; font-size: 12px; }
.duel-strip .stat-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-strip progress { height: 4px; margin-top: 4px; }
.side { display: grid; gap: 12px; align-content: start; }
.stats-card h2 { margin: 5px 0 15px; }
.stat { margin-bottom: 15px; }
.stat-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; overflow-wrap: anywhere; }
.stat-top span { color: var(--muted); font-size: 12px; flex-shrink: 0; }
progress { display: block; width: 100%; height: 8px; margin-top: 7px; border: 0; border-radius: 9px; overflow: hidden; background: #ebeee5; color: #548665; }
progress::-webkit-progress-bar { background: #ebeee5; }
progress::-webkit-progress-value { background: #548665; }
progress::-moz-progress-bar { background: #548665; }
.mini { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 2px; max-width: 170px; }
.mini span { aspect-ratio: 1; background: #f1f3eb; border-radius: 2px; }
.mini .clue, .legend i { background: #d3ddcf; }
.mini .filled, .legend span:nth-child(2) i { background: #548665; }
.legend { display: flex; gap: 13px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
.result { position: relative; isolation: isolate; overflow: hidden; background: var(--ink); color: #fff; }
.result.loss { background: #4d3837; }
.result.loss h2 { color: #ffd5c6; }
.result h2 { margin: 4px 0; font-size: 39px; color: var(--orange); }
.result p { font-size: 14px; }
.result dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.result dt { overflow-wrap: anywhere; }
.result dd { margin: 0; font-variant-numeric: tabular-nums; }
.result .primary { background: var(--lime); color: var(--ink); }
.result .primary:hover:not(:disabled) { background: #c9dfc4; }
.result .primary span { color: var(--ink); }
#rematch-note { margin-top: 10px; color: #ffdfbc; font-weight: 750; }
#result-dialog { width: min(420px, calc(100% - 32px)); max-height: calc(100% - 24px); padding: 0; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: var(--paper); }
#result-dialog::backdrop { background: #122d26a8; }
#result-dialog form { display: flex; justify-content: flex-end; margin: 0; padding: 0 9px; }
#result-dialog .result { border-radius: 15px; margin: 0 5px 5px; }
.confetti { display: none; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.result.win .confetti { display: block; }
.confetti i { position: absolute; left: var(--x); top: 7%; width: 5px; height: 10px; border-radius: 2px; opacity: 0; background: var(--orange); animation: confetti 1s var(--delay) ease-out both; }
.confetti i:nth-child(1) { --x: 12%; --delay: 0ms; }
.confetti i:nth-child(2) { --x: 27%; --delay: 80ms; background: #b9daba; }
.confetti i:nth-child(3) { --x: 43%; --delay: 20ms; }
.confetti i:nth-child(4) { --x: 64%; --delay: 90ms; }
.confetti i:nth-child(5) { --x: 81%; --delay: 120ms; background: #b9daba; }
.confetti i:nth-child(6) { --x: 93%; --delay: 40ms; }
@keyframes confetti {
  10% { opacity: .75; }
  100% { transform: translateY(130px) rotate(125deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .confetti i { animation: none; } }
.tip { font-size: 12px; color: var(--muted); text-align: center; }
.practice .tip { display: none; }
footer { border-top: 1px solid var(--line); padding: 16px 0 24px; color: var(--muted); font-size: 10px; }
@media (max-width: 560px) {
  .shell { padding: 0 13px; }
  .masthead { min-height: 62px; }
  main { padding: 17px 0; }
  .room-heading { margin-bottom: 8px; }
  .board-wrap { width: 100%; margin-inline: auto; }
}
@media (max-width: 440px) and (max-height: 700px) {
  .masthead { min-height: 50px; }
  .brand img { width: 34px; height: 34px; }
  main { padding-top: 9px; }
  .room-heading { margin-bottom: 4px; }
  .room-heading h1 { font-size: 24px; }
  .series { margin-bottom: 6px; }
  .board-panel { padding: 7px 10px; }
  .board-heading { margin-bottom: 4px; }
  .board-wrap { width: 100%; margin-inline: auto; }
  .duel-strip .stat { padding-block: 4px; }
  .pad { margin-top: 6px; }
}
@media (min-width: 760px) {
  main { padding: 44px 0; }
  .lobby { grid-template-columns: 1.15fr 1fr; gap: 26px; }
  .intro, .entry { padding: 34px; }
  .entry { align-self: start; }
  .illustration { display: block; margin: 28px 0 0 auto; width: min(230px, 65%); }
  .art-caption { display: flex; justify-content: space-between; font-size: 9px; letter-spacing: .14em; color: #d0e3d4; margin-bottom: 6px; }
  .art-grid { border: 1px solid #719483; border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: repeat(3, 1fr); background: #719483; gap: 1px; }
  .art-grid span { min-height: 38px; display: grid; place-items: center; background: #204d3f; color: #d8e8d9; font-size: 20px; font-weight: 750; }
  .art-grid .art-accent { background: var(--orange); color: var(--ink); }
  .match { grid-template-columns: minmax(0, 1.65fr) minmax(260px, 1fr); gap: 25px; align-items: start; }
  .board-panel { padding: 17px; }
  .duel-strip { display: none; }
  .pad { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}
