:root { --bg:#f4f6fb; --card:#fff; --ink:#1f2937; --sub:#6b7280; --blue:#2563eb; --blue-l:#dbeafe; --line:#9ca3af; --thick:#1f2937; --red:#dc2626; --red-l:#fee2e2; --same:#bfdbfe; --peer:#eef2ff; --sel:#fde68a; }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }
html,body { margin:0; height:100%; background:var(--bg); color:var(--ink); font-family:-apple-system,"Hiragino Sans",sans-serif; touch-action:manipulation; 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); }
#app { min-height:100%; display:flex; flex-direction:column; }
button { font:inherit; color:inherit; border:0; background:none; cursor:pointer; }
input { font:inherit; -webkit-user-select:text; user-select:text; }
h1 { font-size:34px; margin:24px 0 8px; text-align:center; }
h2 { font-size:22px; margin:0 0 12px; }
.screen { flex:1; display:flex; flex-direction:column; align-items:center; padding:16px 20px 28px; max-width:760px; width:100%; margin:0 auto; }
.top { width:100%; display:flex; align-items:center; justify-content:space-between; min-height:52px; margin-bottom:8px; }
.top .title { font-size:22px; font-weight:700; }
.link { color:var(--blue); font-size:19px; padding:10px 12px; border-radius:10px; }
.chip { display:flex; align-items:center; gap:8px; background:var(--card); padding:8px 16px; border-radius:999px; font-size:19px; box-shadow:0 1px 3px #0002; }
.chip .ic { font-size:26px; }
/* プレイヤー選択 */
.players { display:flex; flex-wrap:wrap; justify-content:center; gap:22px; margin:26px 0; }
.pbtn { width:150px; display:flex; flex-direction:column; align-items:center; gap:10px; padding:18px 8px; background:var(--card); border-radius:24px; box-shadow:0 2px 6px #0002; }
.pbtn .ic { font-size:68px; line-height:1; }
.pbtn .nm { font-size:22px; font-weight:700; word-break:break-all; text-align:center; }
.pbtn.add { background:transparent; border:3px dashed var(--line); box-shadow:none; color:var(--sub); }
.pbtn:active,.btn:active { transform:scale(.97); }
/* ボタン */
.btn { background:var(--blue); color:#fff; font-size:22px; font-weight:700; padding:16px 24px; border-radius:16px; width:100%; max-width:420px; margin:8px 0; }
.btn.sub { background:var(--card); color:var(--ink); box-shadow:0 1px 3px #0003; }
.btn.danger { background:var(--red); }
.btn.sm { font-size:18px; padding:12px 16px; width:auto; }
.stack { width:100%; max-width:420px; display:flex; flex-direction:column; align-items:stretch; }
.stack .btn { max-width:none; }
.note { color:var(--sub); font-size:16px; margin:4px 0 12px; text-align:center; }
.lvl small { display:block; font-weight:400; font-size:15px; opacity:.85; margin-top:2px; }
/* 盤面 */
.game { width:100%; display:flex; flex-direction:column; align-items:center; gap:14px; }
.bar { width:100%; max-width:560px; display:flex; justify-content:space-between; align-items:center; font-size:19px; }
.bar .stat { color:var(--sub); }
.boardwrap { --size:min(94vw, calc(100dvh - 360px), 640px); width:var(--size); height:var(--size); }
.board { width:100%; height:100%; display:grid; grid-template-columns:repeat(9,1fr); grid-template-rows:repeat(9,1fr); border:3px solid var(--thick); background:var(--card); }
.cell { position:relative; display:flex; align-items:center; justify-content:center; border:0; border-right:1px solid var(--line); border-bottom:1px solid var(--line); font-size:calc(var(--size) / 15); color:var(--blue); padding:0; background:var(--card); }
.cell:nth-child(9n) { border-right:0; }
.cell:nth-child(n+73) { border-bottom:0; }
.cell.br { border-right:2px solid var(--thick); }
.cell.bb { border-bottom:2px solid var(--thick); }
.cell.given { color:var(--ink); font-weight:700; }
.cell.peer { background:var(--peer); }
.cell.same { background:var(--same); }
.cell.sel { background:var(--sel); }
.cell.bad { color:var(--red); background:var(--red-l); }
.cell.sel.bad { background:var(--sel); }
.notes { position:absolute; inset:2px; display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); font-size:calc(var(--size) / 33); color:var(--sub); line-height:1; }
.notes span { display:flex; align-items:center; justify-content:center; }
.notes span.hl { color:var(--blue); font-weight:700; }
.controls { width:100%; max-width:640px; display:flex; flex-direction:column; gap:10px; }
.pad { display:grid; grid-template-columns:repeat(9,1fr); gap:6px; }
.pad button { background:var(--card); border-radius:12px; font-size:30px; padding:8px 0 4px; box-shadow:0 1px 3px #0003; display:flex; flex-direction:column; align-items:center; color:var(--blue); font-weight:600; }
.pad button small { font-size:12px; color:var(--sub); font-weight:400; height:14px; }
.pad button.done { opacity:.3; }
.tools { display:grid; grid-template-columns:repeat(4,1fr); gap:6px; }
.tools button { background:var(--card); border-radius:12px; padding:12px 4px; font-size:18px; box-shadow:0 1px 3px #0003; }
.tools button.on { background:var(--blue); color:#fff; }
@media (orientation:landscape) and (min-width:900px) {
  .game { flex-direction:row; align-items:flex-start; justify-content:center; gap:28px; }
  .game .left { display:flex; flex-direction:column; align-items:center; gap:14px; }
  .boardwrap { --size:min(62vh, 60vw, 640px); }
  .controls { width:340px; max-width:340px; flex:none; }
  .tools { grid-template-columns:repeat(2,1fr); }
  .pad { grid-template-columns:repeat(3,1fr); }
  .pad button { font-size:34px; padding:14px 0 8px; }
}
/* 記録など */
table.rec { width:100%; max-width:560px; border-collapse:collapse; background:var(--card); border-radius:14px; overflow:hidden; font-size:19px; }
table.rec th,table.rec td { padding:12px 8px; text-align:center; border-bottom:1px solid #e5e7eb; }
table.rec th { background:var(--blue-l); }
.card { background:var(--card); border-radius:16px; padding:16px; margin:10px 0; width:100%; max-width:560px; box-shadow:0 1px 3px #0002; }
.row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 0; font-size:19px; }
.row + .row { border-top:1px solid #eee; }
.switch { appearance:none; width:56px; height:32px; border-radius:16px; background:#cbd5e1; position:relative; border:0; flex:none; }
.switch::after { content:""; position:absolute; top:3px; left:3px; width:26px; height:26px; background:#fff; border-radius:50%; transition:left .15s; }
.switch:checked { background:var(--blue); }
.switch:checked::after { left:27px; }
.big { font-size:80px; text-align:center; margin:10px 0 0; }
.result { font-size:22px; line-height:1.9; text-align:center; margin:8px 0 14px; }
.icons { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin:10px 0; }
.icons button { font-size:36px; width:62px; height:62px; border-radius:16px; background:var(--card); box-shadow:0 1px 3px #0003; }
.icons button.on { outline:4px solid var(--blue); }
input.txt { width:100%; font-size:24px; padding:12px 14px; border:2px solid var(--line); border-radius:12px; margin:8px 0; }
#toast { position:fixed; left:50%; bottom:calc(30px + env(safe-area-inset-bottom)); transform:translate(-50%,20px); background:#111c; color:#fff; padding:12px 22px; border-radius:999px; font-size:18px; opacity:0; pointer-events:none; transition:.2s; max-width:90vw; text-align:center; z-index:30; }
#toast.show { opacity:1; transform:translate(-50%,0); }
#toast.err { background:var(--red); }
#modal { position:fixed; inset:0; background:#0007; display:flex; align-items:center; justify-content:center; z-index:20; padding:20px; }
#modal[hidden] { display:none; }
#modal .box { background:var(--card); border-radius:20px; padding:22px; width:100%; max-width:440px; max-height:90vh; overflow:auto; }
#modal .box p { font-size:19px; line-height:1.6; margin:0 0 12px; white-space:pre-wrap; }
#modal .btns { display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; }
.score { text-align:center; margin:4px 0 14px; }
.score .pt { font-size:44px; font-weight:800; color:var(--blue, #2563eb); }
.score .pt small { font-size:20px; font-weight:600; }
.score .sb { font-size:20px; font-weight:700; color:#d97706; }
.score .rk { font-size:18px; margin-top:4px; }
.tabs { display:flex; gap:8px; margin:8px 0 12px; }
.tabs button { flex:1; padding:10px 0; font-size:17px; border:2px solid #cbd5e1; background:var(--card); border-radius:12px; }
.tabs button.on { background:var(--blue-l); border-color:#2563eb; font-weight:700; }
table.rec td.pt { font-weight:700; }
table.rank { font-size:15px; } table.rank th,table.rank td { padding:9px 3px; }
