/* tsumetsume100 - styles */
:root {
  --bg: #f4f1ea;
  --fg: #23201b;
  --muted: #7c756a;
  --card: #fffdf8;
  --line: #e2dccf;
  --accent: #b5502a;
  --accent-fg: #ffffff;
  --board-bg: #e9c98a;
  --board-line: #7a5a2a;
  --cell-sel: #ffe08a;
  --cell-tgt: rgba(60, 140, 90, 0.28);
  --cell-last: rgba(120, 160, 255, 0.22);
  --cell-check: rgba(220, 70, 60, 0.32);
  --piece: #201a12;
  --promoted: #b3261e;
  --len1: #3a86c8;
  --len3: #c98a2a;
  --len5: #c0433a;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
  --cell: clamp(30px, 9.4vw, 46px);
  --coord: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1815;
    --fg: #ece7dd;
    --muted: #9a9284;
    --card: #24211c;
    --line: #38332b;
    --accent: #e0794f;
    --accent-fg: #1a1815;
    --board-bg: #c8a866;
    --board-line: #5a3f16;
    --cell-sel: #e8c766;
    --cell-tgt: rgba(70, 160, 100, 0.34);
    --cell-last: rgba(120, 150, 240, 0.26);
    --cell-check: rgba(230, 80, 70, 0.4);
    --piece: #1a140c;
    --promoted: #8f1a15;
    --shadow: 0 2px 12px rgba(0,0,0,0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; }
.app { max-width: 560px; margin: 0 auto; padding: 16px 14px 40px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }

h1 { margin: 0; }
h2 { font-size: 1rem; margin: 0 0 8px; }

/* ---- hero ---- */
.hero { text-align: center; padding: 18px 0 8px; }
.hero h1 { font-size: 2.4rem; letter-spacing: 1px; }
.hero .hundred { color: var(--accent); }
.tagline { color: var(--muted); font-size: .92rem; margin: 8px 4px 0; line-height: 1.6; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 14px 0; box-shadow: var(--shadow); }
.best-card { text-align: center; }
.best-label { color: var(--muted); font-size: .8rem; }
.best-time { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }

/* ---- buttons ---- */
.btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 10px 16px; border-radius: 10px; transition: transform .05s ease, background .15s; }
.btn:hover { background: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 700; }
.btn.big { width: 100%; padding: 15px; font-size: 1.15rem; border-radius: 12px; }
.btn.subtle { background: transparent; border-style: dashed; color: var(--muted); }
.btn.tiny { padding: 5px 10px; font-size: .8rem; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }

.rules ul { margin: 0; padding-left: 18px; line-height: 1.8; font-size: .9rem; }
.rules li strong { color: var(--accent); }

/* ---- records ---- */
table.records { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.records th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 4px; }
table.records td { padding: 6px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.records tr.top td { font-weight: 700; }
.muted { color: var(--muted); }

.pool-card { text-align: center; }
.pool-info { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.hint-text { font-size: .75rem; color: var(--muted); margin: 8px 0 0; }
.foot { text-align: center; color: var(--muted); font-size: .72rem; margin-top: 18px; }

/* ---- game bar ---- */
.game-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 2px; }
.q-no { font-size: 1rem; }
.q-len { display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; color: #fff; background: var(--muted); }
.q-len.len1 { background: var(--len1); }
.q-len.len3 { background: var(--len3); }
.q-len.len5 { background: var(--len5); }
.timer { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.game-sub { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: .85rem; padding: 2px 2px 8px; }
.game-sub strong { color: var(--fg); }
.game-sub .btn { margin-left: auto; }

/* ---- hands ---- */
.hand-row { display: flex; align-items: center; gap: 8px; min-height: 34px; margin: 4px 0; }
.hand-label { font-size: .72rem; color: var(--muted); width: 62px; flex: none; }
.hand { display: flex; flex-wrap: wrap; gap: 4px; }
.hand-piece { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); font-size: .95rem; font-weight: 600; }
.hand-piece.clickable { cursor: pointer; background: var(--board-bg); color: var(--piece); border-color: var(--board-line); }
.hand-piece.clickable:hover { filter: brightness(1.05); }
.hand-piece.selected { outline: 3px solid var(--accent); }
.hand-none { color: var(--muted); font-size: .8rem; }
.hand.def .hand-piece { font-size: .8rem; min-width: 26px; height: 24px; opacity: .8; }

/* ---- board ---- */
.board-wrap { display: flex; justify-content: center; margin: 6px 0; }
.board-grid {
  display: grid;
  grid-template-columns: var(--coord) repeat(9, var(--cell));
  grid-template-rows: var(--coord) repeat(9, var(--cell));
  background: var(--board-line);
  border: 2px solid var(--board-line);
  border-radius: 4px;
  gap: 1px;
}
.coord { display: flex; align-items: center; justify-content: center; font-size: .68rem; color: var(--muted); background: var(--bg); }
.cell {
  position: relative;
  background: var(--board-bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none;
}
.cell.selected { background: var(--cell-sel); }
.cell.last { background: var(--cell-last); }
.cell.in-check { background: var(--cell-check); }
.cell.target { box-shadow: inset 0 0 0 3px var(--cell-tgt); }
.cell.target::after {
  content: ""; position: absolute; width: 32%; height: 32%;
  border-radius: 50%; background: var(--cell-tgt);
}
.piece {
  width: 84%; height: 84%;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * 0.5);
  line-height: 1; color: var(--piece); font-weight: 700;
  z-index: 1; pointer-events: none;
  /* 将棋の駒（五角形）タイル */
  background: linear-gradient(180deg, #f7e8c8 0%, #edd7a8 100%);
  clip-path: polygon(50% 3%, 76% 23%, 86% 97%, 14% 97%, 24% 23%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
}
.piece.promoted { color: var(--promoted); font-size: calc(var(--cell) * 0.44); }
.piece.def { transform: rotate(180deg); }
.piece.gyoku { font-weight: 800; background: linear-gradient(180deg, #f9edd2 0%, #f0dcaf 100%); }

/* ---- status ---- */
.status { min-height: 24px; text-align: center; margin: 8px 0; font-size: .92rem; padding: 8px; border-radius: 10px; }
.status.success { background: rgba(60,160,90,.16); color: #2c8a4e; font-weight: 700; }
.status.warn { background: rgba(220,120,40,.16); color: var(--accent); }
.status.hint { background: rgba(90,140,220,.16); color: var(--len1); }

.controls { display: flex; gap: 8px; margin-top: 6px; }
.controls .btn { flex: 1; }
.controls.center { justify-content: center; }
.controls.center .btn { flex: none; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-box { background: var(--card); padding: 20px 24px; border-radius: 14px; text-align: center; box-shadow: var(--shadow); }
.modal-btns { display: flex; gap: 10px; margin-top: 12px; }

/* ---- result ---- */
.result-card { text-align: center; padding: 28px 20px; }
.result-card h1 { font-size: 1.5rem; margin-bottom: 10px; }
.best-badge { display: inline-block; background: var(--accent); color: var(--accent-fg); padding: 4px 14px; border-radius: 999px; font-weight: 700; margin-bottom: 10px; }
.result-time-label { color: var(--muted); font-size: .85rem; }
.result-time { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-meta { color: var(--muted); margin: 8px 0 18px; }
