:root {
  --ink: #1f3328;
  --ink-soft: #587263;
  --bg: #edf6ee;
  --paper: #ffffff;
  --line: #d3e6d6;
  --primary: #2e9d5b;
  --primary-dark: #1f6e40;
  --gold: #ffd25a;
  --c0: #e5484d;
  --c1: #f2b01e;
  --c2: #3d7fe0;
  --font: "Zen Maru Gothic", system-ui, sans-serif;
  --num: "M PLUS Rounded 1c", "Zen Maru Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 500; line-height: 1.7; line-break: strict; }
.hidden { display: none !important; }
.nw { white-space: nowrap; }

.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 520px; margin: 0 auto; font-size: 13px; font-weight: 900; }
.g-brand { color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.g-title { flex: 1; text-align: center; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-head [data-mg-account] a { color: var(--primary-dark); text-decoration: none; }

main { max-width: 520px; margin: 0 auto; padding: 0 12px 24px; }
.play { position: relative; user-select: none; -webkit-user-select: none; }

/* 上の帯 */
.bar { display: grid; grid-template-columns: 1.4fr 1fr 1fr 44px; gap: 6px; margin-bottom: 6px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px; text-align: center; min-width: 0; }
.lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; }
.val { font: 800 22px/1.3 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.score-box .val { color: var(--primary-dark); }
.val.bump { animation: bump 0.25s ease-out; }
#mult.m2 { color: #d9822b; }
#mult.m3 { color: #e5484d; }
#time.low { color: #e5484d; }
@keyframes bump { 40% { transform: scale(1.18); } }
.menu-btn { display: grid; place-items: center; color: var(--ink-soft); cursor: pointer; padding: 0; }
.next { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 3px 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.next-row { display: flex; gap: 6px; align-items: center; }
.next-row i { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #f3f8f3; }
.next-row i svg { width: 19px; height: 19px; display: block; }
.next-row i:first-child { width: 26px; height: 26px; outline: 2px solid var(--ink-soft); outline-offset: 1px; }
.next-row i:first-child svg { width: 23px; height: 23px; }
#mult { display: flex; align-items: center; justify-content: center; gap: 2px; }
#mult .fr svg { width: 22px; height: 22px; display: block; }
.next-len { margin-left: auto; }
.next-len b { font: 800 16px/1 var(--num); color: var(--ink); }
#spd-box { display: inline-block; }
#spd-box em { display: none; margin-left: 3px; font: 800 11px/1 var(--num); font-style: normal; color: #fff; background: #e5484d; border-radius: 6px; padding: 2px 4px; vertical-align: 2px; }
#spd-box.up b { color: #e5484d; }
#spd-box.up em { display: inline-block; }
#spd-box.up { animation: spdup 1.2s ease-out; }
@keyframes spdup { 0% { transform: scale(1); } 12% { transform: scale(1.25); } 30%, 100% { transform: scale(1); } }

/* 盤 */
.stage { position: relative; touch-action: none; }
#cv { display: block; width: 100%; max-width: calc((100svh - 190px) * 13 / 15); margin: 0 auto; aspect-ratio: 13 / 15; touch-action: none; border-radius: 16px; }
.play.pad-on #cv { max-width: calc((100svh - 350px) * 13 / 15); min-width: 170px; }
/* 遊んでいるあいだは、画面のどこをスワイプしてもページを動かさない（下へ引いても読み直さない） */
html.hebi-run, html.hebi-run body { touch-action: none; overscroll-behavior: none; }
html.hebi-run .play { -webkit-touch-callout: none; touch-action: none; }
.hint { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 18px 12px; border-radius: 16px; background: rgba(18, 40, 28, 0.66); color: #fff; font-weight: 900; font-size: 15px; pointer-events: none; text-align: center; max-width: calc(100% - 24px); line-height: 1.5; }
.hint small { font-size: 12px; opacity: 0.9; }
.hint svg { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.86); } }
/* 止めているあいだは盤を見せない（止めて考えて、有利にならないように） */
.pause { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #2b4a37; border-radius: 16px; pointer-events: none; padding: 16px; text-align: center; }
.pause span { padding: 10px 22px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 900; font-size: 17px; }
.pause b { color: #ffe08a; font-weight: 900; font-size: 18px; line-height: 1.5; }
.pause small { color: #d6eadb; font-weight: 700; font-size: 13px; line-height: 1.6; max-width: 280px; }
.count { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font: 800 72px/1 var(--num); color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.kbd { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* 矢印ボタン（十字） */
.pad { display: grid; grid-template-columns: repeat(3, 76px); grid-template-rows: repeat(3, 58px); gap: 4px; justify-content: center; margin-top: 8px; touch-action: none; }
@media (max-height: 640px) { .pad { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 42px); margin-top: 6px; } .play.pad-on #cv { max-width: calc((100svh - 290px) * 13 / 15); } }
.pb { border: 0; border-radius: 14px; background: var(--paper); box-shadow: 0 3px 0 var(--line); display: grid; place-items: center; cursor: pointer; padding: 0; touch-action: none; }
.pb svg { width: 28px; height: 28px; fill: var(--primary-dark); }
.pb.on { background: #d9f0de; transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.pb.up { grid-column: 2; grid-row: 1; } .pb.lf { grid-column: 1; grid-row: 2; } .pb.rt { grid-column: 3; grid-row: 2; } .pb.dn { grid-column: 2; grid-row: 3; }

/* タイトル・結果 */
.play.menu .bar, .play.menu .next, .play.menu .stage, .play.menu .kbd, .play.menu .pad { display: none !important; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 16px; text-align: center; box-shadow: 0 10px 30px rgba(30, 80, 50, 0.12); }
.t-art { display: block; width: 220px; height: 100px; margin: 0 auto 4px; }
.logo { margin: 0; font: 900 27px/1.3 var(--font); letter-spacing: 0.02em; white-space: nowrap; color: var(--primary-dark); }
.day { margin: 2px 0 6px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.t-rule { margin: 2px 0 12px; font-weight: 900; font-size: 15px; line-height: 1.6; }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 12px; margin-bottom: 10px; background: #f3fbf4; }
.daily-lbl { font-size: 12px; font-weight: 900; color: var(--primary-dark); letter-spacing: 0.1em; }
.daily-name { font: 900 22px/1.4 var(--font); color: var(--primary-dark); }
.daily-par { font-size: 13px; font-weight: 900; color: var(--ink-soft); margin-top: 2px; }
.daily-note { margin: 4px 0 8px; font-size: 12px; color: var(--ink-soft); }
.done { font-size: 14px; font-weight: 900; margin-top: 6px; }
.howto { list-style: none; margin: 12px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 13px; font-weight: 700; }
.howto li { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.howto .num { flex: none; font-weight: 900; color: var(--primary); }
.howto .c0 { color: var(--c0); }
.opt { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font: 900 13px/1.2 var(--font); color: var(--ink); cursor: pointer; }
.chip b { color: var(--primary-dark); }
.stats { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 0; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 13px 10px; border: 0; border-radius: 14px; font: 900 16px/1.2 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); }
.btn small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-top: 3px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--primary-dark); }
.btn.sub { font-size: 15px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 14px; }
.btn.x { background: #000; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.clear-lbl { font-size: 13px; font-weight: 900; color: var(--primary-dark); }
.clear-score { margin: 4px 0 0; }
.clear-score b { font: 800 56px/1.1 var(--num); font-variant-numeric: tabular-nums; color: var(--primary-dark); }
.clear-score span { font: 900 18px/1 var(--font); margin-left: 4px; }
.clear-sub { margin: 2px 0 0; font-size: 15px; font-weight: 900; }
.c-eat { display: flex; justify-content: center; gap: 14px; margin: 10px 0 0; font: 800 16px/1 var(--num); }
.c-eat span { display: flex; align-items: center; gap: 5px; }
.c-eat i { display: block; width: 16px; height: 16px; border-radius: 50%; }
.c-eat .c0 { background: var(--c0); } .c-eat .c1 { background: var(--c1); } .c-eat .c2 { background: var(--c2); }
.c-detail { margin: 8px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.best { display: block; width: max-content; max-width: 100%; margin: 8px auto 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.rank { margin: 12px 0; padding: 8px; background: var(--bg); border-radius: 14px; }
.rank-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font: 900 22px/1.4 var(--font); }
.c-note { margin: 8px 0; padding: 8px 10px; border-radius: 12px; background: #fff6dd; font-size: 13px; font-weight: 700; text-align: left; }
.share { margin: 8px 0; }

.toast { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(31, 51, 40, 0.9); color: #fff; font-weight: 900; font-size: 15px; text-align: center; pointer-events: none; }

.guide { margin-top: 28px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px 12px; font-size: 15px; line-height: 1.85; }
.guide p { margin: 0 0 1em; }
.guide h2 { font: 900 19px/1.4 var(--font); margin: 32px 0 12px; padding-left: 10px; border-left: 5px solid var(--primary); }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide ul { padding-left: 1.3em; margin: 0 0 1em; }
.guide li { margin: 6px 0; }
.guide .steps { list-style: none; padding: 0; }
.guide .steps li { display: flex; align-items: baseline; gap: 6px; }
.guide .steps .num { flex: none; font-weight: 900; color: var(--primary); }
.guide details { border-top: 1px solid var(--line); padding: 12px 0; }
.guide details p { margin: 8px 0 4px; }
.guide summary { font-weight: 900; cursor: pointer; }
.guide a { color: var(--primary-dark); }
.g-foot { max-width: 520px; margin: 0 auto; padding: 14px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }

.card-ui .mg-box { background: var(--bg); border-color: transparent; }
@media (max-width: 360px) {
  .val { font-size: 19px; }
  .logo { font-size: 23px; }
  .clear-score b { font-size: 48px; }
  .g-head { gap: 6px; padding: 10px 10px; font-size: 12px; }
  .pad { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 48px); }
}
@media (prefers-reduced-motion: reduce) {
  .val.bump, .hint svg { animation: none; }
}
