:root {
  --paper: #fbf7ee;
  --ink: #2b2622;
  --sub: #8a7f74;
  --shu: #d2553f;
  --line: #e7b3a6;
  --m: min(40px, calc((100vw - 64px) / 8));
  --kana: 'Klee One', 'Zen Maru Gothic', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: 'Zen Maru Gothic', system-ui, -apple-system, 'Hiragino Sans', sans-serif;
  font-weight: 500;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
main {
  max-width: 460px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; border: 1.5px solid #d9cfc2; color: var(--ink); font-size: 16px; padding: 11px 16px; }
.btn.ghost.fresh { border-color: var(--shu); color: var(--shu); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.02); } }
.btn.x { display: inline-flex; align-items: center; justify-content: center; gap: 4px; background: #000; color: #fff; }
.btn.x svg { width: 18px; height: 18px; }
.note { color: var(--sub); font-size: 13px; text-align: center; margin: 8px 0; line-height: 1.6; }

/* --- タイトル --- */
.title { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding-top: max(36px, env(safe-area-inset-top)); }
.logo { display: flex; justify-content: center; margin: 0; }
.logo span {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border: 2px solid var(--shu);
  margin-left: -2px;
  font-family: var(--kana);
  font-size: 40px;
  background: #fff;
}
.tag { text-align: center; margin: 0; font-size: 17px; letter-spacing: .08em; }
.today { background: #fff; border-radius: 16px; padding: 14px 12px 16px; text-align: center; box-shadow: 0 1px 0 #e9e0d3; }
.today .no { color: var(--sub); font-size: 13px; }
.today .odai { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin: 6px 0 2px; }
.today .odai b { font-family: var(--kana); font-size: 46px; line-height: 1.1; color: var(--shu); }
.today .odai span { font-size: 15px; }
.today .odai i { font-style: normal; color: var(--sub); margin: 0 6px; }
.today .n { font-size: 16px; font-weight: 700; }
.rule { text-align: center; margin: 0; font-size: 14px; line-height: 1.7; color: var(--ink); }
.rule b { color: var(--shu); }
.foot { text-align: center; }

/* --- マス目 --- */
.rows { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: flex-start; gap: 6px; }
.row .idx { width: 18px; padding-top: calc(var(--m) / 2 - 9px); font-size: 13px; color: var(--sub); text-align: right; flex: none; }
.row .body { min-width: 0; }
.masu { display: flex; align-items: center; position: relative; }
.masu .m {
  width: var(--m); height: var(--m);
  flex: none;
  display: grid; place-items: center;
  border: 1.5px solid var(--line);
  margin-left: -1.5px;
  background: #fff;
  font-family: var(--kana);
  font-size: calc(var(--m) * .62);
  line-height: 1;
}
.masu .m:first-child { margin-left: 0; }
.masu .m.ghost { color: #cbbfb2; }
.masu .m.on { color: var(--ink); }
.masu.bad .m { border-color: var(--shu); }
.masu .over { margin-left: 4px; color: var(--shu); font-weight: 700; font-size: 13px; }
.goaltag { margin-left: auto; color: var(--shu); font-weight: 700; }
.row.next .masu .m { background: transparent; border-style: dashed; border-color: #ead7cf; }
.row.cur .masu .m { border-color: var(--shu); }
.row .sub { display: flex; align-items: center; gap: 8px; min-height: 20px; font-size: 13px; padding: 2px 2px 0; }
.row .disp { color: var(--sub); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.len { color: var(--sub); }
.len.max { color: var(--shu); font-weight: 700; }
.pt { color: var(--ink); font-weight: 700; white-space: nowrap; }
.pt.solo { color: #2f8a4a; }
.pt.live { color: var(--sub); font-weight: 500; }
.del { border: 0; background: #efe7dc; border-radius: 999px; width: 26px; height: 26px; line-height: 26px; padding: 0; font-size: 16px; cursor: pointer; }

/* --- 遊ぶ --- */
.ptop, .rtop { display: flex; align-items: center; gap: 8px; height: 40px; }
.ptop .back, .rtop .back { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 6px 4px 0; cursor: pointer; }
.ptop .no, .rtop .no { color: var(--sub); font-size: 14px; }
.ptop .odai, .rtop .odai { font-family: var(--kana); font-size: 20px; color: var(--shu); }
.ptop .sum { margin-left: auto; font-size: 14px; }
.ptop .sum b { font-size: 22px; }
.ptop .sum small { color: var(--sub); }
.rtop .tag { margin-left: auto; font-size: 13px; color: var(--sub); }
.entry { display: flex; gap: 8px; margin-top: 12px; }
.entry[hidden] { display: none; }
.entry input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 18px;
  padding: 11px 12px;
  border: 1.5px solid #d9cfc2; border-radius: 12px;
  background: #fff; color: var(--ink);
  outline: none;
}
.entry input:focus { border-color: var(--ink); border-width: 2px; padding: 10.5px 11.5px; }
.entry input::placeholder { color: #b5aa9e; font-size: 15px; }
.btn.put { width: auto; flex: none; padding: 0 18px; font-size: 17px; background: var(--ink); color: var(--paper); }
.msg { min-height: 22px; margin: 6px 2px 0; color: var(--shu); font-size: 14px; }
.msg.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.fin { margin-top: 10px; }
.fin[hidden] { display: none; }

/* --- 出したあと・結果 --- */
.done h2, .result h2 { font-size: 20px; margin: 14px 0 4px; text-align: center; }
.done h2 b, .result h2 b { font-size: 30px; color: var(--shu); }
.prov { text-align: center; margin: 12px 0 0; font-size: 15px; }
.prov b { font-size: 22px; }
.prov small { color: var(--sub); }
.wait { text-align: center; margin: 6px 0 14px; }
.wait b { font-variant-numeric: tabular-nums; font-size: 20px; }
.share { margin: 12px 0 4px; }
.done > .btn.ghost, .result > .btn { margin-top: 14px; }
.loading { text-align: center; color: var(--sub); padding-top: 40vh; }
.score { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin-top: 10px; }
.score b { font-size: 58px; line-height: 1; color: var(--shu); font-variant-numeric: tabular-nums; }
.score span { font-size: 20px; font-weight: 700; }
.rank { text-align: center; font-size: 17px; font-weight: 700; margin-top: 4px; }
.rank small { color: var(--sub); font-weight: 500; font-size: 14px; }
.board { background: #fff; border-radius: 16px; padding: 12px 14px 14px; margin-top: 18px; }
.board h3 { margin: 0 0 6px; font-size: 16px; }
.board h3 small { color: var(--sub); font-weight: 500; font-size: 13px; }
.board h4 { margin: 12px 0 6px; font-size: 13px; color: var(--sub); font-weight: 700; }
.board .top { margin: 0; padding: 0 0 0 1.4em; font-size: 15px; }
.board .top li { display: flex; justify-content: space-between; padding: 2px 0; }
.board .top .c { color: var(--sub); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #f3eee5; border-radius: 999px; padding: 4px 10px; font-size: 14px; }
.chip small { color: var(--sub); margin-left: 4px; font-size: 11px; }
.credit { text-align: center; font-size: 11px; color: var(--sub); margin-top: 18px; }
.credit a { color: inherit; }
.vsline { text-align: center; margin: 8px 0 0; font-size: 15px; }
.vsline b { color: var(--shu); font-size: 18px; }
.ptop + .vsline { margin: 2px 0 0; font-size: 14px; }
.vsbox { background: #fff; border-radius: 16px; padding: 12px 14px; margin-top: 14px; text-align: center; }
.vsbox h3 { margin: 0; font-size: 16px; }
.vsbox h3 small { color: var(--sub); font-weight: 500; font-size: 13px; }
.vsbox .wl { font-size: 30px; font-weight: 900; margin: 4px 0; }
.vsbox .wl.win { color: #2f8a4a; }
.vsbox .wl.lose { color: var(--sub); }
.vslist { list-style: none; margin: 6px 0 0; padding: 0; text-align: left; font-size: 15px; }
.vslist li { display: flex; gap: 8px; padding: 3px 0; border-top: 1px solid #f1ebe1; }
.vslist .a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vslist .p { color: var(--sub); font-variant-numeric: tabular-nums; }
.vslist b { width: 1.4em; text-align: center; }
.vslist b.win { color: #2f8a4a; } .vslist b.lose { color: var(--sub); }
.challenge h2 { line-height: 1.5; }
.claim { margin-top: 14px; font-size: 14px; }
.claim summary { text-align: center; color: var(--sub); cursor: pointer; list-style: none; text-decoration: underline; }
.claim summary::-webkit-details-marker { display: none; }
.claim .entry { margin-top: 8px; }
.devclock { position: fixed; left: 6px; bottom: 6px; z-index: 50; padding: 3px 8px; border-radius: 6px; background: #2b2622; color: #fff; font-size: 11px; opacity: .85; pointer-events: none; }
/* 置いた行を押印のように（ドン）。 */
.row.pop .masu { animation: stamp .3s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: 30% 50%; }
.row.pop .sub { animation: fadein .25s .12s both; }
@keyframes stamp { from { transform: scale(1.22); opacity: 0; } 55% { opacity: 1; } to { transform: scale(1); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .row.pop .masu, .row.pop .sub { animation: none; } }
