:root {
  --panel: rgba(20, 16, 28, 0.92);
  --ink: #f3ead9;
  --sub: #c9bda6;
  --accent: #ffb347;
  --accent2: #ff6b6b;
  --line: rgba(255, 255, 255, 0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: #10131a;
  color: var(--ink);
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  position: fixed;
  inset: 0;
  user-select: none;
}
canvas#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
}

#hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 14px;
  pointer-events: none;
  z-index: 5;
}
#hud.hidden { display: none; }
#heightBadge {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 15px;
  letter-spacing: .03em;
  backdrop-filter: blur(4px);
}
#heightBadge b { color: var(--accent); font-size: 17px; }
#heightBadge .best { display: block; font-size: 10.5px; color: var(--sub); margin-top: 2px; }
#pauseBtn {
  pointer-events: auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

#toast {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top) + 60px));
  left: 50%;
  transform: translate(-50%, -8px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--sub);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.overlay {
  position: fixed; inset: 0;
  background: rgba(6, 5, 10, 0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
  padding: 20px;
}
.overlay.hidden { display: none; }

.panel {
  background: linear-gradient(180deg, #211a2c, #171220);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 26px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.panel h1 {
  font-size: 26px;
  letter-spacing: .04em;
  color: var(--accent);
  line-height: 1.3;
}
.panel h1 span {
  display: block;
  font-size: 13px;
  color: var(--sub);
  letter-spacing: .3em;
  margin-top: 2px;
}
.panel h2 { font-size: 20px; color: var(--accent); margin-bottom: 6px; }
.panel .desc { color: var(--sub); font-size: 13.5px; margin: 10px 0 18px; }

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, var(--accent), #e08a26); color: #2a1a05; border-color: transparent; }
.btn.danger { background: rgba(255,107,107,.14); border-color: rgba(255,107,107,.4); color: #ffb3b3; }

#continueRow { margin-bottom: 4px; }
.saveinfo { font-size: 12.5px; color: var(--sub); margin-bottom: 6px; }
.saveinfo b { color: var(--accent); }

.howto { margin-top: 18px; text-align: left; background: rgba(255,255,255,.04); border-radius: 12px; padding: 12px 14px; }
.howto p { font-size: 12.5px; color: var(--sub); line-height: 1.7; }

.soundToggle { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 16px; font-size: 12.5px; color: var(--sub); }
.soundToggle input { width: 16px; height: 16px; }

.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { margin-top: 0; }

#winTime { color: var(--sub); font-size: 14px; margin-bottom: 16px; }

@media (max-width: 380px) {
  .panel { padding: 22px 18px; }
  .panel h1 { font-size: 22px; }
}
