:root { --ink:#3b2a28; --ink2:#7a6a67; --page:#fdfcfa; --hair:#e4dedb; --blue:#1f5f8b; --soft:#eef2f5; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--page); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
.app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 6px; border-bottom: 1px solid var(--hair); background: var(--page); }
h1 { margin: 0; font-size: 22px; line-height: 1.1; font-weight: 700; }
.top p { margin: 2px 0 0; font-size: 12px; color: var(--ink2); }
.time { font-variant-numeric: tabular-nums; font-size: 18px; padding: 5px 12px; border-radius: 999px; background: var(--soft); }
.stage { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; padding: 8px 12px; }
.boardwrap { min-height: 0; min-width: 0; container-type: size; display: grid; place-items: center; }
.grid { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.cell { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; font-size: clamp(16px, 4.6cqmin, 40px); color: var(--blue); border-right: 1px solid var(--hair); border-bottom: 1px solid var(--hair); cursor: pointer; touch-action: manipulation; background: var(--page); container-type: size; }
.cell.bR { border-right: 2px solid var(--ink); } .cell.bB { border-bottom: 2px solid var(--ink); }
.cell:nth-child(9n) { border-right: 0; } .cell:nth-child(n+73) { border-bottom: 0; }
.cell.given { color: var(--ink); font-weight: 700; }
.cell.peer { background: var(--soft); } .cell.same { background: #d8e6ef; }
.cell.sel { background: #bcd7e8; box-shadow: inset 0 0 0 2px var(--blue); }
.cell.conf { color: #b3261e; } .cell.wrong { background: #f6d5d2; }
.cell:focus-visible, button:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }
.cell .v { font-size: 62cqmin; line-height: 1; }
.notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; text-align: center; align-items: center; color: var(--ink2); font-size: 26cqmin; line-height: 1; padding: 2px; }
.notes i { font-style: normal; }
.side { display: grid; gap: 8px; }
.pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.key { all: unset; box-sizing: border-box; position: relative; display: flex; align-items: center; justify-content: center; height: clamp(44px, 7.5dvh, 60px); border: 1px solid var(--hair); border-radius: 10px; background: #fff; font-size: 22px; cursor: pointer; touch-action: manipulation; }
.key small { position: absolute; right: 4px; bottom: 2px; font-size: 10px; color: var(--ink2); }
.key:active { background: #bcd7e8; } .key:disabled { opacity: .3; cursor: default; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tools button { all: unset; box-sizing: border-box; text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--soft); cursor: pointer; font-size: 15px; touch-action: manipulation; }
.tools button[aria-pressed="true"] { background: var(--blue); color: #fff; } .tools button:disabled { opacity: .4; cursor: default; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 16px 8px; border-top: 1px solid var(--hair); font-size: 13px; color: var(--ink2); }
.link { all: unset; cursor: pointer; text-decoration: underline; color: var(--ink); min-height: 32px; display: inline-flex; align-items: center; }
@media (min-aspect-ratio: 6/5) and (min-width: 560px) {
  .stage { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) minmax(220px, 340px); gap: 20px; padding: 12px 20px; align-items: stretch; }
  .side { align-content: center; }
  .pad { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .key { height: clamp(48px, 11dvh, 72px); font-size: 26px; }
}
@media (max-width: 340px) { .key { font-size: 18px; } }
@media (max-width: 460px) { .key small { display: none; } }
@media (display-mode: standalone) { .foot { padding-bottom: 10px; } }
#ad-slot { height: 50px; margin: 0 12px 4px; display: grid; place-items: center; border-radius: 6px; background: var(--soft); font-size: 11px; color: var(--ink2); overflow: hidden; }
