/*
  見た目の決まり: 置いてある物はすべて「濃い緑のインク枠＋ベタ塗り＋下にずれた影」。
  グラデーション、ぼかし、色つきの上線、つや出しは使わない。絵文字は絵の代わりに使わない。
*/
:root {
  --ink: #2d3b2e;
  --ink-soft: #66756a;
  --paper: #fff4d6;
  --paper-line: #e6d6a6;
  --grass: #8fd16a;
  --grass-deep: #4f9e45;
  --wood: #e8b66b;
  --yellow: #ffd23f;
  --orange: #ff7a35;
  --red: #e2452b;
  --sky: #d6f1ff;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --dots: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Ccircle cx='8' cy='8' r='3' fill='%23fff' fill-opacity='.22'/%3E%3Ccircle cx='32' cy='32' r='3' fill='%23fff' fill-opacity='.14'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-weight: 500;
  color: var(--ink);
  background: var(--grass) var(--dots);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 480px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button, label, summary, a { touch-action: manipulation; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
[hidden] { display: none !important; }

/* ---- 題字帯と上部バー ---- */
.hero {
  display: flex; align-items: center; gap: 14px;
  margin: 0 -16px; padding: calc(24px + env(safe-area-inset-top)) 20px 22px;
  background: var(--sky); border-bottom: 4px solid var(--ink);
}
.logo { flex: none; width: 56px; height: 56px; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); background: var(--grass); display: block; }
.hero h1 { font-size: 34px; font-weight: 800; letter-spacing: .05em; line-height: 1; text-shadow: 3px 3px 0 var(--yellow); }
.hero p { margin-top: 8px; font-size: 12px; font-weight: 800; }
.hero .grow { flex: 1; min-width: 0; }
.bar {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px;
  margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--sky); border-bottom: 4px solid var(--ink);
}
.bar h1 { flex: 1; font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none; min-width: 40px; height: 40px; padding: 0 10px; border: 3px solid var(--ink); border-radius: 10px;
  background: #fff; font-size: 15px; line-height: 1; font-weight: 800; box-shadow: 0 3px 0 var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }

.page { display: grid; gap: 28px; padding-top: 26px; }

/* ---- ボタン ---- */
.pop-btn {
  display: block; width: 100%; padding: 15px 20px; border: 4px solid var(--ink); border-radius: 20px;
  background: var(--yellow); color: var(--ink); text-align: center; box-shadow: 0 7px 0 var(--ink);
  transition: transform .22s cubic-bezier(.3, 1.6, .5, 1), box-shadow .22s cubic-bezier(.3, 1.6, .5, 1);
}
.pop-btn b { display: block; font-size: 22px; font-weight: 800; line-height: 1.3; letter-spacing: .02em; }
.pop-btn small { display: block; margin-top: 2px; font-size: 12px; font-weight: 800; }
.pop-btn:active { transform: translateY(5px) scale(.98); box-shadow: 0 2px 0 var(--ink); transition-duration: .04s; }
.pop-btn.orange { background: var(--orange); color: #fff; }
.pop-btn.white { background: #fff; }
.pop-btn.green { background: var(--grass-deep); color: #fff; }
.pop-btn.dim { opacity: .65; }
.mini-btn {
  padding: 8px 14px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 800; font-size: 14px;
  box-shadow: 0 3px 0 var(--ink);
}
.mini-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.mini-btn.on { background: var(--yellow); }
.mini-btn.red { color: var(--red); }

/* ---- 札（見出しは枠にまたがる荷札）---- */
.panel {
  position: relative; padding: 28px 16px 16px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 var(--grass-deep);
}
.panel.plain { background: #fff; padding-top: 16px; }
.ribbon {
  position: absolute; top: -17px; left: 14px; padding: 3px 14px 3px 26px; font-size: 14px; font-weight: 800;
  background: #fff; border: 3px solid var(--ink); border-radius: 6px; transform: rotate(-1.5deg);
}
.ribbon::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border: 2.5px solid var(--ink); border-radius: 50%;
}
.note { font-size: 13px; line-height: 1.8; color: var(--ink-soft); }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 800; }
input[type=text], select {
  width: 100%; padding: 11px 12px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; font-weight: 800; font-size: 16px;
}
.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; min-width: 0; }

/* ---- 行リスト ---- */
.list li + li { border-top: 2px solid var(--paper-line); }
.list .item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 2px; border: 0; background: none; text-align: left; }
.list .item b { display: block; font-size: 16px; font-weight: 800; }
.list .item small { display: block; font-size: 12px; color: var(--ink-soft); }
.list .item .grow { flex: 1; min-width: 0; }
.chev { font-size: 24px; font-weight: 800; }
.dot { flex: none; width: 16px; height: 16px; border: 2.5px solid var(--ink); border-radius: 50%; display: inline-block; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 8px 10px 0; padding: 8px 14px;
  border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 800; font-size: 15px;
}
.chip.on { background: var(--yellow); box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }

/* 朱色の落款ふうの印 */
.seal {
  display: inline-block; padding: 1px 7px; border: 2px solid currentColor; border-radius: 5px;
  color: var(--ink); font-size: 11px; font-style: normal; font-weight: 800; white-space: nowrap;
}
.seal.red { color: var(--red); transform: rotate(-3deg); }
.seal-btn { padding: 4px 9px; border: 2.5px solid var(--ink); border-radius: 7px; background: #fff; font-size: 12px; font-weight: 800; opacity: .45; }
.seal-btn.on { opacity: 1; background: var(--yellow); box-shadow: 0 2px 0 var(--ink); }
.stamp {
  flex: none; display: grid; place-items: center; width: 74px; height: 74px; border: 4px solid var(--red); border-radius: 50%;
  outline: 2px solid var(--red); outline-offset: -9px; color: var(--red); font-size: 32px; font-weight: 800; transform: rotate(-9deg);
}

/* 見出しタブ。選んだ札だけが下の線を越えて手前に出る */
.tabs { display: flex; align-items: flex-end; gap: 6px; margin: 18px 0 0; padding: 0 8px; border-bottom: 3px solid var(--ink); }
.tabs button {
  flex: 1; padding: 7px 4px 6px; border: 3px solid var(--ink); border-bottom: 0; border-radius: 10px 10px 0 0;
  background: #bfe5a4; font-size: 14px; font-weight: 800;
}
.tabs button.on { margin-bottom: -3px; padding: 10px 4px 9px; background: var(--grass); font-size: 15px; }

/* ---- 広場 ---- */
.post { padding: 12px 14px 14px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 var(--grass-deep); }
.post header { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.post header b { font-weight: 800; }
.post p { margin: 8px 0 10px; font-size: 15px; line-height: 1.7; }
.stamps { display: flex; flex-wrap: wrap; gap: 8px; }
.stamps button { padding: 5px 10px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; font-size: 13px; font-weight: 800; }
.stamps button.on { background: var(--orange); color: #fff; }

/* ---- 試合の準備 ---- */
.pl { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.pl + .pl { border-top: 2px solid var(--paper-line); }
.pl .nm { flex: 1; min-width: 0; font-weight: 800; }
.bdgs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.team { padding: 10px 12px; margin-top: 10px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; }
.team b { display: block; margin-bottom: 6px; font-size: 14px; }
.legend { display: grid; gap: 4px; margin-top: 10px; font-size: 12px; line-height: 1.6; color: var(--ink-soft); }
.legend b { color: var(--ink); }

/* ---- スコアボード ---- */
.board { min-height: 100dvh; margin: 0 -16px; padding: 0 0 calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; background: var(--bg-board, var(--grass)); background-size: cover; background-position: center; }
.board.wood { --bg-board: #e0b678; }
.board.chalk { --bg-board: #35523f; }
.board.sky { --bg-board: #bfe5f7; }
.scores { display: grid; gap: 12px; padding: 16px 16px 0; }
.ts { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ink); }
.ts.cur { background: var(--yellow); }
.ts.outt { opacity: .45; }
.ts .nm { flex: 1; min-width: 0; font-weight: 800; font-size: 15px; }
.ts .nm small { display: block; margin-top: 2px; font-size: 12px; font-weight: 500; line-height: 1.5; }
.ts .sc { font-size: 58px; font-weight: 800; line-height: 1; min-width: 2.1ch; text-align: right; font-variant-numeric: tabular-nums; }
.turn {
  margin: 20px 16px 0; padding: 12px 14px; background: var(--orange); color: #fff; text-align: center;
  font-size: 21px; font-weight: 800; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 5px 0 var(--ink);
}
.turn small { display: block; font-size: 12px; font-weight: 800; }
.hint { margin: 14px 16px 0; text-align: center; font-weight: 800; font-size: 16px; min-height: 24px; color: var(--ink); }
.board.chalk .hint, .board.photo .hint { color: #fff; }
.prompt { margin: 8px 16px 0; padding: 9px 12px; background: var(--paper); border: 3px solid var(--ink); border-radius: 10px; font-size: 14px; font-weight: 800; text-align: center; }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 16px; margin-top: auto; }
.pad button {
  height: 62px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; font-size: 28px; font-weight: 800; box-shadow: 0 5px 0 var(--ink);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1), box-shadow .2s cubic-bezier(.3, 1.6, .5, 1);
}
.pad button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); transition-duration: .04s; }
.pad .zero { grid-column: span 3; font-size: 18px; background: var(--paper); }
.pad .undo { font-size: 16px; background: var(--sky); }
.board.land .scores { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); flex: 1; min-height: 0; padding-top: 10px; }
.board.land .ts { flex-direction: column; justify-content: center; text-align: center; }
.board.land .ts .sc { font-size: min(26vh, 22vw); text-align: center; }
.board.land .bar { padding-top: 6px; padding-bottom: 6px; }
.board.land .turn { margin-top: 12px; padding: 6px; font-size: 17px; }
.board.land .hint { margin-top: 6px; min-height: 0; font-size: 18px; }
.board.land .pad { grid-template-columns: repeat(14, 1fr); gap: 5px; padding: 8px 12px; }
.board.land .pad button { height: 44px; font-size: 18px; box-shadow: 0 3px 0 var(--ink); }
.board.land .pad .zero { grid-column: auto; font-size: 13px; }
.board.land .pad .undo { font-size: 13px; }
.board.land .prompt { display: none; }
#app:has(.board.land) { max-width: none; }

.result { display: grid; gap: 14px; padding: 18px 16px 0; margin-top: auto; justify-items: center; text-align: center; }
.result h2 { font-size: 26px; font-weight: 800; background: #fff; padding: 4px 16px; border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink); }
.result .pop-btn { width: 100%; }

.big { font-size: 76px; font-weight: 800; line-height: 1.1; text-align: center; font-variant-numeric: tabular-nums; }

/* テーマ見本 */
.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.swatches button { height: 60px; border: 3px solid var(--ink); border-radius: 12px; font-weight: 800; font-size: 14px; }
.swatches button.on { box-shadow: 0 0 0 3px var(--yellow), 0 0 0 5.5px var(--ink); }

/* 読み物 */
.article h2 { font-size: 22px; line-height: 1.5; font-weight: 800; }
.article p { margin-top: 14px; font-size: 16px; line-height: 2; }

/* ---- 写真の確認・トースト ---- */
.cardimg { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; background: rgba(45, 59, 46, .92); }
.cardimg img { max-width: 100%; max-height: 78dvh; border: 4px solid var(--ink); border-radius: 12px; }
.cardimg p { margin: 0; color: #fff; font-weight: 800; text-align: center; }
#toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 70; transform: translate(-50%, 10px);
  padding: 10px 18px; background: var(--ink); color: #fff; border: 3px solid var(--ink); border-radius: 12px;
  font-weight: 800; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.board .bar { margin: 0; }
