/* なつかしアーケード Web版 — 共通スタイル（いつもダークのレトロ調。iOS版と同じ色） */
:root {
  --bg: #0d0a1f;
  --panel: #1c1738;
  --line: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --dim: rgba(255, 255, 255, 0.6);
  --cyan: #2ee6f2;
  --pink: #ff529e;
  --yellow: #ffdb40;
  --green: #59f273;
  --orange: #ff9433;
  --purple: #a873ff;
  --red: #ff4d4d;
  --blue: #4d8cff;
  --f-retro: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --f-round: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --f-ui: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05040c;
  color: var(--text);
  font-family: var(--f-ui);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

@media (min-width: 520px) {
  body { background: radial-gradient(ellipse at 50% 30%, #1a1238 0%, #05040c 70%); }
  #app { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 24px 90px rgba(0, 0, 0, 0.7); }
}

button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.screen { position: absolute; inset: 0; overflow: hidden; }
canvas.px { image-rendering: pixelated; display: block; }
.game-canvas { display: block; touch-action: none; }
.dim { color: var(--dim); }

.loading, .stub {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font: 800 18px var(--f-retro); color: var(--dim);
}
.load-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 100%; padding: 24px; text-align: center; font-weight: 800;
}
.load-error .retro-btn { margin-top: 14px; }

/* ── 点滅 ── */
@keyframes blink { 0%, 49.99% { opacity: 1; } 50%, 100% { opacity: 0; } }
.blink-1 { animation: blink 1s steps(1, end) infinite; }
.blink-12 { animation: blink 1.2s steps(1, end) infinite; }

/* ── 共通の枠（上部バー） ── */
.scaffold { display: flex; flex-direction: column; background: var(--bg); }
.sc-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-top)) 14px 8px;
  flex: none;
}
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text);
  background: var(--panel); border-radius: 10px;
}
.icon-btn:active { filter: brightness(1.3); }
.sc-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.sc-title { font: 800 16px var(--f-retro); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-best { font: 800 11px var(--f-retro); color: var(--dim); }
.sc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.sc-label { font: 800 10px var(--f-retro); color: var(--dim); }
.sc-score { font: 800 20px var(--f-retro); color: var(--yellow); font-variant-numeric: tabular-nums; }
.sc-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── ボタン ── */
.retro-btn {
  font: 800 17px var(--f-retro);
  color: var(--bg);
  background: var(--c, var(--cyan));
  padding: 12px 22px;
  min-width: 140px;
  border-radius: 12px;
  box-shadow: 0 0 16px color-mix(in srgb, var(--c, var(--cyan)) 60%, transparent);
}
.retro-btn:active { transform: scale(0.97); filter: brightness(1.1); }

.pad-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text);
  background: var(--c, var(--panel));
  border: 2px solid var(--line);
  touch-action: none;
  transition: transform 0.06s;
  flex: none;
}
.pad-btn.pressed { transform: scale(0.92); filter: brightness(0.7); }
.dpad { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dpad-row { display: flex; align-items: center; justify-content: center; }

/* ── スタート／ゲームオーバー ── */
.ov {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  animation: fadein 0.2s ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.ov-panel {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 28px;
  max-width: 100%;
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  border: 2px solid color-mix(in srgb, var(--c) 60%, transparent);
  border-radius: 20px;
}
.ov-title {
  font: 800 30px var(--f-retro);
  color: var(--c);
  text-shadow: 0 0 10px color-mix(in srgb, var(--c) 80%, transparent);
  text-align: center;
  white-space: pre-line;
}
.ov-msg { font: 800 14px/1.6 var(--f-retro); text-align: center; white-space: pre-line; }
.ov-panel .retro-btn { margin-top: 6px; }

/* ── トップ画面 ── */
.menu { background: #08051a; }
.menu-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.menu-scroll {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
}
.menu-scroll::-webkit-scrollbar { display: none; }
.scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 50% 50%, transparent 180px, rgba(0, 0, 0, 0.55) 520px);
}
.m-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(14px + var(--safe-top)) 18px 0;
}
.m-col { display: flex; flex-direction: column; gap: 5px; }
.m-col.left { align-items: flex-start; }
.m-col.center { align-items: center; }
.m-col.right { align-items: flex-end; }
.m-title { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 0 18px; }
.m-logo-row { display: flex; align-items: flex-end; gap: 14px; }
.m-piyo { position: relative; width: 48px; height: 48px; }
.m-piyo canvas { position: absolute; left: 0; bottom: 4px; }
.m-piyo canvas:first-child { animation: blink 0.7s steps(1, end) infinite; }
.m-piyo canvas:last-child { animation: blink 0.7s steps(1, end) infinite reverse; transform: translateY(-3px); }
.m-natsukashi {
  font: 900 26px var(--f-round);
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--red);
  line-height: 1.1;
}
.m-star { padding-bottom: 14px; }
.m-arcade {
  height: 70px; display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 0 10px rgba(46, 230, 242, 0.6));
}
.m-push { height: 16px; display: flex; align-items: center; }
.m-select { display: flex; align-items: center; gap: 8px; padding: 0 16px 14px; }
.m-select i { flex: 1; height: 3px; background: var(--cyan); }
.m-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding: 0 16px;
}
.m-card {
  display: flex; flex-direction: column; text-align: left;
  background: var(--panel);
  border: 3px solid var(--c);
  box-shadow: 5px 5px 0 #000;
  container-type: inline-size;
  min-width: 0;
  transition: transform 0.05s, box-shadow 0.05s;
}
.m-card:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 #000; }
.m-band {
  height: 26px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px; background: var(--c);
}
.m-card-body { display: flex; flex-direction: column; gap: 7px; padding: 10px; }
.m-icon { height: 36px; display: flex; align-items: center; }
.m-card-title {
  font: 900 15px var(--f-retro);
  font-size: min(15px, calc((100cqi - 20px) / 9.3));
  color: var(--text);
  white-space: nowrap; overflow: hidden;
}
.m-card-sub {
  font: 700 11px var(--f-retro);
  color: color-mix(in srgb, var(--c) 85%, transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-card-best { display: flex; align-items: center; gap: 6px; padding-top: 2px; }
.m-footer {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 26px 0 calc(40px + var(--safe-bottom));
}
.m-hearts { display: flex; gap: 6px; }
