:root {
  --ink: #18191b;
  --muted: #555a61;
  --line: #d7d9dc;
  --accent: #dce3ef;
  --peer: #f1f4f8;
  --paper: #fff;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--ink);
  background: var(--paper);
  font-family: "Inter", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: transparent; border: 0; padding: 0; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
i { display: inline-flex; }
svg { width: 18px; height: 18px; }
h1, h2, h3, p { margin: 0; }
h2, h3 { font-size: 16px; letter-spacing: -.04em; }
main, .masthead { width: min(500px, calc(100% - 32px)); margin-inline: auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; padding: clamp(24px,5vh,52px) 0 20px; }
h1 { font: 400 clamp(46px,7vw,68px)/1 "Baskervville", Georgia, "Times New Roman", serif; letter-spacing: -.065em; }
nav, .timer, .board-head, #levels, .progress-label, .rank-head, .rank-fields { display: flex; align-items: center; }
nav { gap: 4px; }
nav button, .timer button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
nav button:hover, .timer button:hover { background: var(--peer); }
nav svg { width: 20px; height: 20px; }
.board-head { justify-content: space-between; border-top: 1px solid var(--line); padding-block: 6px; }
#levels { gap: 3px; }
#levels button { min-height: 40px; padding: 0 12px; font-size: 13px; color: var(--muted); }
#levels .active { color: var(--ink); font-weight: 700; background: linear-gradient(var(--ink),var(--ink)) center bottom 5px / 14px 2px no-repeat; }
.timer { font: 500 13px var(--mono); gap: 1px; }
.timer svg { width: 15px; height: 15px; }
#rank-mode { margin-bottom: 8px; font-size: 13px; }
.board-wrap { position: relative; }
#board { display: grid; grid-template: repeat(9,minmax(0,1fr)) / repeat(9,minmax(0,1fr)); aspect-ratio: 1; border: 1.5px solid var(--ink); }
.cell {
  position: relative; display: grid; place-items: center;
  min-width: 0; min-height: 0; border-right: 1px solid #dfe1e4; border-bottom: 1px solid #dfe1e4;
  font: 400 clamp(21px, 5.8vw, 30px)/1 "Inter", Arial, sans-serif; border-radius: 0;
}
.cell:nth-child(3n) { border-right: 1.5px solid #51545a; }
.cell:nth-child(9n) { border-right: 0; }
.cell.block-end { border-bottom: 1.5px solid #51545a; }
.cell.last-row { border-bottom: 0; }
.cell:focus-visible { outline-offset: -4px; z-index: 1; }
.peer { background: var(--peer); }
.match { background: var(--accent); }
.cell.selected { background: var(--accent); box-shadow: inset 0 0 0 1.5px #697b95; }
.cell.user { color: #35455c; font-weight: 450; }
.cell.error { text-decoration: underline wavy; text-underline-offset: 3px; }
.notes { display: grid; grid-template-columns: repeat(3,1fr); width: 92%; height: 94%; align-items: center; font: 500 clamp(8px,1vw,12px)/1 var(--mono); }
#cover { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; background: var(--accent); }
#cover-title { font-size: 22px; }
#cover button, #confirm, .new { border-radius: 5px; background: var(--ink); color: white; font-weight: 700; padding: 12px 18px; }
#result { font-weight: 650; text-align: center; padding: 0 10px; }
.progress-label { margin: 10px 0 7px; color: var(--muted); font-size: 12px; }
#percent { font-family: var(--mono); color: var(--ink); }
.track { height: 2px; background: var(--peer); }
#progress { height: 100%; background: #8c99aa; }
#pad { display: grid; grid-template-columns: repeat(9,minmax(0,1fr)); gap: clamp(2px,.6vw,6px); margin: 20px 0 12px; }
#pad button { font: 400 clamp(24px,5vw,29px)/1 "Inter", Arial, sans-serif; background: #f3f4f6; border-radius: 8px; min-height: clamp(46px,9vw,58px); }
#pad button:active, .tools button[aria-pressed=true] { background: var(--accent); }
@media (hover:hover) { #pad button:hover { background: var(--accent); } }
.tools { display: grid; grid-template-columns: repeat(4,1fr); padding-block: 4px; }
.tools button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border-radius: 6px; font-size: 13px; }
.tools button:hover:enabled { background: var(--peer); }
.tools svg { width: 16px; height: 16px; }
.progress-label { justify-content: space-between; }
.new { width: 100%; }
#status { min-height: 30px; margin: 12px 0; text-align: center; color: var(--muted); font-size: 13px; }
dialog { max-width: min(380px,92vw); padding: 24px; color: var(--ink); background: white; border: 1px solid var(--ink); border-radius: 8px; }
dialog::backdrop { background: #15191f70; }
dialog p { white-space: pre-line; font-size: 14px; line-height: 1.65; margin: 12px 0; }
.actions { display: flex; justify-content: flex-end; gap: 15px; }
#rank-dialog { width: 430px; max-width: calc(100vw - 24px); max-height: 90dvh; overflow: auto; }
.rank-head { justify-content: space-between; }
.rank-head h2 { font-size: 21px; }
.rank-head button { font-size: 24px; width: 38px; height: 38px; }
.rank-desc, #rank-form p { font-size: 13px; color: var(--muted); }
.rank-list-wrap { max-height: 28vh; overflow: auto; }
#rank-dialog table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
#rank-dialog td, #rank-dialog th { padding: 7px 4px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#rank-dialog th { background: var(--accent); font-size: 12px; }
.rank-fields { align-items: end; gap: 10px; }
.rank-fields label { display: grid; gap: 4px; font-size: 13px; }
.rank-fields label:first-child { flex: 1; min-width: 0; }
.rank-fields input, .rank-fields select { width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 9px; background: white; font-size: 16px; }
#rank-form { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
#rank-form details { font-size: 13px; margin-bottom: 14px; }
#rank-form summary { cursor: pointer; }
#rank-error:empty { display: none; }
#challenge { margin-top: 14px; }
@media (max-width: 410px) {
  #levels button { padding-inline: 9px; }
  .tools button { flex-direction: column; gap: 4px; min-height: 48px; font-size: 11px; }
}
