:root {
  --bg: #EEEBE5; --wall: #DCD8D0; --panel: #FFFFFF; --line: #C9C4BA; --ink: #1C1D20; --ink-sub: #5C5952;
  --accent: #FF5A1F; --best: #1F8A5B; --danger: #E0452B; --yellow: #F2C230;
  --mat-stone: #C9C2B4; --mat-stone-e: #8E877A; --mat-copper: #C2693A; --mat-copper-e: #7E3E1F; --mat-iron: #3F4650; --mat-iron-e: #262A30;
  --sans: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
a { color: var(--ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.app { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto 1fr auto; grid-template-areas: "bar" "word" "stage" "tools"; }
.app[data-mode="title"] { grid-template: "stage" 1fr / 1fr; }
.app[data-mode="title"] .bar, .app[data-mode="title"] .tools, .app[data-mode="title"] .word { display: none; }
.app[data-mode="test"] .tools, .app[data-mode="test"] .word { display: none; }
.bar { grid-area: bar; display: flex; align-items: center; gap: 8px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px; background: var(--panel); border-bottom: 3px solid var(--ink); min-height: 52px; }
.ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; background: transparent; border-radius: 2px; color: var(--ink-sub); }
.ic:hover { background: var(--bg); color: var(--ink); }
.ic svg { width: 22px; height: 22px; }
#soundBtn .mute { display: none; }
#soundBtn[aria-pressed="false"] .mute { display: inline; }
#soundBtn[aria-pressed="false"] .wave { display: none; }
.st { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.st b { font-size: 11px; font-weight: 800; color: var(--ink-sub); letter-spacing: .04em; }
.st span { font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.best { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; border-left: 4px solid var(--accent); padding-left: 8px; }
.best small { font-size: 10px; color: var(--ink-sub); font-weight: 700; }
.best b { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.word { grid-area: word; padding: 8px 10px; background: var(--panel); border-bottom: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot { position: relative; border: 2px solid var(--ink); border-radius: 2px; padding: 2px 4px 4px; display: flex; flex-direction: column; align-items: center; background: var(--c); box-shadow: inset 0 6px 0 var(--l), inset 0 -6px 0 var(--e), 3px 3px 0 rgba(28,29,32,.25); min-height: 66px; }
.slot::before { content: attr(data-mat); position: absolute; left: 4px; top: 4px; font-size: 10px; font-weight: 900; opacity: .7; }
.slot b { font-size: 34px; line-height: 1.15; font-weight: 900; min-height: 39px; }
.slot small { font-size: 11px; font-weight: 800; opacity: .85; min-height: 15px; }
.slot.k0 { --c: var(--mat-stone); --e: var(--mat-stone-e); --l: #E4DED2; background-image: radial-gradient(#6F6A62 1px, transparent 1.5px); background-size: 9px 9px; background-color: var(--c); }
.slot.k1 { --c: var(--mat-copper); --e: var(--mat-copper-e); --l: #E8A275; background-image: repeating-linear-gradient(0deg, rgba(169,85,44,.45) 0 1px, transparent 1px 6px); background-color: var(--c); }
.slot.k2 { --c: var(--mat-iron); --e: var(--mat-iron-e); --l: #7A8593; color: #FFFFFF; background-image: radial-gradient(circle at 8px 8px, #59626E 3px, transparent 3.5px), radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), #59626E 3px, transparent 3.5px); background-color: var(--c); }
.slot.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.inrow { display: flex; gap: 6px; }
#chars { flex: 1; min-width: 0; height: 40px; border: 2px solid var(--ink); border-radius: 2px; padding: 0 10px; font: 700 16px var(--sans); color: var(--ink); background: #FFFFFF; }
#chars:focus { outline: 3px solid var(--accent); outline-offset: 0; }
#chars:disabled { opacity: .5; }
.locked { margin: 0; font-size: 12px; color: var(--ink-sub); font-weight: 700; }
.stage { grid-area: stage; position: relative; overflow: hidden; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.toast { position: absolute; left: 50%; top: 10px; transform: translate(-50%, -10px); background: #FFFFFF; border: 2px solid var(--ink); border-radius: 2px; padding: 7px 14px; font-size: 14px; font-weight: 800; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 24px); text-align: center; z-index: 5; box-shadow: 3px 3px 0 var(--ink); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--danger); color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: var(--ink); color: #FFFFFF; border-left: 6px solid var(--accent); padding: 8px 14px; max-width: min(92%, 420px); font-size: 14px; font-weight: 800; z-index: 3; pointer-events: none; }
.hint p { margin: 0; }
.hud { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; z-index: 2; }
.hud-load { margin: 0; font: 900 60px/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-shadow: 0 0 10px var(--wall); }
.hud-load small { font-size: 24px; margin-left: 3px; }
.hud-load.warn { color: #B4361B; }
.hud-load.up { color: var(--accent); }
.hud-load.fail { color: var(--danger); }
.hud-sub { margin: 3px 0 0; font-size: 13px; font-weight: 800; color: var(--ink); background: rgba(238,235,229,.85); padding: 0 6px; white-space: nowrap; }
.hud-sub.up { color: #FFFFFF; background: var(--accent); }
.hud-sub b { color: var(--accent); }
.hud-sub:empty { display: none; }
@media (max-width: 520px) { .hud { top: 56px; } .hud-load { font-size: 46px; } }
.testbar { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; z-index: 3; }
.chip { display: flex; align-items: center; gap: 6px; border: 2px solid var(--ink); background: #FFFFFF; border-radius: 2px; padding: 0 12px; height: 40px; font-size: 14px; font-weight: 900; }
.chip svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
#ffBtn { min-width: 52px; justify-content: center; }
#ffBtn[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.tools { grid-area: tools; display: grid; grid-template-columns: 1fr; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 3px solid var(--ink); }
.grp { display: flex; gap: 6px; }
.grp button { flex: 1 1 0; min-width: 0; height: 50px; border: 2px solid var(--ink); background: #FFFFFF; border-radius: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 11px; font-weight: 900; }
.grp button svg { width: 20px; height: 20px; }
.grp button:disabled { opacity: .3; cursor: default; }
.go { height: 56px; border: 2px solid var(--ink); border-radius: 2px; background: var(--accent); color: var(--ink); font-size: 19px; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 0 var(--ink); letter-spacing: .04em; }
.go:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.go svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.go.pulse { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 4px 0 var(--ink), 0 0 0 8px rgba(255,90,31,.25); } }
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .app { grid-template-columns: 340px 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "bar bar" "word stage" "tools stage"; }
  .word { border-bottom: 0; border-right: 2px solid var(--line); justify-content: flex-start; padding: 14px; }
  .slot b { font-size: 44px; min-height: 50px; }
  .tools { border-top: 0; border-right: 2px solid var(--line); padding: 14px; }
  .app[data-mode="test"] { grid-template-columns: 1fr; grid-template-rows: auto 1fr; grid-template-areas: "bar" "stage"; }
}
.screen { position: fixed; inset: 0; z-index: 10; overflow-y: auto; }
.title { display: grid; place-items: center; background: linear-gradient(180deg, rgba(238,235,229,.1), rgba(238,235,229,.86) 55%, rgba(238,235,229,.97)); }
.title-in { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 20px calc(24px + env(safe-area-inset-bottom)); text-align: center; width: min(100%, 420px); margin-top: 22vh; }
.title .logo { width: 64px; height: 64px; stroke: none; }
.title h1 { margin: 0; font-size: 54px; line-height: 1; font-weight: 900; letter-spacing: -.02em; }
.copy { margin: 0 0 4px; font-size: 18px; font-weight: 900; }
.lead { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink-sub); }
.btn { border: 2px solid var(--ink); background: #FFFFFF; border-radius: 2px; min-height: 46px; padding: 8px 14px; font-weight: 900; font-size: 15px; box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.sm { min-height: 40px; padding: 4px 12px; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.btn.big { width: 100%; min-height: 56px; background: var(--accent); color: var(--ink); font-size: 18px; box-shadow: 0 4px 0 var(--ink); }
.btn small { display: block; font-size: 11px; color: var(--ink-sub); }
.row { display: flex; gap: 8px; width: 100%; } .row .btn { flex: 1; }
.total { margin: 4px 0 0; font-size: 13px; font-weight: 800; color: var(--ink-sub); }
.total b { color: var(--ink); }
.note { color: var(--ink-sub); font-size: 12px; font-weight: 700; }
.foot { display: flex; gap: 16px; font-size: 12px; }
.foot a { color: var(--ink-sub); }
.select { background: var(--bg); }
.select-in { width: min(100%, 980px); margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom)); }
.select header { display: flex; align-items: center; gap: 6px; }
.select h2 { margin: 0; font-size: 20px; font-weight: 900; }
.listh { margin: 16px 0 0; font-size: 13px; font-weight: 900; border-left: 4px solid var(--accent); padding-left: 8px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
@media (min-width: 720px) { .cards { grid-template-columns: repeat(4, 1fr); } }
.card { position: relative; text-align: left; border: 2px solid var(--ink); background: #FFFFFF; border-radius: 2px; padding: 0 0 10px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; box-shadow: 3px 3px 0 rgba(28,29,32,.25); }
.card canvas { width: 100%; height: 92px; display: block; margin-bottom: 6px; border-bottom: 2px solid var(--ink); }
.card b, .card span, .card em, .card small { padding: 0 10px; }
.card b { font-size: 11px; font-weight: 900; color: var(--ink-sub); }
.card span { font-weight: 900; font-size: 15px; }
.card small { color: var(--ink-sub); font-size: 11px; font-weight: 700; }
.card em { font-weight: 900; font-size: 14px; font-style: normal; display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.card em i { font-style: normal; font-size: 11px; color: #FFFFFF; background: var(--ink); padding: 0 8px; white-space: nowrap; }
.card.lock { opacity: .6; }
.card.lock::after { content: attr(data-lock); position: absolute; inset: 0 0 auto 0; height: 98px; display: grid; place-items: center; background: rgba(238,235,229,.85); font-size: 12px; font-weight: 800; color: var(--ink-sub); padding: 0 10px; text-align: center; }
.card.today { grid-column: 1 / -1; border-left: 8px solid var(--accent); }
.card.today canvas { height: 110px; }
.select .sub { color: var(--ink-sub); font-size: 12px; font-weight: 700; }
.challist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.chalcard { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; text-align: left; border: 2px solid var(--ink); background: #FFFFFF; border-radius: 2px; padding: 8px 12px; box-shadow: 3px 3px 0 rgba(28,29,32,.25); }
.chalcard b { font-size: 22px; font-weight: 900; }
.chalcard span { font-size: 12px; color: var(--ink-sub); font-weight: 800; }
.chalcard em { font-style: normal; font-size: 12px; font-weight: 900; padding: 1px 8px; background: var(--bg); }
.chalcard.won em { background: var(--accent); }
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; background: rgba(28,29,32,.4); }
@media (min-width: 700px) { .modal { place-items: center; } }
.sheet { width: min(100%, 460px); max-height: 100%; overflow-y: auto; overflow-x: hidden; background: var(--bg); border: 3px solid var(--ink); border-bottom: 0; border-radius: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: up .22s ease-out; }
@media (min-width: 700px) { .sheet { border-bottom: 3px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet h2 { margin: 0; font-size: 26px; font-weight: 900; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; letter-spacing: .06em; }
.sheet h2 small { font-size: 12px; color: var(--ink-sub); letter-spacing: 0; text-align: right; white-space: pre-line; }
.sheet h2 span { min-width: 0; overflow-wrap: anywhere; }
.rec { position: relative; border-top: 2px solid var(--ink); padding-top: 6px; }
.rec > small { color: var(--ink-sub); font-size: 12px; font-weight: 800; }
.rec .big { margin: 0; font: 900 66px/1.05 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rec .big small { font-size: 28px; margin-left: 4px; }
.rec .big.up { color: var(--best); }
.rec .cmp { margin: 0; font-weight: 800; color: var(--ink-sub); }
.ribbon { position: absolute; right: 0; top: 14px; background: var(--ink); color: #FFFFFF; font-weight: 900; font-size: 20px; padding: 6px 16px; animation: pop .25s cubic-bezier(.3,1.6,.6,1); }
.ribbon.best { background: var(--best); }
.ribbon small { display: block; font-size: 11px; text-align: center; line-height: 1; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } }
.verdict { margin: 0; font-size: 34px; font-weight: 900; line-height: 1.1; padding: 10px 14px; background: #B8B3AA; border: 2px solid var(--ink); }
.verdict small { display: block; font-size: 13px; font-weight: 800; margin-top: 4px; }
.verdict.win { background: var(--accent); transform: rotate(-2deg); animation: stamp .28s cubic-bezier(.3,1.6,.6,1); }
@keyframes stamp { from { transform: rotate(-2deg) scale(1.7); opacity: 0; } }
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.facts li { display: contents; }
.facts li span { color: var(--ink-sub); font-weight: 700; }
.facts li b { font-weight: 900; }
.facts .up { color: var(--best); }
.facts s { color: var(--ink-sub); }
.resnote { margin: 0; font-size: 13px; color: var(--ink-sub); font-weight: 800; }
.resnote:empty { display: none; }
.row3, .row2 { display: grid; gap: 8px; } .row3 { grid-template-columns: repeat(3, 1fr); } .row2 { grid-template-columns: 1fr 1fr; } .row2.one { grid-template-columns: 1fr; }
.row3 .btn, .row2 .btn { padding: 8px 6px; font-size: 13px; }
.btn.x { background: #000000; color: #FFFFFF; }
.doc ol, .doc ul { margin: 0; padding-left: 1.3em; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.doc .sub, .sheet .sub { font-size: 12px; color: var(--ink-sub); margin: 0; font-weight: 700; }
#chalText { margin: 0; font-weight: 800; }
.chalbar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; border-left: 6px solid var(--accent); padding-left: 10px; }
.chalbar p { margin: 0; font-weight: 900; font-size: 14px; }
.chalbar p b { font-size: 18px; }
.chalbar small { grid-column: 1; font-size: 12px; color: var(--ink-sub); font-weight: 800; }
.chalbar .btn { grid-row: 1 / 3; grid-column: 2; }
.chalword { margin: 0; font-size: 46px; font-weight: 900; letter-spacing: .12em; text-align: center; background: var(--accent); border: 2px solid var(--ink); }
#chal h2 { background: var(--ink); color: #FFFFFF; padding: 6px 10px; font-size: 18px; letter-spacing: .1em; }
.namefield { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 800; color: var(--ink-sub); }
.namefield input { height: 40px; border: 2px solid var(--ink); border-radius: 2px; padding: 0 10px; font: 700 16px var(--sans); }
.preview { margin: 0; white-space: pre-wrap; word-break: break-all; font: 12px/1.5 var(--sans); background: #FFFFFF; border: 2px dashed var(--line); padding: 8px 10px; max-height: 110px; overflow: auto; }
body.docpage { overflow: auto; }
.doc-top { padding: 14px 20px; border-bottom: 3px solid var(--ink); background: #FFFFFF; }
.doc-top a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 900; }
main.doc { max-width: 720px; margin: 0 auto; padding: 20px; }
main.doc h1 { font-size: 22px; } main.doc h2 { font-size: 17px; margin-top: 28px; }
main.doc .date { color: var(--ink-sub); }
.doc-foot { max-width: 720px; margin: 0 auto; padding: 20px; color: var(--ink-sub); font-size: 13px; }
.doc-foot nav { display: flex; gap: 16px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
