:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(ellipse at top, rgba(56, 189, 248, 0.10), transparent 38%),
    radial-gradient(ellipse at 80% 15%, rgba(192, 132, 252, 0.10), transparent 28%),
    radial-gradient(ellipse at 50% 100%, rgba(251, 146, 60, 0.06), transparent 30%),
    #09090b;
}

/* ============================================================
   BACKGROUND LAYERS
============================================================ */

/* Starfield nebula – home screen */
.nebula {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.07) 0, transparent 1.5px),
    radial-gradient(circle at 75% 38%, rgba(255,255,255,0.05) 0, transparent 1px),
    radial-gradient(circle at 52% 72%, rgba(255,255,255,0.05) 0, transparent 1.5px),
    radial-gradient(circle at 33% 55%, rgba(255,255,255,0.04) 0, transparent 1px),
    radial-gradient(circle at 88% 66%, rgba(255,255,255,0.04) 0, transparent 1.5px),
    radial-gradient(circle at 10% 88%, rgba(255,255,255,0.04) 0, transparent 1px);
  background-size: 260px 260px, 340px 340px, 290px 290px, 220px 220px, 300px 300px, 180px 180px;
  animation: nebula-drift 40s linear infinite;
}

/* Subtle version for game/result screens */
.nebula-dim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top, rgba(56, 189, 248, 0.05), transparent 35%),
    radial-gradient(ellipse at bottom right, rgba(192, 132, 252, 0.05), transparent 30%);
}

@keyframes nebula-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50px, 40px, 0); }
}

/* ============================================================
   FLOATING CARD NAMES (home screen演出)
============================================================ */

.floating-cards-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-card-name {
  position: absolute;
  bottom: -2rem;
  font-family: 'Cinzel', serif;
  font-size: clamp(9px, 1.2vw, 12px);
  color: rgba(165, 243, 252, 0.055);
  white-space: nowrap;
  letter-spacing: 0.06em;
  animation: float-name linear forwards;
}

@keyframes float-name {
  0%   { transform: translateY(0);       opacity: 0; }
  6%   { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translateY(-110vh);  opacity: 0; }
}

/* ============================================================
   VOID PULSE DOT (VOID CALIBRATION badge)
============================================================ */

.void-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(165, 243, 252, 0.85);
  animation: void-dot-pulse 2.2s ease-in-out infinite;
}

@keyframes void-dot-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.75); }
  50%       { opacity: 1;    transform: scale(1.25); }
}

/* ============================================================
   TITLE SHIMMER
============================================================ */

.title-shimmer {
  background: linear-gradient(
    100deg,
    #e7e5e4 0%,
    #e7e5e4 30%,
    #a5f3fc 48%,
    #c4b5fd 56%,
    #e7e5e4 70%,
    #e7e5e4 100%
  );
  background-size: 220% auto;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: title-shimmer 5s linear infinite;
}

@keyframes title-shimmer {
  from { background-position: 220% center; }
  to   { background-position: -20% center; }
}

/* ============================================================
   HOME SCREEN ENTRANCE
============================================================ */

.home-enter {
  animation: home-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes home-enter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   SCREEN TRANSITION
============================================================ */

.screen-enter {
  animation: screen-fade 0.22s ease-out both;
}

@keyframes screen-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   GLASS PANEL
============================================================ */

.glass-panel {
  background: linear-gradient(
    160deg,
    rgba(24, 24, 27, 0.88),
    rgba(9, 9, 11, 0.75)
  );
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* ============================================================
   MODE BUTTONS (home screen)
============================================================ */

.mode-button {
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  transition: transform 0.15s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.mode-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 70%
  );
  transform: translateX(-120%);
  transition: transform 0.55s ease;
}

.mode-button:hover::after {
  transform: translateX(120%);
}

.mode-button:active {
  transform: scale(0.975);
}

/* ============================================================
   CHOICE BUTTONS (game screen)
============================================================ */

.choice-button {
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  min-height: 64px;
  transition: transform 0.12s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.choice-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,0.055), transparent);
  transform: translateX(-120%);
  transition: transform 0.4s ease;
}

.choice-button:hover::after,
.choice-button:focus-visible::after {
  transform: translateX(120%);
}

.choice-button:active {
  transform: scale(0.975);
}

.choice-button.correct {
  border-color: rgba(74, 222, 128, 0.75) !important;
  background: rgba(74, 222, 128, 0.12) !important;
}

.choice-button.wrong {
  border-color: rgba(251, 113, 133, 0.80) !important;
  background: rgba(251, 113, 133, 0.12) !important;
}

/* ============================================================
   QUESTION FRAME
============================================================ */

.question-frame {
  /* subtle inner glow */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ============================================================
   VOID OVERLAY – death animation
============================================================ */

.void-active {
  animation: void-blackout 2s cubic-bezier(0.17, 0.84, 0.44, 1) forwards;
}

.void-pulse {
  background:
    radial-gradient(circle at 50% 40%, rgba(239, 68, 68, 0.12), transparent 50%),
    radial-gradient(circle at 50% 60%, rgba(192, 132, 252, 0.08), transparent 40%);
  animation: void-pulse-anim 1.5s ease-in-out infinite;
}

@keyframes void-blackout {
  0%   { opacity: 0; transform: scale(1.06); filter: blur(4px); }
  18%  { opacity: 1; filter: blur(0px); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes void-pulse-anim {
  0%, 100% { opacity: 0.4; transform: scale(0.96); }
  50%       { opacity: 0.9; transform: scale(1.04); }
}

/* ============================================================
   RANKING LIST
============================================================ */

.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
}

.rank-item-gold   { border-color: rgba(251, 191, 36, 0.30); background: rgba(251, 191, 36, 0.05); }
.rank-item-silver { border-color: rgba(203, 213, 225, 0.20); background: rgba(203, 213, 225, 0.04); }
.rank-item-bronze { border-color: rgba(180, 120, 60, 0.22);  background: rgba(180, 120, 60, 0.04); }

/* ============================================================
   SETTINGS PANEL (bottom sheet slide-up)
============================================================ */

.settings-sheet {
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

#settings-panel.open .settings-sheet {
  transform: translateY(0);
}

/* ============================================================
   MOBILE SAFE AREA
============================================================ */

@supports (padding-top: env(safe-area-inset-top)) {
  .safe-top    { padding-top:    max(env(safe-area-inset-top),    16px); }
  .safe-bottom { padding-bottom: max(env(safe-area-inset-bottom), 16px); }
}
