:root {
  --bg: #0d1030;
  --panel: #161a44;
  --ink: #eef0ff;
  --ink-2: #9aa0d0;
  --cyan: #46e0ff;
  --pink: #ff5fa8;
  --gold: #ffd25a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #1b2060, var(--bg) 60%);
  color: var(--ink);
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Yu Gothic', 'Meiryo', sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.game {
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: none;
}

/* 上の数字 */
.hud { display: grid; grid-template-columns: 1fr 1.3fr 1fr 1.3fr auto; gap: 6px; align-items: center; }
.hud div { background: var(--panel); border-radius: 10px; padding: 3px 8px; line-height: 1.2; }
.hud small { display: block; font-size: 10px; color: var(--ink-2); }
.hud b { font-size: 17px; font-variant-numeric: tabular-nums; }
.hud i { font-style: normal; font-size: 11px; color: var(--ink-2); margin-left: 2px; }
.lives { color: var(--pink); letter-spacing: 1px; }
.icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #343a80; background: var(--panel); font-weight: 800; }

/* 盤面 */
.board-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#board { display: block; border-radius: 6px; box-shadow: 0 0 0 1px #2a3080, 0 0 24px rgba(70, 224, 255, .18); background: #0a0c22; }
.bar { position: relative; height: 6px; border-radius: 99px; background: #23285e; margin-top: 6px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); border-radius: 99px; transition: width .2s; }
.bar .goal { position: absolute; left: 75%; top: -2px; bottom: -2px; width: 2px; background: var(--gold); }

/* 画面（題名・クリアなど） */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center;
  background: rgba(8, 10, 34, .86); border-radius: 8px;
  backdrop-filter: blur(2px);
}
.screen h1 { margin: 0 0 4px; font-size: 44px; line-height: 1.15; letter-spacing: .06em; }
.screen h1 span { display: block; }
.screen h1 span:first-child { color: var(--cyan); text-shadow: 0 0 18px rgba(70, 224, 255, .7); }
.screen h1 span:last-child { color: var(--gold); text-shadow: 0 0 18px rgba(255, 210, 90, .6); font-size: 34px; }
.screen h2 { margin: 0; font-size: 24px; }
.screen p { margin: 0; }
.sub { color: var(--ink-2); font-size: 14px; margin-bottom: 8px !important; }
.best { color: var(--ink-2); font-size: 14px; }
.best b { color: var(--gold); }
.big { font-size: 40px; font-weight: 800; color: var(--gold); }
.glow { color: var(--cyan); text-shadow: 0 0 14px rgba(70, 224, 255, .7); }
.new { color: var(--pink); font-weight: 800; }
.howto { text-align: left; margin: 0; padding-left: 1.1em; font-size: 14px; line-height: 1.7; max-width: 400px; }
.howto li { margin-bottom: 6px; }
.howto b { color: var(--cyan); }

.btn {
  width: min(100%, 280px); min-height: 50px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 800; font-size: 17px;
}
.btn.primary { background: linear-gradient(90deg, #2bc7f0, #8a6bff); color: #fff; box-shadow: 0 0 18px rgba(70, 224, 255, .35); }
.btn.ghost { background: transparent; border-color: var(--cyan); color: var(--cyan); }
.btn.text { background: none; color: var(--ink-2); font-weight: 400; font-size: 14px; min-height: 36px; text-decoration: underline; }

.msg {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); margin: 0;
  padding: 10px 22px; border-radius: 99px; background: rgba(8, 10, 34, .85); font-size: 20px; font-weight: 800;
  color: var(--pink); pointer-events: none; white-space: nowrap;
}

/* 十字のボタン */
.pad {
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 54px);
  grid-template-areas: '. up .' 'left down right'; gap: 8px; justify-content: center; padding-bottom: 2px;
}
.pad button {
  border-radius: 16px; border: 1px solid #343a80; background: var(--panel); font-size: 22px; color: var(--cyan);
  touch-action: none;
}
.pad button.on { background: #2a3290; box-shadow: 0 0 14px rgba(70, 224, 255, .45); }
.pad .up { grid-area: up; } .pad .left { grid-area: left; } .pad .right { grid-area: right; } .pad .down { grid-area: down; }

/* パソコン（マウスで使う大きい画面）では、十字のボタンを小さく */
@media (hover: hover) and (pointer: fine) {
  .pad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 40px); }
}
