:root { --cell: 38px; --wood: #e8c27a; --bg: #2b1a0e; --ink: #2a1a0a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: #fbf3e4; font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.hidden { display: none !important; }
.screen { display: none; min-height: 100%; padding: 14px; flex-direction: column; gap: 12px; align-items: stretch; max-width: 640px; margin: 0 auto; }
.screen.show { display: flex; }
h1 { text-align: center; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 40px; margin: 18px 0 6px; letter-spacing: .1em; }
h2 { font-size: 26px; margin: 6px 0; }
button { font: inherit; font-size: 19px; padding: 12px 10px; border-radius: 12px; border: 2px solid #7a5532; background: #4a2f1a; color: #fbf3e4; min-height: 50px; }
button:active { transform: scale(.97); }
button.big { font-size: 22px; padding: 16px; }
button.primary { background: #b8442c; border-color: #e07a55; }
button.warn { background: #6b2a1c; }
button.on { background: #d9a441; color: #2a1a0a; border-color: #f3d08a; font-weight: bold; }
button:disabled { opacity: .4; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > button { flex: 1 1 40%; }
.card { background: #3d2715; border: 1px solid #6b4a2b; border-radius: 14px; padding: 14px; font-size: 18px; }
.card.text p { margin: 0 0 10px; line-height: 1.6; }
.small { font-size: 14px; opacity: .7; text-align: center; }
.rank { font-family: "Hiragino Mincho ProN", serif; font-size: 44px; font-weight: bold; color: #f3d08a; text-align: center; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #8a6a48; }
.dot.w { background: #e8b23a; border-color: #e8b23a; } .dot.l { background: #555; } .dot.d { background: #999; }
.setgrp { margin-bottom: 14px; } .setgrp h3 { margin: 4px 0 6px; font-size: 18px; color: #f3d08a; }
.setgrp .row > button { flex: 1 1 28%; font-size: 17px; padding: 10px 4px; }
table { width: 100%; border-collapse: collapse; font-size: 17px; } td, th { padding: 6px 4px; border-bottom: 1px solid #5a3d24; text-align: left; }
.ach { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #5a3d24; } .ach .ic { font-size: 30px; } .ach.lock { opacity: .4; }
pre { white-space: pre-wrap; font-size: 15px; max-height: 60vh; overflow: auto; -webkit-user-select: text; user-select: text; }
/* ---- 対局画面 ---- */
#game.screen { max-width: none; padding: 6px; gap: 6px; height: 100%; }
#boardWrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.info { width: calc(var(--cell) * 9 + 20px); display: flex; justify-content: space-between; align-items: center; font-size: 18px; font-weight: bold; }
.clock { font-variant-numeric: tabular-nums; font-size: 20px; padding: 2px 8px; border-radius: 8px; background: #1a0f07; }
.clock.run { background: #d9a441; color: #2a1a0a; } .clock.low { background: #c0392b; color: #fff; }
#boardBox { background: var(--wood); padding: 10px; border-radius: 6px; box-shadow: 0 4px 14px #0008; }
#board { display: grid; grid-template-columns: repeat(9, var(--cell)); grid-template-rows: repeat(9, var(--cell)); border: 2px solid var(--ink); position: relative; background: linear-gradient(135deg, #f0cf8c, #e2b467); }
.cell { border: 1px solid #6b4a2b88; position: relative; display: flex; align-items: center; justify-content: center; }
.cell.star::after { content: ""; position: absolute; width: 6px; height: 6px; background: var(--ink); border-radius: 50%; right: -4px; bottom: -4px; z-index: 1; }
.cell.last { background: #f7a85a99; } .cell.sel { background: #7ec8ff99; } .cell.chk { background: #ff4d4d99; } .cell.hintc { background: #7cff9a88; }
.cell.tgt::before { content: ""; position: absolute; width: 34%; height: 34%; border-radius: 50%; background: #1e7a3acc; z-index: 3; }
.cell.tgt.cap::before { width: 86%; height: 86%; background: none; border: 4px solid #1e7a3acc; }
.coord { position: absolute; font-size: 11px; color: var(--ink); }
.pc { width: 88%; height: 94%; position: relative; display: flex; align-items: center; justify-content: center; z-index: 2; }
.pc::before { content: ""; position: absolute; inset: 0; clip-path: polygon(50% 0, 86% 16%, 100% 100%, 0 100%, 14% 16%); background: linear-gradient(160deg, #fbe7b8, #e0b066 70%, #c99548); }
.pc span { position: relative; font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; font-weight: 800; font-size: calc(var(--cell) * .58); color: #1c1006; line-height: 1; margin-top: 12%; }
.pc.pr span { color: #b3170e; }
.pc.g { transform: rotate(180deg); }
.pc.mv { animation: drop .25s ease-out; }
@keyframes drop { from { transform: scale(1.35); filter: drop-shadow(0 6px 4px #0006); } to { transform: scale(1); } }
.pc.g.mv { animation: dropg .25s ease-out; }
@keyframes dropg { from { transform: rotate(180deg) scale(1.35); } to { transform: rotate(180deg) scale(1); } }
.stand { width: calc(var(--cell) * 9 + 20px); min-height: calc(var(--cell) * 1.05); background: #c79a55; border-radius: 6px; display: flex; flex-wrap: wrap; align-items: center; padding: 2px 6px; gap: 2px; }
.stand .hp { width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; position: relative; border-radius: 6px; }
.stand .hp.sel { background: #7ec8ff; }
.stand .cnt { position: absolute; right: -4px; bottom: -2px; background: #2a1a0a; color: #fff; font-size: 13px; border-radius: 9px; padding: 0 5px; z-index: 4; }
#panel { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 560px; margin: 0 auto; min-height: 0; flex: 1; }
.status { text-align: center; font-size: 19px; font-weight: bold; min-height: 28px; }
#controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#controls button { font-size: 18px; padding: 8px 2px; min-height: 48px; }
#moveList { margin: 0; padding: 6px 6px 6px 42px; overflow-y: auto; background: #1f130a; border-radius: 10px; font-size: 16px; flex: 1; min-height: 60px; max-height: 30vh; columns: 2; }
@media (orientation: landscape) {
  #game.screen { flex-direction: row; align-items: center; justify-content: center; }
  #boardWrap { flex: 0 0 auto; }
  #panel { max-width: 340px; height: 100%; justify-content: center; }
  #moveList { max-height: none; columns: 1; }
}
.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.dialog { background: #3d2715; border: 2px solid #d9a441; border-radius: 16px; padding: 18px; width: min(92vw, 420px); font-size: 20px; text-align: center; }
.dialog .row { margin-top: 14px; } #dlgMsg .rank { margin: 6px 0; }
#fx { background: #000c; flex-direction: column; overflow: hidden; }
#fxBox { text-align: center; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); }
#fxBox .t1 { font-size: 24px; } #fxBox .t2 { font-family: "Hiragino Mincho ProN", serif; font-size: 72px; font-weight: 900; color: #ffd76a; text-shadow: 0 0 24px #ffb300; margin: 10px 0; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.conf { position: absolute; width: 10px; height: 16px; top: -20px; animation: fall linear forwards; z-index: 60; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.side { display: flex; flex-direction: column; gap: 4px; }
@media (orientation: landscape) {
  #boardWrap { flex-direction: row; align-items: stretch; height: calc(var(--cell) * 9 + 24px); }
  .side { width: calc(var(--cell) * 2 + 14px); }
  .side.top { justify-content: flex-start; } .side.bot { justify-content: flex-end; flex-direction: column; }
  .side .stand, .side .info { width: 100%; }
  .side .stand { align-content: flex-start; min-height: calc(var(--cell) * 3); }
  .info { flex-direction: column; align-items: flex-start; font-size: 16px; gap: 2px; }
  #panel { max-width: 250px; }
  #controls { grid-template-columns: repeat(2, 1fr); }
}
.coord.ct { top: -11px; right: 40%; font-size: 9px; line-height: 1; z-index: 5; }
.coord.cr { right: -10px; top: 40%; font-size: 9px; line-height: 1; z-index: 5; }
#moveList { columns: auto; display: grid; grid-template-columns: 1fr 1fr; align-content: start; column-gap: 28px; list-style-position: outside; }
@media (orientation: landscape) { #moveList { grid-template-columns: 1fr; } }
.clock:empty { display: none; }
