:root {
  --ink: #23272d;
  --ink-soft: #626a74;
  --bg: #eceae4;
  --paper: #ffffff;
  --line: #d9d6cd;
  --primary: #2f6db5;
  --primary-dark: #1d4a80;
  --asphalt: #474c55;
  --asphalt-dark: #2f343b;
  --wall: #cfc9b8;
  --sign: #f2b233;
  --red: #e0393e;
  --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; }
.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.2fr 1fr; gap: 8px; margin-bottom: 10px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; 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 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: 4px; }
.val small span { font-family: var(--num); }
#count { display: inline-block; }
#count.pop { animation: pop 0.25s ease-out; }
@keyframes pop { 40% { transform: scale(1.3); color: var(--primary); } }

/* 駐車場（まわりの塀の右はし、3行目にだけ出口のすき間） */
.lot-wrap { position: relative; width: 100%; max-width: 420px; margin: 0 auto; }
.lot { position: relative; width: 100%; aspect-ratio: 1; padding: 3.2%; border-radius: 18px; background: var(--wall); box-shadow: 0 10px 28px rgba(35, 39, 45, 0.25), inset 0 0 0 2px rgba(0, 0, 0, 0.06); overflow: hidden; }
.field { position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 8px; touch-action: none;
  background-color: var(--asphalt);
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.13) 2px, transparent 2px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.13) 2px, transparent 2px);
  background-size: calc(100% / 6) calc(100% / 6);
  background-position: -1px -1px; }
/* 出口: 塀の右はしの、3行目の高さのすき間 */
.exit { position: absolute; right: 0; top: calc(3.2% + (100% - 6.4%) / 6 * 2); height: calc((100% - 6.4%) / 6); width: 3.4%; background: repeating-linear-gradient(-45deg, var(--sign) 0 5px, var(--asphalt-dark) 5px 10px); }
/* 出口の矢印（盤の外の右に出す） */
.lot-wrap::after { content: ""; position: absolute; z-index: 2; right: -11px; top: calc(3.2% + (100% - 6.4%) / 6 * 2 + (100% - 6.4%) / 12 - 9px); width: 0; height: 0; border-left: 10px solid var(--sign); border-top: 9px solid transparent; border-bottom: 9px solid transparent; }
/* 赤い車の通り道（出口までの行）をうっすら示す */
.lane { position: absolute; left: 0; right: 0; border-top: 2px dashed rgba(242, 178, 51, 0.45); border-bottom: 2px dashed rgba(242, 178, 51, 0.45); pointer-events: none; }

.car { position: absolute; left: 0; top: 0; border-radius: 10px; cursor: grab; will-change: transform; transition: transform 0.16s cubic-bezier(.2, .9, .3, 1.2); filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35)); }
.car svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.car.drag { transition: none; cursor: grabbing; z-index: 5; filter: drop-shadow(0 7px 6px rgba(0, 0, 0, 0.45)); }
.car.bump svg { animation: bump 0.22s ease-out; }
@keyframes bump { 45% { transform: scale(1.06); } }
.car.shake svg { animation: shake 0.32s ease-in-out; }
@keyframes shake { 20% { transform: translate(-3px, 0); } 40% { transform: translate(3px, 0); } 60% { transform: translate(-2px, 0); } 80% { transform: translate(2px, 0); } }
.car.v.shake svg { animation-name: shakev; }
@keyframes shakev { 20% { transform: translate(0, -3px); } 40% { transform: translate(0, 3px); } 60% { transform: translate(0, -2px); } 80% { transform: translate(0, 2px); } }
.car.blocker::after, .car.hint::after { content: ""; position: absolute; inset: -3px; border-radius: 12px; border: 3px solid var(--sign); animation: glow 0.7s ease-in-out 2; pointer-events: none; }
.car.hint::after { border-color: #fff; animation-iteration-count: 4; }
@keyframes glow { 50% { opacity: 0.25; } }
.car.out { transition: transform 0.55s cubic-bezier(.55, 0, .8, .4); }
.play.solved .lot { animation: win 0.9s ease-out; }
@keyframes win { 40% { box-shadow: 0 0 0 6px var(--sign), 0 10px 28px rgba(35, 39, 45, 0.25); } }
.car.slide { transition: transform 0.24s cubic-bezier(.25, .8, .35, 1); }
/* 出庫の札は盤の下（赤い車が走り去るのを隠さない） */
.cheer { position: absolute; left: 50%; top: calc(100% + 30px); transform: translate(-50%, -50%); z-index: 20; padding: 8px 22px; border-radius: 999px; background: var(--sign); color: var(--ink); font: 900 26px/1.3 var(--font); white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); animation: cheer 1.2s ease-out forwards; pointer-events: none; }
@keyframes cheer { 0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; } 40% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .car { transition: transform 0.05s linear; }
  .car.bump svg, .car.shake svg, .play.solved .lot, #count.pop { animation: none; }
  .car.out { transition: transform 0.2s linear; }
  .cheer { animation: none; }
}

/* 道具のボタン */
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 12px/1.1 var(--font); cursor: pointer; white-space: nowrap; min-height: 54px; touch-action: manipulation; }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool small { font: 700 10px/1 var(--font); color: var(--ink-soft); }

/* 星（絵文字を使わず、CSS の形で） */
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars i { width: 12px; height: 12px; background: #cfcbbf; 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(--sign); }
.c-stars { margin: 8px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.c-stars .stars i { width: 30px; height: 30px; }
.c-stars .new { padding: 2px 10px; border-radius: 999px; background: var(--gold); font-size: 12px; font-weight: 900; }
/* 結果画面の小さな盤 */
.mini { width: 132px; margin: 12px auto 0; padding: 5px; border-radius: 10px; background: var(--wall); position: relative; }
.mini::after { content: ""; position: absolute; right: 0; top: calc(5px + (100% - 10px) / 6 * 2); height: calc((100% - 10px) / 6); width: 5px; background: repeating-linear-gradient(-45deg, var(--sign) 0 3px, var(--asphalt-dark) 3px 6px); }
.mini-field { position: relative; aspect-ratio: 1; border-radius: 5px; background: var(--asphalt); }
.mini-car { position: absolute; padding: 1.5px; }
.mini-car svg { display: block; width: 100%; height: 100%; }

/* 練習の問題の一覧 */
.s-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 10px; }
.s-tabs button { padding: 8px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font: 900 12px/1.2 var(--font); color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.s-tabs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.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(6, 1fr); gap: 5px; }
.st { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 700 15px/1 var(--num); color: var(--ink); cursor: pointer; }
.st .stars i { width: 9px; height: 9px; }
.st.done { background: var(--paper); }
.st.cur { box-shadow: inset 0 0 0 2px var(--primary); }
.kbd { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); text-align: center; }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .lot-wrap, .play.menu .tools, .play.menu .kbd { display: none; }
.play.solved .tools { visibility: hidden; }
.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(35, 39, 45, 0.1); }
.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 24px/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; }
.tip { margin: 0 0 8px; padding: 6px 10px; border-radius: 10px; background: #fff6dd; font-size: 12px; font-weight: 700; text-align: left; }
.free-lbl { font-size: 12px; font-weight: 900; color: var(--ink-soft); margin: 6px 0 4px; }
.free-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 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 .rb { color: #c42a2f; }
.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; white-space: nowrap; }
.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: 15px; padding: 10px 2px; white-space: nowrap; }
.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-moves { margin: 6px 0; white-space: nowrap; }
.clear-moves b { font: 700 60px/1 var(--num); font-variant-numeric: tabular-nums; }
.clear-moves span { font: 900 18px/1 var(--font); margin-left: 4px; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.gap { display: inline-block; margin: 10px 0 0; padding: 6px 14px; border-radius: 12px; background: var(--asphalt-dark); color: #fff; font-size: 14px; font-weight: 900; }
.gap.perfect { background: var(--sign); color: var(--ink); }
.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(35, 39, 45, 0.92); color: #fff; font-weight: 900; font-size: 14px; 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) {
  .tool { font-size: 11px; }
  .btn.lv { font-size: 14px; }
  .logo { font-size: 25px; }
}
