:root {
  --ink: #1d2433;
  --ink-soft: #5b6377;
  --bg: #eef0f4;
  --paper: #ffffff;
  --line: #d5d9e2;
  --primary: #e0533a;
  --primary-dark: #a8341f;
  --face: #1d2433;
  --face-2: #283147;
  --digit: #ffd66b;
  --digit-soft: #9aa3b8;
  --ok: #1f8a4c;
  --ng: #c23b2e;
  --gold: #f2c14e;
  --font: "Zen Kaku Gothic New", system-ui, sans-serif;
  --num: "Martian Mono", ui-monospace, "Zen Kaku Gothic New", monospace;
}
* { 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; 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: 1fr 1.3fr auto; gap: 8px; }
.box { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px 8px; text-align: center; min-width: 0; }
.lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val { font: 700 22px/1.25 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.val small { font: 900 13px/1 var(--font); color: var(--ink-soft); margin-left: 2px; }
.menu-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 6px; color: var(--ink); font: 900 11px/1.2 var(--font); cursor: pointer; }
.menu-btn span { color: var(--ink-soft); }

/* 時計 */
.watch { margin: 10px 0 10px; padding: 10px 12px 10px; border-radius: 22px; background: var(--face); color: #fff; box-shadow: 0 10px 28px rgba(29, 36, 51, 0.25); text-align: center; }
.w-target { font-size: 15px; font-weight: 900; color: var(--digit-soft); }
.w-target b { font: 700 24px/1.2 var(--num); color: #fff; margin: 0 2px 0 6px; }
.w-face { position: relative; height: clamp(108px, 19dvh, 150px); margin: 4px 0 2px; border-radius: 16px; background: var(--face-2); display: grid; place-items: center; overflow: hidden; }
.w-digits { font: 700 clamp(58px, 18vw, 84px)/1 var(--num); font-variant-numeric: tabular-nums; color: var(--digit); letter-spacing: -0.02em; transition: opacity 0.35s, filter 0.35s; }
.w-face.off .w-digits { opacity: 0; filter: blur(8px); }
.w-face.stop .w-digits { color: #fff; transition: none; opacity: 1; filter: none; }
.w-hidden { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 16px; }
.w-face.off .w-hidden { display: flex; }
.w-hidden i { display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--digit-soft); opacity: 0.55; }
.w-err { position: absolute; left: 0; right: 0; bottom: 8px; font: 700 20px/1 var(--num); color: var(--digit); opacity: 0; }
.w-word { position: absolute; left: 0; right: 0; top: 8px; font: 900 16px/1 var(--font); color: var(--digit-soft); opacity: 0; }
.w-face.stop .w-digits { transform: translateY(-6px); }
.w-face.stop .w-err, .w-face.stop .w-word { opacity: 1; }
.w-face.pop .w-digits { animation: pop 0.38s ease-out; }
.w-face.pop .w-err { animation: rise 0.45s ease-out; }
@keyframes pop { 0% { transform: translateY(-6px) scale(1.25); } 60% { transform: translateY(-6px) scale(0.97); } 100% { transform: translateY(-6px) scale(1); } }
@keyframes rise { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }
/* ずれの段ごとの色 */
.g0 { color: var(--gold) !important; } .g1 { color: #8be0ae !important; } .g2 { color: #9fd0ff !important; } .g3 { color: #e9eaee !important; } .g4 { color: #ffb4a6 !important; }
/* 0.01秒以内: 金色に光る */
.w-face.gold { background: radial-gradient(circle at 50% 45%, #5a4410 0%, var(--face-2) 70%); }
.w-face.gold .w-digits { color: var(--gold); text-shadow: 0 0 18px rgba(242, 193, 78, 0.8); }
.w-burst { position: absolute; left: 50%; top: 45%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 4px solid var(--gold); opacity: 0; pointer-events: none; }
.w-face.gold .w-burst { animation: burst 0.9s ease-out; }
@keyframes burst { 0% { opacity: 1; transform: scale(0.4); } 100% { opacity: 0; transform: scale(9); } }
@media (prefers-reduced-motion: reduce) { .w-face.pop .w-digits, .w-face.pop .w-err, .w-face.gold .w-burst { animation: none; } .w-digits { transition: none; } }
.w-note { font-size: 13px; font-weight: 700; color: var(--digit-soft); min-height: 1.6em; }
.pips { list-style: none; display: flex; justify-content: center; gap: 6px; margin: 4px 0 0; padding: 0; }
.pips li { min-width: 76px; padding: 2px 6px; border-radius: 99px; background: var(--face-2); font: 700 13px/1.5 var(--num); color: var(--digit-soft); }
.pips li.cur { box-shadow: inset 0 0 0 2px var(--digit); color: #fff; }

/* 下半分の大きなボタン */
.big-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; height: max(220px, 42dvh); margin: 0; border: 0; border-radius: 26px; background: var(--primary); color: #fff; box-shadow: 0 6px 0 var(--primary-dark); cursor: pointer; touch-action: manipulation; font-family: var(--font); outline: none; }
.big-btn:focus-visible { box-shadow: 0 6px 0 var(--primary-dark), 0 0 0 4px #fff, 0 0 0 7px var(--ink); }
.big-btn.down { transform: translateY(4px); box-shadow: 0 2px 0 var(--primary-dark); }
.big-btn.run { background: #2d3a5c; box-shadow: 0 6px 0 #161d30; }
.big-btn.run.down { box-shadow: 0 2px 0 #161d30; }
.big-btn.wait { background: #8a90a0; box-shadow: 0 6px 0 #5b6377; }
.bb-main { font: 900 clamp(34px, 11vw, 46px)/1.1 var(--font); letter-spacing: 0.08em; }
.bb-sub { font-size: 14px; font-weight: 700; opacity: 0.85; padding: 0 12px; }

/* タイトル・結果（時計を隠して全体を見せる） */
.play.menu .bar, .play.menu .watch, .play.menu .big-btn { display: none; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(29, 36, 51, 0.1); }
.logo { margin: 0; font: 900 clamp(24px, 7.5vw, 31px)/1.3 var(--font); letter-spacing: 0.03em; }
.logo span { display: inline-block; white-space: nowrap; }
.day { margin: 2px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.demo { display: flex; flex-direction: column; align-items: center; width: 200px; margin: 0 auto 12px; padding: 8px 10px 10px; border-radius: 16px; background: var(--face); }
.demo-t { font-size: 12px; font-weight: 900; color: var(--digit-soft); }
.demo-d { font: 700 40px/1.1 var(--num); color: var(--gold); text-shadow: 0 0 12px rgba(242, 193, 78, 0.6); }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.daily-lbl, .prac-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.t-rounds { list-style: none; margin: 6px 0 4px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.t-rounds li { background: var(--bg); border-radius: 12px; padding: 6px 2px; line-height: 1.35; }
.t-rounds small { display: block; font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.t-rounds b { display: block; font: 700 21px/1.3 var(--num); color: var(--primary-dark); }
.t-rate { margin: 4px 0 0; font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.5; }
.t-rate b { color: var(--primary-dark); font-size: 16px; }
.t-rate small { display: block; font-size: 12px; color: var(--ink-soft); }
.clear-rate { font-size: 13px; font-weight: 900; color: var(--ink-soft); }
.c-pen { margin: 6px 0 0; padding: 6px 10px; border-radius: 10px; background: #fde9e4; color: var(--primary-dark); font-size: 13px; font-weight: 700; }
.daily-note { margin: 4px 0 8px; font-size: 13px; color: var(--ink-soft); }
.done { font-size: 15px; font-weight: 900; margin-top: 6px; }
.prac { border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 4px; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 6px 0; }
.chips button { min-width: 44px; min-height: 40px; padding: 4px 9px; border: 2px solid var(--line); border-radius: 99px; background: var(--paper); color: var(--ink); font: 900 14px/1.2 var(--font); cursor: pointer; touch-action: manipulation; }
.chips button[aria-pressed="true"] { border-color: var(--primary); background: #fde9e4; color: var(--primary-dark); }
.prac-stats { margin: 2px 0 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); min-height: 1.6em; }
.howto { list-style: none; margin: 12px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 14px; 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); }
.stats { font-size: 13px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 0; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 14px 10px; border: 0; border-radius: 14px; font: 900 17px/1.2 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); }
.btn small { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 4px; }
.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: 16px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 15px; }
.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-pre { margin-top: 6px; font-size: 13px; font-weight: 900; color: var(--ink-soft); }
.clear-big b { font: 700 58px/1.05 var(--num); font-variant-numeric: tabular-nums; }
.clear-big span { font: 900 20px/1 var(--font); margin-left: 4px; }
.clear-sub { margin: 4px 0 0; font-size: 14px; font-weight: 700; }
.best { display: block; width: max-content; margin: 10px auto 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.laps { list-style: none; margin: 12px 0 0; padding: 8px; border-radius: 14px; background: var(--face); color: #fff; }
.laps li { display: grid; grid-template-columns: 3.2em 1fr auto; align-items: baseline; gap: 6px; padding: 6px 6px; text-align: left; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.laps li:first-child { border-top: 0; }
.laps small { font-size: 12px; font-weight: 900; color: var(--digit-soft); }
.laps .l-t { font: 500 13px/1.3 var(--num); color: var(--digit-soft); }
.laps .l-t b { font-weight: 700; color: #fff; font-size: 15px; }
.laps .l-e { font: 700 18px/1.3 var(--num); text-align: right; }
.laps .l-e i { display: block; font: 900 11px/1.3 var(--font); font-style: normal; }
.rank { margin: 12px 0; padding: 8px; background: var(--bg); border-radius: 14px; }
.rank-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font: 900 22px/1.4 var(--font); }
.rank-basis { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.c-cmp { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.c-cmp b.up { color: var(--ok); } .c-cmp b.down { color: var(--ng); }
.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: 30%; transform: translate(-50%, -50%); z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(29, 36, 51, 0.94); 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 { display: flex; align-items: baseline; font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide h3 .num { flex: none; }
.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) {
  .bar { gap: 6px; }
  .box { padding: 4px 6px; }
  .val { font-size: 19px; }
  .pips li { min-width: 64px; }
}
