:root {
  --ink: #1f2b33;
  --ink-soft: #5b6872;
  --bg: #e9efe8;
  --paper: #ffffff;
  --line: #ccd8cf;
  --primary: #2f7a63;
  --primary-dark: #1f5646;
  --hedge: #2c5b47;
  --floor: #f5eedb;
  --trail: #ff8a1f;
  --gold: #f2b92c;
  --blue: #3b7be0;
  --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%; }
html.meiro-run, html.meiro-run body { overscroll-behavior: none; }
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; }
.g-title { flex: 1; text-align: center; }
.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.3fr 1fr 0.9fr; gap: 6px; margin-bottom: 8px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 5px 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; }
.val { font: 700 20px/1.25 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 4px; }
.val small { font-size: 13px; color: var(--ink-soft); }
.val .key { width: 22px; height: 22px; }
.val .key.off { opacity: 0.22; }

/* 盤（SVG。1マス = 1 の大きさで描く。game.js が大きさを決めて描く） */
.wrap { position: relative; touch-action: none; padding: 6px 0; display: flex; justify-content: center; }
.board { display: block; border-radius: 12px; background: var(--hedge); box-shadow: 0 10px 26px rgba(31, 86, 70, 0.3); touch-action: none; }
.board.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.bd .ring { fill: none; stroke: #fff; stroke-width: 0.08; animation: ring 1.3s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ring { 0% { transform: scale(0.7); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.bd .goalglow { animation: glow 1.2s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes glow { from { transform: scale(0.92); } to { transform: scale(1.08); } }
.bd.win .goalglow { animation: win 0.5s ease-in-out infinite alternate; }
@keyframes win { from { transform: scale(1) rotate(-8deg); } to { transform: scale(1.25) rotate(8deg); } }
.bd .pick { animation: pick 0.5s ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes pick { 0% { transform: scale(1.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
/* 指のまわりを大きく写す窓（おおきな迷路だけ。なぞっているあいだ、盤の上・指と反対がわ） */
.loupe { position: absolute; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); background: var(--hedge); pointer-events: none; z-index: 6; }
.demo { display: block; width: 104px; height: 104px; margin: 0 auto 10px; border-radius: 14px; background: var(--hedge); }
.demo .tr { fill: none; stroke: var(--trail); stroke-width: 0.34; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 9; stroke-dashoffset: 9; animation: demo 3.4s ease-in-out infinite; }
@keyframes demo { 0%, 8% { stroke-dashoffset: 9; } 60%, 88% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .bd .ring, .bd .goalglow, .bd.win .goalglow, .bd .pick, .board.shake { animation: none; }
  .demo .tr { animation: none; stroke-dashoffset: 0; }
}

.msg { margin: 6px 0 0; min-height: 1.7em; font-size: 13px; font-weight: 700; color: var(--ink-soft); text-align: center; }
.msg.warn { color: #b0402d; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; touch-action: manipulation; }
.tools:has(#b-reset.hidden) { grid-template-columns: 1fr; }
.tools .tool { flex-direction: column; justify-content: center; gap: 3px; padding: 8px 2px; font-size: 12px; white-space: nowrap; min-height: 50px; }
.tool { display: inline-flex; align-items: center; gap: 4px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 13px/1 var(--font); cursor: pointer; touch-action: manipulation; }
.tool:disabled { opacity: 0.35; cursor: default; }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .wrap, .play.menu .msg, .play.menu .tools { 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(31, 43, 51, 0.1); touch-action: manipulation; }
.logo { margin: 0; font: 900 28px/1.3 var(--font); letter-spacing: 0.04em; white-space: nowrap; }
.day { margin: 2px 0 12px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.daily-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.daily-name { font: 900 22px/1.4 var(--font); color: var(--primary-dark); }
.daily-name .kd { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: #b98a1c; color: #fff; font-size: 13px; vertical-align: 3px; }
.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; }
.free-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); margin: 6px 0 4px; }
.free-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.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); }
.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.lv { margin: 0; font-size: 13px; padding: 9px 1px; }
.btn.sub { font-size: 14px; }
.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-time { margin: 6px 0; }
.clear-time b { font: 700 56px/1 var(--num); font-variant-numeric: tabular-nums; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
/* 迷わず度（最短の道 ÷ 歩いた長さ）の10マスの帯 */
.eff { display: flex; justify-content: center; gap: 3px; margin: 8px 0 2px; }
.eff i { width: 18px; height: 18px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); }
.eff i.on { background: var(--trail); border-color: #e07410; }
.eff-l { font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.star { width: 20px; height: 20px; fill: #d9dfe0; }
.star.on { fill: var(--gold); }
.c-stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 6px; }
.c-stars .star { width: 38px; height: 38px; }
.c-stars .star.on { filter: drop-shadow(0 2px 0 #c8962b); }
/* ステージの一覧 */
.stages-h { margin: 0 0 10px; font: 900 22px/1.3 var(--font); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.tab { padding: 7px 2px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 13px/1.2 var(--font); cursor: pointer; touch-action: manipulation; }
.tab small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.tab.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.tab.on small { color: #d6efe6; }
.stage-sum { margin: 10px 0 8px; font-size: 13px; font-weight: 900; color: var(--ink-soft); }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 6px; touch-action: manipulation; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); cursor: pointer; font-family: var(--font); }
.stage b { font: 700 15px/1.1 var(--num); }
.stage .st { display: flex; gap: 0; height: 12px; }
.stage .star { width: 12px; height: 12px; }
.stage.clear { background: #e8f5ef; border-color: #a9d3c2; }
.stage.perfect { background: #fff6dd; border-color: #ecc55f; }
.stage:disabled { opacity: 0.45; cursor: default; }
.stage .lock { width: 12px; height: 12px; fill: none; stroke: var(--ink-soft); stroke-width: 2.4; }
.stage-note { margin: 10px 0 0; font-size: 12px; color: var(--ink-soft); text-align: left; }
.best { display: block; width: max-content; 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: 30%; transform: translate(-50%, -50%); z-index: 40; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(31, 43, 51, 0.92); color: #fff; font-weight: 900; font-size: 14px; 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) {
  main { padding: 0 8px 24px; }
  .val { font-size: 18px; }
  .val small { font-size: 12px; }
  .logo { font-size: 25px; }
}
