:root {
  --night-top: #0b1230;
  --night-bottom: #1d2a63;
  --cream: #f6e8c3;
  --cream-dim: rgba(246, 232, 195, 0.72);
  --gold: #f2c96b;
  --ink: #1a1f3d;
  --line: rgba(246, 232, 195, 0.28);
  --font: "Hiragino Maru Gothic ProN", "Yu Gothic", "YuGothic", "Meiryo", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night-top);
  color: var(--cream);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background: linear-gradient(180deg, var(--night-top) 0%, var(--night-bottom) 100%);
  overflow: hidden;
}

/* ---------- ボタン ---------- */

.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font: inherit;
  font-size: 1rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible,
.toggle input:focus-visible,
#lst-slider:focus-visible,
#sky-canvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.btn-primary {
  min-height: 52px;
  padding: 0 44px;
  background: var(--cream);
  color: var(--ink);
  border-color: var(--cream);
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 0 28px rgba(246, 232, 195, 0.25);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: rgba(11, 18, 48, 0.55);
  color: var(--cream);
}

/* ---------- タイトル画面 ---------- */

.title-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 108%, rgba(242, 201, 107, 0.18), transparent 55%),
    linear-gradient(180deg, #080d27 0%, #121c4d 60%, #1d2a63 100%);
}

.title-body {
  position: relative;
  z-index: 1;
  padding: 0 24px;
}

.title-body h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-shadow: 0 0 22px rgba(246, 232, 195, 0.35);
}

.subtitle {
  margin: 0 0 44px;
  font-size: clamp(0.85rem, 3.6vw, 1.05rem);
  letter-spacing: 0.1em;
  color: var(--cream-dim);
}

/* 控えめな星のきらめき（CSS のみ） */
.twinkle {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: no-repeat;
}

.twinkle-a {
  background-image:
    radial-gradient(circle 1.6px at 12% 14%, #fff 98%, transparent),
    radial-gradient(circle 1.2px at 78% 9%, #fff 98%, transparent),
    radial-gradient(circle 1.8px at 90% 34%, #fff 98%, transparent),
    radial-gradient(circle 1.2px at 22% 42%, #fff 98%, transparent),
    radial-gradient(circle 1.4px at 8% 72%, #fff 98%, transparent),
    radial-gradient(circle 1.6px at 70% 80%, #fff 98%, transparent);
  animation: twinkle 5s ease-in-out infinite;
}

.twinkle-b {
  background-image:
    radial-gradient(circle 1.2px at 40% 7%, #fff 98%, transparent),
    radial-gradient(circle 1.6px at 60% 24%, #fff 98%, transparent),
    radial-gradient(circle 1.2px at 30% 85%, #fff 98%, transparent),
    radial-gradient(circle 1.8px at 88% 62%, #fff 98%, transparent),
    radial-gradient(circle 1.2px at 50% 92%, #fff 98%, transparent),
    radial-gradient(circle 1.4px at 16% 28%, #fff 98%, transparent);
  animation: twinkle 7s ease-in-out -2.5s infinite;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.95;
  }
}

/* ---------- 星空画面 ---------- */

.sky-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  flex: 0 0 auto;
}

.badge {
  display: inline-block;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--cream-dim);
}

.dome-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

#sky-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* ドラッグ中にページがスクロールしないように */
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

#sky-canvas:active {
  cursor: grabbing;
}

.controls {
  flex: 0 0 auto;
  padding: 4px 16px 14px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.hint {
  margin: 0 0 4px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--cream-dim);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.slider-label {
  flex: 0 0 auto;
  font-size: 0.9rem;
}

#lst-output {
  flex: 0 0 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#lst-slider {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  margin: 0;
  accent-color: var(--gold);
  touch-action: pan-y; /* 横方向はスライダー操作に使う */
  cursor: pointer;
}

.toggle-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.toggle input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
  .twinkle {
    animation: none;
    opacity: 0.7;
  }
  .btn,
  .btn-primary:active {
    transition: none;
    transform: none;
  }
}
