* { box-sizing: border-box; }
body { margin: 0; background: #262421; color: #eee; font: 16px/1.4 system-ui, sans-serif; }
main { max-width: 560px; margin: 0 auto; padding: 8px 8px calc(16px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.1rem; margin: 4px 0; }
#banner { min-height: 2.4em; padding: 6px 10px; border-radius: 6px; background: #3a3733; margin-bottom: 8px; }
#banner.over { background: #7a3b1d; font-weight: 600; }
#banner.check { background: #6b5a1a; }
#board-wrap { position: relative; width: 100%; touch-action: none; }
#board { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
button { flex: 1; min-height: 44px; border: 0; border-radius: 6px; background: #4b7bb5; color: #fff; font: inherit; }
button:active { background: #3a6293; }
.fen { display: flex; flex-direction: column; gap: 6px; }
textarea { width: 100%; font: 14px ui-monospace, monospace; padding: 8px; border-radius: 6px; border: 1px solid #555; background: #1c1b19; color: #eee; }
#fen-error { color: #ff8a80; min-height: 1.2em; font-size: .9rem; }
#moves { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 2px 12px; font-family: ui-monospace, monospace; }
#moves li b { color: #999; font-weight: 400; margin-right: 4px; }
#promo { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; gap: 8px; z-index: 5; }
#promo[hidden] { display: none; }
#promo button { flex: 0 0 22%; aspect-ratio: 1; background: #f0d9b5; padding: 4px; }
#promo svg { width: 100%; height: 100%; }
.cm-chessboard .board.default .coordinates .coordinate { font-size: 9px; }

#arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#hints { margin: 10px 0; padding: 8px 10px; background: #2f2d2a; border-radius: 6px; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.toggle input { width: 22px; height: 22px; }
#hints-status { min-height: 1.3em; color: #f0c674; }
#hints .note { margin: 2px 0 6px; font-size: .85rem; color: #aaa; }
#hints-list { list-style: none; margin: 0; padding: 0; font-family: ui-monospace, monospace; }
#hints-list li { display: flex; gap: 14px; padding: 4px 0 4px 10px; border-left: 6px solid var(--c); margin-bottom: 4px; }
#hints-list .san { flex: 0 0 5em; font-weight: 700; }
#hints-list .ev { flex: 0 0 4em; }
#hints-list .dp { color: #999; }

#editor[hidden], #play-row[hidden], #hints[hidden], #fen-form[hidden], #moves[hidden] { display: none; }
#palette { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px 0; }
#palette button { min-height: 44px; padding: 2px; background: #f0d9b5; }
#palette button[aria-pressed="true"] { outline: 3px solid #4b7bb5; background: #cfe0f5; }
#palette svg { width: 100%; height: 100%; max-height: 40px; }
#palette .txt { color: #222; font-weight: 700; font-size: .8rem; }
#editor fieldset { border: 1px solid #555; border-radius: 6px; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
#editor fieldset label, .ep { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
#editor input[type=radio], #editor input[type=checkbox] { width: 20px; height: 20px; }
#editor select { min-height: 36px; font: inherit; }
#editor input:disabled + * { opacity: .5; }
.fenrow { display: flex; gap: 6px; }
.fenrow input { flex: 1; min-width: 0; font: 13px ui-monospace, monospace; padding: 8px; border-radius: 6px; border: 1px solid #555; background: #1c1b19; color: #eee; }
.fenrow button { flex: 0 0 72px; }
#ed-errors { color: #ff8a80; margin: 6px 0; padding-left: 18px; min-height: 1.2em; }
button.secondary { background: #5b5853; }

#pgn { margin-top: 1rem; }
#pgn textarea { width: 100%; box-sizing: border-box; font-family: ui-monospace, monospace; font-size: 13px; }
#pgn-msg { min-height: 1.2em; font-size: 14px; }
#pgn-msg.bad { color: #e5534b; }
footer { margin: 1.5rem 0 2rem; font-size: 13px; opacity: .8; }
footer a { color: inherit; }
