:root {
  --bg: #eaf4fb;
  --card: #ffffff;
  --ink: #23323f;
  --ink-soft: #66788a;
  --line: #d5e3ee;
  --accent: #4aa3d8;
  --accent-ink: #ffffff;
  --mint: #5cc6a8;
  --gold: #d9a43a;
  --board: #e9d6b4;
  --board-edge: #cfb68c;
  --pit: #d8bf95;
  --pit-in: #c9ad7f;
  --store: #d3b887;
  --hot: #fff4c8;
  --bubble: #ffffff;
  --shadow: 0 2px 10px rgba(40, 70, 100, .08);
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14202b;
    --card: #1d2c39;
    --ink: #e6eef5;
    --ink-soft: #9db0c1;
    --line: #2d4152;
    --accent: #5fb4e6;
    --accent-ink: #0f1a24;
    --board: #4a3b2a;
    --board-edge: #3a2e21;
    --pit: #3a2e21;
    --pit-in: #2f251a;
    --store: #3d3023;
    --hot: #5c5131;
    --bubble: #253747;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; touch-action: pan-x pan-y; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input { font: inherit; color: inherit; }
input { font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%; }

.app { max-width: 760px; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.side, .main { display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.card.mini { font-size: 14px; color: var(--ink-soft); }
.card.mini b { color: var(--ink); font-weight: 700; }

/* Soraのカード */
.sora-card { background: var(--card); border-radius: 20px; padding: 12px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.sora-pic { width: 96px; height: 96px; flex: none; border-radius: 50%; overflow: hidden; background: var(--bg); }
.sora-pic img, .sora-pic svg { width: 100%; height: 100%; display: block; object-fit: cover; }
.bubble { flex: 1; min-height: 64px; background: var(--bubble); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; font-size: 16px; line-height: 1.6; position: relative; transition: opacity .3s; }
.bubble.old { opacity: .55; }
.bubble:empty::after { content: "…"; color: var(--ink-soft); }
.dots span { display: inline-block; width: 6px; height: 6px; margin: 0 3px; border-radius: 50%; background: var(--ink-soft); opacity: .3; }
.playing .dots span { animation: dot 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.playing .sora-pic > * { animation: breathe 4.5s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@media (prefers-reduced-motion: reduce) {
  .playing .sora-pic > *, .playing .dots span { animation: none; }
  .dots span { opacity: .6; }
}

/* 盤 */
.turn { text-align: center; font-weight: 700; font-size: 16px; min-height: 24px; }
.turn small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-soft); }
.board-wrap { background: var(--board); border: 3px solid var(--board-edge); border-radius: 28px; padding: 10px; box-shadow: var(--shadow); }
.board { display: grid; grid-template-columns: 1fr repeat(6, minmax(0, 1.15fr)) 1fr; grid-template-rows: auto auto; gap: 6px; align-items: center; }
.store { grid-row: 1 / 3; align-self: stretch; background: var(--store); border-radius: 22px; box-shadow: inset 0 2px 6px rgba(0,0,0,.18); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 2px; min-height: 150px; position: relative; }
.store .who { font-size: 10px; white-space: nowrap; color: var(--ink-soft); position: absolute; top: 6px; }
.store .n { font-size: 26px; font-weight: 800; }
.pit { aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--pit); box-shadow: inset 0 3px 6px rgba(0,0,0,.2); display: flex; align-items: center; justify-content: center; position: relative; padding: 0; transition: background .15s, box-shadow .15s; }
.pit .n { position: absolute; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.pit.top .n { top: -16px; }
.pit.bottom .n { bottom: -16px; }
.board .row-gap { height: 0; }
.pit.can { cursor: pointer; box-shadow: inset 0 3px 6px rgba(0,0,0,.2), 0 0 0 3px var(--accent); }
.pit.hot, .store.hot { background: var(--hot); }
.pit.pick { box-shadow: inset 0 3px 6px rgba(0,0,0,.2), 0 0 0 3px var(--mint); }
.pit.cap, .store.cap { box-shadow: inset 0 3px 6px rgba(0,0,0,.2), 0 0 0 3px var(--gold); }
.board { row-gap: 22px; padding: 14px 0; }
.seeds { width: 78%; height: 78%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 2px; pointer-events: none; }
.store .seeds { width: 90%; height: auto; max-height: 70%; overflow: hidden; }
.seed { width: 9px; height: 9px; border-radius: 50%; box-shadow: inset -1px -1px 1px rgba(0,0,0,.25); }
.seeds.many .seed { width: 6px; height: 6px; }
.s0 { background: #7fb7d9; } .s1 { background: #e9a7a0; } .s2 { background: #9fd1b5; } .s3 { background: #f0d38a; } .s4 { background: #c4b0e0; }

/* ボタン */
.row-btns, .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 18px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.small { padding: 4px 12px; font-size: 14px; }

/* 記録 */
details.card summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.log { margin: 10px 0 0; padding-left: 22px; font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.log li.sora { color: var(--ink); }
.log .meta { color: var(--ink-soft); font-size: 12px; }
.update { background: var(--card); border: 1px solid var(--mint); border-radius: 14px; padding: 10px 14px; text-align: center; font-size: 14px; }
.ver { text-align: center; font-size: 11px; color: var(--ink-soft); margin: 0; }

/* シート */
.sheet { border: 0; border-radius: 22px 22px 0 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; background: var(--card); color: var(--ink); }
.sheet::backdrop { background: rgba(10, 20, 30, .4); }
.sheet form { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.field { margin-bottom: 14px; }
.lab { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.chip small { display: block; font-size: 11px; color: var(--ink-soft); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.on small { color: inherit; opacity: .8; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 10px 0; }
.check input { width: auto; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { width: 110px; }
.note { font-size: 13px; color: var(--ink-soft); }

/* 幅 700px 以上 */
@media (min-width: 700px) {
  .sora-pic { width: 120px; height: 120px; }
  .seed { width: 11px; height: 11px; }
  .seeds.many .seed { width: 8px; height: 8px; }
  .store .n { font-size: 32px; }
  .store { min-height: 200px; }
}
/* 横向きの広い画面：左にSora、右に盤 */
@media (orientation: landscape) and (min-width: 1000px) {
  .app { max-width: 1240px; flex-direction: row; align-items: flex-start; gap: 20px; padding: 20px; }
  .side { width: 350px; flex: none; position: sticky; top: 20px; }
  .main { flex: 1; min-width: 0; }
  .sora-card { flex-direction: column; text-align: left; }
  .sora-pic { width: 220px; height: 220px; }
  .bubble { width: 100%; min-height: 90px; font-size: 17px; }
  .sheet { border-radius: 22px; margin: auto; }
}
