:root {
  --ink: #33231d;
  --ink-soft: #7a6258;
  --bg: #fbf1ea;
  --paper: #ffffff;
  --line: #f0dccf;
  --primary: #e2603a;
  --primary-dark: #a83a1c;
  --gold: #ffd25a;
  --star: #ffb320;
  --danger: #e5484d;
  --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 1.15fr 1fr 44px; gap: 6px; margin-bottom: 6px; }
/* 命（ハートの形は SVG を CSS の mask で） */
.lives { display: flex; justify-content: center; align-items: center; gap: 2px; height: 29px; }
.lives i { width: 17px; height: 15px; background: #e5484d; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 21'%3E%3Cpath d='M12 21 2.2 11.2A6 6 0 0 1 12 3.6a6 6 0 0 1 9.8 7.6z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 21'%3E%3Cpath d='M12 21 2.2 11.2A6 6 0 0 1 12 3.6a6 6 0 0 1 9.8 7.6z'/%3E%3C/svg%3E") center/contain no-repeat; transition: background 0.3s, transform 0.3s; }
.lives i.off { background: #d3d5e4; transform: scale(0.8); }
.lives.bump { animation: bump 0.35s ease-out; }
.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; }
.val small { font-size: 13px; color: var(--ink-soft); }
.score-box .val { color: var(--primary-dark); }
.score-box .val.bump { animation: bump 0.25s ease-out; }
@keyframes bump { 40% { transform: scale(1.15); } }
.menu-btn { display: grid; place-items: center; color: var(--ink-soft); cursor: pointer; padding: 0; }
.prog { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #f2a03c); border-radius: 3px; transition: width 0.3s; }

/* 塔 */
.stage { position: relative; }
#cv { display: block; width: 100%; max-width: calc((100svh - 230px) * 300 / 400); margin: 0 auto; aspect-ratio: 300 / 400; touch-action: none; cursor: default; border-radius: 18px; }
.hint { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 16px 10px; border-radius: 16px; background: rgba(20, 24, 54, 0.62); color: #fff; font-weight: 900; font-size: 15px; pointer-events: none; text-align: center; max-width: calc(100% - 24px); }
.hint svg { animation: sway 1.2s ease-in-out infinite; }
@keyframes sway { 0%, 100% { transform: translateX(-14px); } 50% { transform: translateX(14px); } }
.pause { position: absolute; top: 0; bottom: 0; left: 50%; width: 100%; max-width: calc((100svh - 230px) * 300 / 400); transform: translateX(-50%); display: grid; place-items: center; background: rgba(20, 24, 54, 0.35); border-radius: 18px; pointer-events: none; }
.pause span { padding: 10px 22px; border-radius: 999px; background: rgba(20, 24, 54, 0.8); color: #fff; font-weight: 900; font-size: 16px; }
.kbd { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* タイトル・結果（塔を隠して全体を見せる） */
.play.menu .bar, .play.menu .prog, .play.menu .stage, .play.menu .kbd { display: none; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 16px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(120, 60, 30, 0.12); }
.t-art { display: block; width: 220px; height: 130px; margin: 0 auto 2px; -webkit-mask-image: linear-gradient(transparent, #000 12%, #000 72%, transparent); mask-image: linear-gradient(transparent, #000 12%, #000 72%, transparent); }
.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: #fff6f0; }
.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); }
.dz { color: #b3262d; background: repeating-linear-gradient(-45deg, rgba(229, 72, 77, 0.2) 0 4px, transparent 4px 8px); padding: 0 2px; border-radius: 3px; }
.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 small { color: #ffe1d4; }
.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; }

/* 星（絵文字を使わず、CSS の形で） */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars i { width: 12px; height: 12px; background: #d3d5e4; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.stars i.on { background: var(--star); }
.c-stars { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.c-stars .stars i { width: 30px; height: 30px; }
.c-stars .stars i.on { animation: pop 0.4s ease-out backwards; }
.c-stars .stars i.on:nth-child(2) { animation-delay: 0.15s; }
.c-stars .stars i.on:nth-child(3) { animation-delay: 0.3s; }
@keyframes pop { 0% { transform: scale(0.2); } 70% { transform: scale(1.25); } }
.c-stars .new { padding: 2px 10px; border-radius: 999px; background: var(--gold); font-size: 12px; font-weight: 900; }

/* 練習ステージの一覧 */
.s-title { margin: 0; font: 900 20px/1.4 var(--font); }
.s-sum { margin: 2px 0 0; font-size: 13px; font-weight: 900; color: var(--ink-soft); }
.s-note { margin: 4px 0 10px; font-size: 11px; color: var(--ink-soft); }
.s-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.st { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 800 15px/1 var(--num); color: var(--ink); cursor: pointer; min-width: 0; }
.st .stars i { width: 9px; height: 9px; }
.st.done { background: var(--paper); }
.st.cur { box-shadow: inset 0 0 0 2px var(--primary); }
.st small { font: 700 9px/1 var(--font); color: var(--ink-soft); }

/* 結果 */
.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-tower { height: 10px; margin: 10px auto 0; max-width: 260px; border-radius: 5px; background: var(--line); overflow: hidden; }
.c-tower i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #f2a03c); }
.c-detail { margin: 6px 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; }
.gap { margin: 8px 0 0; font-size: 13px; font-weight: 900; color: var(--primary-dark); }
.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: 30%; transform: translate(-50%, -50%); z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(35, 40, 69, 0.9); color: #fff; font-weight: 900; font-size: 15px; text-align: center; pointer-events: none; }

/* 下の解説（ポータルと同じ決まり: 行間 1.85・段落の間は1行分・見出しは前を広く後ろを狭く） */
.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; }
  .st { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .score-box .val.bump, .c-stars .stars i.on, .hint svg, .lives.bump { animation: none; }
}

/* ブロックくずし: 上の帯は 点数・面・玉・メニュー */
.bar { grid-template-columns: 1.5fr 1fr 1fr 44px; }
.balls { display: flex; justify-content: center; align-items: center; gap: 4px; height: 29px; }
.balls i { width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #ffd23f 45%, #f29a1c); transition: transform 0.3s, background 0.3s; }
.balls.bump { animation: bump 0.35s ease-out; }
.balls i.off { background: #e6d8cf; transform: scale(0.7); }
/* バーを動かす帯（キャンバスの下）。指でバーや玉を隠さずに、ここを左右になぞって動かせる */
.padzone { display: flex; align-items: center; justify-content: center; gap: 8px; height: 62px; margin: 6px auto 0; max-width: calc((100svh - 230px) * 300 / 400); border-radius: 16px; background: repeating-linear-gradient(90deg, #f6e4d8 0 10px, #fbefe7 10px 20px); color: var(--ink-soft); font-size: 13px; font-weight: 900; touch-action: none; user-select: none; -webkit-user-select: none; cursor: ew-resize; }
.padzone svg { flex: none; }
.play.menu .padzone { display: none; }
/* 今日の3つの絵（タイトル: かげだけ・こわした絵は色つき） */
.pics { display: flex; justify-content: center; gap: 8px; margin: 6px 0 4px; }
.pic { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 86px; padding: 6px 0 4px; border-radius: 12px; background: #2a2340; }
.pic canvas { width: 72px; height: 60px; image-rendering: pixelated; }
.pic span { font-size: 11px; font-weight: 900; color: #f3e6ff; white-space: nowrap; }
.c-pics { margin: 10px 0 0; }
.yday { margin: 4px 0 10px; padding: 8px 6px 4px; border-radius: 14px; background: var(--bg); }
.yday .pic { width: 78px; }
.st canvas { width: 36px; height: 30px; image-rendering: pixelated; border-radius: 4px; background: #2a2340; }
.s-grid { grid-template-columns: repeat(4, 1fr); }
.st { font-size: 13px; }
.st b { font: 800 13px/1 var(--num); }
.t-art { width: 260px; height: 120px; -webkit-mask-image: none; mask-image: none; border-radius: 14px; }
