:root { font-family: system-ui, -apple-system, "Noto Sans JP", sans-serif; color: #302b24; background: #f5f1e9; color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 640px; margin: 0 auto; padding: 24px 14px 40px; }
header { margin-bottom: 22px; }
header a { color: #655e52; font-size: .85rem; }
h1 { font-size: 2rem; margin: 14px 0 2px; letter-spacing: .12em; }
header p { margin: 0; color: #756b5c; }
.game { background: #fffdf8; padding: 18px; border: 1px solid #e1d7c6; border-radius: 16px; box-shadow: 0 8px 28px #59452b0a; }
.turnbar { display: flex; justify-content: space-between; align-items: center; }
#turn { font-weight: 700; font-size: 1.1rem; }
#count { color: #776b5b; font-variant-numeric: tabular-nums; }
#status { min-height: 2.8em; font-size: .9rem; line-height: 1.4; margin: 12px 0 6px; }
.files { display: grid; grid-template-columns: repeat(var(--columns, 9), 1fr); text-align: center; font-size: .75rem; color: #847255; padding: 0 2px 5px; }
.board { display: grid; grid-template-columns: repeat(var(--columns, 9), minmax(0, 1fr)); border: 2px solid #725b38; background: #725b38; gap: 1px; }
.square { position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 1px; min-width: 0; border: 0; border-radius: 0; background: #eacb91; touch-action: manipulation; }
.square:nth-child(even) { background: #e7c78b; }
.square.selected { background: #e6aa50; box-shadow: inset 0 0 0 3px #8c5418; }
.square.candidate { background: #c9d5a1; }
.square.candidate::after { content: ""; position: absolute; width: 18%; height: 18%; background: #456441; border-radius: 50%; }
.square.candidate:has(.piece)::after { width: 82%; height: 82%; background: transparent; border: 2px solid #456441; border-radius: 3px; }
.square.last { box-shadow: inset 0 0 0 2px #b9863e; }
.piece { width: 83%; height: 87%; display: grid; place-items: center; background: #fff0cc; clip-path: polygon(50% 0, 87% 18%, 100% 100%, 0 100%, 13% 18%); font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-weight: 700; font-size: clamp(18px, 5vw, 31px); line-height: 1; padding-top: 8%; color: #30241b; }
.piece.enemy { transform: rotate(180deg); }
.piece.promoted { color: #ad352b; }
.piece.long { font-size: clamp(12px, 3.4vw, 22px); }
button { font: inherit; cursor: pointer; color: inherit; }
button:focus-visible, summary:focus-visible { outline: 3px solid #246978; outline-offset: 2px; z-index: 1; }
button:disabled { opacity: .4; cursor: default; }
.controls { display: flex; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.controls button { border: 1px solid #d2c5af; background: #faf5ea; padding: 9px 14px; border-radius: 8px; }
details { margin-top: 20px; font-size: .9rem; line-height: 1.8; color: #655b4e; }
summary { cursor: pointer; }
@media (max-width: 400px) { main { padding: 16px 8px 28px; } .game { padding: 12px 8px; } .controls button { padding: 8px 10px; } }
main.large-board { max-width: 880px; }
.large-board .board-wrap { overflow-x: auto; padding-bottom: 8px; }
.large-board .board, .large-board .files { min-width: 600px; }
.large-board .piece.long { font-size: clamp(14px, 2.2vw, 20px); }
main.dai { max-width: 1040px; }
.dai .board, .dai .files { min-width: 750px; }
main.taikyoku { max-width: 1900px; }
.taikyoku .board-wrap { max-height: 75vh; overflow: auto; }
.taikyoku .board, .taikyoku .files { min-width: 1800px; }
.taikyoku .files { position: sticky; top: 0; background: #fffdf8; z-index: 2; }
.taikyoku .piece.long { font-size: 16px; }
.taikyoku .piece.very-long { font-size: 10px; line-height: 1.1; word-break: break-all; }
.game-select { display: block; margin-top: 16px; }
select { font: inherit; padding: 8px 12px; border: 1px solid #d2c5af; border-radius: 8px; background: #fffdf8; color: inherit; }
select:focus-visible { outline: 3px solid #246978; }
#end-turn { background: #e5edcf; border-color: #9baa77; }
.board-layout { display: flex; flex-direction: column; gap: 12px; }
.hand-panel { padding: 10px 12px; border: 1px solid #e4dbcb; border-radius: 8px; background: #faf5ea; }
.hand-panel[hidden] { display: none; }
.board-layout > .hand-panel:first-child { transform: rotate(180deg); }
.hand-panel.active { border-color: #9baa77; background: #f2f5e8; }
.hand-panel h2 { font-size: .85rem; margin: 0 0 8px; color: #766a59; }
.hand { display: flex; gap: 6px; flex-wrap: wrap; font-size: .9rem; }
.hand button { border: 1px solid #d2c5af; background: #fff0cc; border-radius: 6px; padding: 8px 10px; }
.hand button:disabled { opacity: 1; }
.hand button.selected { background: #e6aa50; border-color: #8c5418; }
.dobutsu .board-layout { max-width: 360px; margin: 0 auto; }
.dobutsu .piece { clip-path: none; border-radius: 12px; font-family: inherit; font-size: clamp(12px, 3.4vw, 18px); padding: 6px 2px; gap: 2px; }
.dobutsu .animal { font-size: clamp(28px, 9vw, 48px); }
.dobutsu .piece.promoted { background: #ffe0b2; }
