* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #1f2f68 0%, #0f172a 55%, #020617 100%);
  color: white;
}

body {
  position: relative;
  touch-action: manipulation;
}

#effectsCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 5;
}

.screen.active {
  display: flex;
}

#setupScreen,
#endScreen {
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
}

.panel {
  width: min(92vw, 760px);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 28px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  text-align: center;
}

.panel h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.subtitle {
  margin: 0 0 28px;
  opacity: 0.92;
  font-size: clamp(1rem, 2vw, 1.3rem);
}

.time-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.picker-group {
  background: rgba(255,255,255,0.08);
  border-radius: 22px;
  padding: 22px;
}

.picker-group label {
  display: block;
  margin-bottom: 12px;
  font-size: 1.1rem;
  font-weight: bold;
}

.picker-group input[type="range"] {
  width: 100%;
}

.picker-value {
  margin-top: 12px;
  font-size: 1.8rem;
  font-weight: bold;
}

.preset-note {
  margin-bottom: 28px;
  font-size: 1.05rem;
  opacity: 0.95;
}

.main-btn,
.secondary-btn {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.main-btn:active,
.secondary-btn:active {
  transform: scale(0.97);
}

.main-btn {
  padding: 20px 40px;
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  background: linear-gradient(135deg, #f43f5e, #fb7185);
  color: white;
  min-width: 220px;
}

.secondary-btn {
  padding: 12px 20px;
  font-size: 1rem;
  background: rgba(255,255,255,0.12);
  color: white;
}

#countdownScreen {
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
}

.top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 60px;
  z-index: 10;
}

.gift-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gift-wrapper {
  position: relative;
  width: min(58vw, 430px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gift-glow {
  position: absolute;
  width: 65%;
  height: 65%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,80,80,0.32) 0%, rgba(255,80,80,0.08) 45%, rgba(255,80,80,0) 70%);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.gift-glow.active {
  opacity: 1;
  transform: scale(1.08);
}

.gift {
  position: relative;
  width: 70%;
  height: 70%;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,0.35));
  transition: transform 0.2s ease, opacity 0.4s ease;
}

.gift-box {
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 58%;
  background: linear-gradient(135deg, #d90429, #ef233c);
  border-radius: 14px;
}

.gift-lid {
  position: absolute;
  top: 15%;
  left: 6%;
  width: 88%;
  height: 22%;
  background: linear-gradient(135deg, #ff4d6d, #ff758f);
  border-radius: 16px;
  z-index: 3;
}

.gift-ribbon-vertical {
  position: absolute;
  top: 15%;
  left: 46.5%;
  width: 7%;
  height: 73%;
  background: #ffd166;
  z-index: 4;
  border-radius: 10px;
}

.gift-ribbon-horizontal {
  position: absolute;
  top: 26%;
  left: 10%;
  width: 80%;
  height: 8%;
  background: #ffd166;
  z-index: 4;
  border-radius: 10px;
}

.gift-bow {
  position: absolute;
  top: -30%;
  width: 24%;
  height: 65%;
  background: #ffd166;
  border-radius: 50% 50% 40% 40%;
  z-index: 5;
}

.bow-left {
  left: 29%;
  transform: rotate(-28deg);
}

.bow-right {
  right: 29%;
  transform: rotate(28deg);
}

.gift-knot {
  position: absolute;
  left: 44%;
  top: -10%;
  width: 12%;
  height: 34%;
  background: #ffcf56;
  border-radius: 10px;
  z-index: 6;
}

.gift.warning {
  animation: blinkGift 0.55s infinite;
}

.gift.panic {
  animation: blinkGiftFast 0.3s infinite, shakeGift 0.14s infinite;
}

@keyframes blinkGift {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.2)) drop-shadow(0 18px 40px rgba(0,0,0,0.35));
    opacity: 1;
  }
  50% {
    filter: drop-shadow(0 0 35px rgba(255,120,120,0.95)) drop-shadow(0 18px 40px rgba(0,0,0,0.35));
    opacity: 0.82;
  }
}

@keyframes blinkGiftFast {
  0%, 100% {
    filter: drop-shadow(0 0 12px rgba(255,255,255,0.22)) drop-shadow(0 18px 40px rgba(0,0,0,0.35));
    opacity: 1;
  }
  50% {
    filter: drop-shadow(0 0 42px rgba(255,80,80,1)) drop-shadow(0 18px 40px rgba(0,0,0,0.35));
    opacity: 0.7;
  }
}

@keyframes shakeGift {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-2px, 1px) rotate(-1deg); }
  50% { transform: translate(2px, -1px) rotate(1deg); }
  75% { transform: translate(-1px, -2px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.gift.explode {
  animation: explodeGift 0.55s ease-out forwards;
}

@keyframes explodeGift {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    filter: brightness(1.1);
  }
  40% {
    transform: scale(1.25) rotate(-6deg);
    opacity: 1;
    filter: brightness(2);
  }
  100% {
    transform: scale(0.15) rotate(20deg);
    opacity: 0;
    filter: brightness(3);
  }
}

.end-panel p {
  font-size: 1.3rem;
  margin-bottom: 24px;
}

@media (max-width: 800px) {
  .time-picker {
    grid-template-columns: 1fr;
  }

  .gift-wrapper {
    width: min(80vw, 420px);
  }
}