:root {
  --text: #f5f6fb;
  --muted: #d6d8e7;
  --panel: rgba(7, 9, 18, 0.34);
  --panel-strong: rgba(7, 9, 18, 0.56);
  --line: rgba(255, 255, 255, 0.22);
  --timer: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans KR", sans-serif;
  background: #05070f;
}

.app {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

.video-bg,
.bg-layer,
.noise-layer,
.vignette-layer {
  position: absolute;
  inset: 0;
}

.video-bg {
  z-index: -4;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.1) contrast(1.05);
  opacity: 1;
  background: #0a0f1f;
}

.bg-layer {
  z-index: -3;
  transition: background 260ms ease;
}

.noise-layer {
  z-index: -2;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.16;
  animation: drift 10s linear infinite;
}

.vignette-layer {
  z-index: -1;
  background: linear-gradient(
    180deg,
    rgba(5, 7, 15, 0.5) 0%,
    rgba(5, 7, 15, 0.08) 25%,
    rgba(5, 7, 15, 0.06) 60%,
    rgba(5, 7, 15, 0.62) 100%
  );
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-18px);
  }
}

.top-ui {
  position: fixed;
  z-index: 20;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
}

.timer-track {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--timer);
  transform-origin: left center;
}

.progress-label {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.card {
  position: fixed;
  z-index: 10;
  left: 10px;
  right: 10px;
  bottom: max(14px, env(safe-area-inset-bottom));
  min-height: min(62dvh, 510px);
  border-radius: 20px;
  padding: 16px 92px 14px 14px;
  background: linear-gradient(180deg, rgba(8, 10, 17, 0.34), rgba(8, 10, 17, 0.58));
  border: 1px solid var(--line);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
}

.type-label {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.prompt {
  margin: 10px 0 14px;
  font-size: clamp(24px, 8vw, 46px);
  line-height: 1.1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.36);
}

.options {
  margin-top: 2px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.opt-btn {
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(11, 13, 21, 0.56);
  color: var(--text);
  font-size: 15px;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.opt-btn:disabled {
  opacity: 0.76;
}

.caption {
  margin-top: auto;
  font-size: 13px;
  color: var(--muted);
}

.side-ui {
  position: fixed;
  z-index: 24;
  right: 10px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-item {
  min-width: 76px;
  padding: 6px 8px;
  border-radius: 999px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-size: 12px;
}

.icon {
  width: 16px;
  text-align: center;
  font-weight: 700;
  opacity: 0.9;
}

.sound-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px;
  color: var(--text);
  background: var(--panel-strong);
  font-size: 11px;
  cursor: pointer;
}

.correct {
  animation: pulse 250ms ease;
  box-shadow: 0 0 0 2px rgba(142, 255, 193, 0.54) inset, 0 0 30px rgba(142, 255, 193, 0.26);
}

.wrong {
  animation: shake 240ms linear;
  box-shadow: 0 0 0 2px rgba(255, 143, 149, 0.54) inset;
}

.feedback-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.mode-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: rgba(2, 4, 9, 0.58);
  backdrop-filter: blur(8px);
}

.hidden {
  display: none !important;
}

.mode-panel {
  width: min(520px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(7, 10, 18, 0.74);
  padding: 20px 16px;
}

.mode-hero {
  width: min(520px, 100%);
  text-align: left;
}

.hero-title {
  margin: 0;
  font-size: clamp(30px, 8vw, 46px);
  line-height: 1.04;
  font-weight: 900;
  letter-spacing: -0.01em;
  text-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

.hero-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.mode-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.mode-subtitle {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.mode-buttons {
  display: grid;
  gap: 8px;
}

.mode-btn {
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(14, 18, 30, 0.78);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.mode-btn.recommended {
  border-color: rgba(142, 255, 193, 0.68);
  box-shadow: 0 0 18px rgba(142, 255, 193, 0.24);
}

.feedback-pop {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(10, 12, 22, 0.72);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.03em;
  animation: popIn 1500ms cubic-bezier(0.15, 0.85, 0.2, 1) forwards;
}

.feedback-pop.combo {
  color: #9cffcc;
  box-shadow: 0 0 28px rgba(156, 255, 204, 0.35);
}

.feedback-pop.miss {
  color: #ffadb3;
  box-shadow: 0 0 24px rgba(255, 126, 136, 0.34);
}

.impact-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 82, 96, 0.24);
  animation: flashRed 420ms ease-out forwards;
}

.burst-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #8effc1;
  box-shadow: 0 0 14px rgba(142, 255, 193, 0.6);
  animation: burstOut 520ms ease-out forwards;
}

.reward-card {
  display: grid;
  place-items: center;
  text-align: center;
}

.reward-main {
  font-size: clamp(28px, 9vw, 52px);
  font-weight: 800;
}

.reward-sub {
  margin-top: 10px;
  color: var(--muted);
}

.slide-out-up {
  animation: slideOutUp 220ms ease forwards;
}

.slide-in-up {
  animation: slideInUp 260ms cubic-bezier(0.2, 0.85, 0.4, 1) both;
}

.slide-out-down {
  animation: slideOutDown 220ms ease forwards;
}

.slide-in-down {
  animation: slideInDown 260ms cubic-bezier(0.2, 0.85, 0.4, 1) both;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-6px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-26px);
    opacity: 0;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(20px) scale(0.99);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(26px);
    opacity: 0;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-20px) scale(0.99);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -44%) scale(0.7);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) scale(0.96);
  }
}

@keyframes flashRed {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes burstOut {
  from {
    opacity: 1;
    transform: translate(var(--tx, 0), var(--ty, 0)) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.4);
  }
}

@media (min-width: 720px) {
  .card {
    left: 18px;
    right: 18px;
    max-width: 760px;
    margin: 0 auto;
    padding-right: 112px;
  }

  .options {
    grid-template-columns: 1fr 1fr;
  }

  .mode-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .mode-overlay {
    align-items: stretch;
  }

  .mode-hero,
  .mode-panel {
    margin: 0 auto;
  }

  .side-ui {
    right: max(14px, calc((100vw - 760px) / 2 + 12px));
  }
}

@media (max-height: 700px) {
  .card {
    min-height: min(66dvh, 470px);
    padding-top: 12px;
  }

  .prompt {
    font-size: clamp(22px, 7.6vw, 40px);
    margin-bottom: 10px;
  }

  .side-item {
    min-width: 70px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .burst-particle,
  .impact-flash,
  .feedback-pop,
  .correct,
  .wrong,
  .slide-out-up,
  .slide-in-up,
  .slide-out-down,
  .slide-in-down {
    animation-duration: 1ms !important;
  }
}
