:root {
  --bg: #070b14;
  --panel: rgba(8, 12, 22, 0.93);
  --ink: #eef3ff;
  --sub: #a4b2cc;
  --amber: #ffc640;
  --lime: #8cff6a;
  --line: rgba(255, 198, 64, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% 30%, #121a30 0%, var(--bg) 70%);
  background-color: var(--bg);
  color: var(--ink);
  font-family: "DotGothic16", system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: max(6px, env(safe-area-inset-top)) 16px max(6px, env(safe-area-inset-bottom));
}

/* 画面は 240x320（3:4）。HUD 40px と下の余白を引いた高さに合わせる */
.stage, .hud { width: var(--w); }
.wrap { --h: min(calc(100vh - 86px), calc((100vw - 32px) * 4 / 3), 960px); --w: calc(var(--h) * 3 / 4); }
@supports (height: 100dvh) {
  .wrap { min-height: 100dvh; --h: min(calc(100dvh - 86px), calc((100vw - 32px) * 4 / 3), 960px); }
}
@media (pointer: coarse) {
  .wrap { --h: min(calc(100vh - 80px), calc((100vw - 16px) * 4 / 3), 960px); padding-left: 8px; padding-right: 8px; }
  @supports (height: 100dvh) {
    .wrap { --h: min(calc(100dvh - 80px), calc((100vw - 16px) * 4 / 3), 960px); }
  }
}

.hud {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 8px;
  background: linear-gradient(180deg, #0e1424, #05080f);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.15;
  overflow: hidden;
}
.hud-cell { display: flex; flex-direction: column; min-width: 0; }
.hud-cell.mid { align-items: center; color: var(--lime); font-size: 12px; }
.hud-cell.right { align-items: flex-end; }
.lbl { font-size: 10px; color: var(--sub); letter-spacing: 0.1em; }
.num { font-size: 17px; color: var(--amber); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.stock { color: #e8f0ff; font-size: 11px; letter-spacing: 1px; min-height: 1em; }

.stage {
  position: relative;
  height: var(--h);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 6px;
  touch-action: none;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
}

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 0 2px #000, 2px 2px 0 #000;
}
.banner.show { animation: banner 2.2s ease-out forwards; }
#bn-main { font-size: clamp(24px, 7vw, 38px); color: var(--amber); letter-spacing: 0.12em; }
#bn-sub { font-size: clamp(13px, 3.6vw, 18px); color: #fff; margin-top: 4px; }
@keyframes banner {
  0% { opacity: 0; transform: scale(1.3); }
  12% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.bomb {
  display: none;
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  font: inherit;
  font-size: 13px;
  color: #fff;
  background: rgba(255, 90, 60, 0.32);
  border: 2px solid rgba(255, 198, 64, 0.8);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  touch-action: none;
}

.bomb[hidden] { display: none !important; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
}
.overlay[hidden] { display: none; }

.panel {
  width: 100%;
  max-width: 360px;
  margin: auto;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
  line-height: 1.45;
}
.panel[hidden] { display: none; }

h1 {
  margin: 0 0 2px;
  font-weight: normal;
  font-size: clamp(30px, 8.5vw, 42px);
  line-height: 1.05;
  letter-spacing: 0.1em;
  color: var(--amber);
  text-shadow: 3px 3px 0 #a03010;
}
h2 { margin: 0 0 10px; font-weight: normal; font-size: clamp(22px, 6vw, 30px); color: var(--amber); letter-spacing: 0.08em; }

.lead { margin: 0 0 8px; font-size: 14px; color: var(--sub); letter-spacing: 0.2em; }
.rules { list-style: none; padding: 0; margin: 0 0 8px; text-align: left; font-size: 13px; }
.rules li { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.dot { flex: none; width: 8px; height: 8px; margin-top: 6px; }
.dot.c1 { background: #fff3a0; }
.dot.c2 { background: #ff3048; }
.dot.c3 { background: #c8d0dc; }
.dot.c4 { background: #9ea8b6; }
.dot.c5 { background: var(--amber); }
.keys { margin: 6px 0; font-size: 12px; color: var(--sub); }
.keys.pad-hint { color: var(--lime); }
.keys.pad-hint[hidden] { display: none; }
.hi { margin: 8px 0 0; font-size: 13px; color: var(--sub); }
.result { margin: 4px 0; font-size: 22px; color: var(--amber); }
.result.small { font-size: 13px; color: var(--sub); }

.diff { display: flex; gap: 6px; align-items: stretch; margin: 8px 0 0; }
.diff-btn {
  flex: 1;
  padding: 6px 2px;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(164, 178, 204, 0.4);
  border-radius: 4px;
  cursor: pointer;
}
.diff-btn small { display: block; font-size: 10px; color: var(--sub); }
.diff-btn[aria-pressed="true"] { color: #1a1000; background: var(--amber); border-color: var(--amber); }
.diff-btn[aria-pressed="true"] small { color: #5a3a00; }
.diff-note { margin: 5px 0 0; min-height: 2.6em; font-size: 12px; color: var(--lime); }

.btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 11px;
  font: inherit;
  font-size: 19px;
  color: #1a1000;
  background: linear-gradient(180deg, #ffe07a, #f0a020);
  border: 0;
  border-radius: 6px;
  box-shadow: 0 3px 0 #9a5a00;
  cursor: pointer;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #9a5a00; }
.btn.sub { background: linear-gradient(180deg, #d4dcec, #8e9bb8); box-shadow: 0 3px 0 #4a5470; font-size: 15px; }

.corner {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 6px;
}
.mini {
  width: 32px;
  height: 32px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.mini.off { opacity: 0.45; text-decoration: line-through; }

/* 背の低いスマホ・幅の狭いスマホ（画面が小さくなる）でもタイトルが 1 画面に収まるように詰める */
@media (max-height: 720px), (max-width: 440px) {
  .panel { padding: 8px 9px; line-height: 1.3; }
  h1 { font-size: 24px; }
  .lead { margin-bottom: 3px; font-size: 11px; }
  .rules { font-size: 11.5px; margin-bottom: 4px; }
  .rules li { margin: 1px 0; gap: 6px; }
  .dot { margin-top: 4px; }
  .keys { font-size: 10.5px; margin: 3px 0; }
  .diff { margin-top: 5px; }
  .diff-btn { padding: 4px 2px; font-size: 13px; }
  .diff-note { min-height: 0; font-size: 11px; margin-top: 3px; }
  .btn { padding: 7px; margin-top: 6px; font-size: 16px; }
  .hi { margin-top: 3px; font-size: 12px; }
}

.touch-only { display: none; }
@media (pointer: coarse) {
  .touch-only { display: block; }
  .pc-only { display: none; }
  .bomb { display: block; }
}

.back { margin: 0; font-size: 13px; color: #56617e; }
.back a { color: #7f8db0; }

/* ゲームの下の説明（遊び方・操作・難易度・FAQ） */
.about {
  max-width: 720px;
  margin: 28px auto 48px;
  padding: 0 16px;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.8;
  color: #d8e0f0;
  -webkit-user-select: text;
  user-select: text;
}
.about h2 {
  margin: 32px 0 10px;
  padding-bottom: 4px;
  font-family: "DotGothic16", system-ui, sans-serif;
  font-size: 20px;
  color: var(--amber);
  border-bottom: 1px solid var(--line);
}
.about h2:first-child { margin-top: 0; }
.about p { margin: 0 0 10px; }
.about strong { color: #fff; }
.about ul { margin: 0 0 10px; padding-left: 1.3em; }
.about li { margin: 4px 0; }
.about table {
  display: block;
  overflow-x: auto;
  width: 100%;
  margin: 0 0 10px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}
.about th, .about td { padding: 7px 9px; border: 1px solid rgba(164, 178, 204, 0.25); text-align: left; vertical-align: top; }
.about thead th { background: rgba(255, 198, 64, 0.12); color: var(--amber); font-weight: normal; }
.about tbody th { white-space: nowrap; color: #fff; }
.about dt { margin-top: 12px; font-weight: bold; color: #fff; }
.about dd { margin: 2px 0 0 1em; }
.about a { color: #9ec4ff; }
.about .back-top { margin-top: 24px; font-size: 13px; }
