/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --text: #f0f0f0;
  --text-muted: #8888aa;
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.4);
  --success: #00d26a;
  --input-bg: #16213e;
  --input-border: #2a2a4a;
  --radius: 10px;
}

html {
  height: 100%;
  background: #000;
}

body {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   APP LAYOUT — single screen, no scroll
   ======================================== */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 12px;
  overflow: hidden;
}

/* ========================================
   HEADER (compact)
   ======================================== */
.header {
  text-align: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.header__title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #e94560, #f5a623, #e94560);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s ease infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.header__subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ========================================
   CODE ENTRY FORM (compact)
   ======================================== */
.code-section {
  width: 100%;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.code-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.code-form__input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-form__input#code-input {
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
}

.code-form__input#code-input::placeholder {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.code-form__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.code-form__btn {
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.code-form__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.code-form__btn:active {
  transform: translateY(0);
}

.code-form__error {
  margin-top: 6px;
  color: var(--accent);
  font-size: 0.8rem;
  text-align: center;
}

/* ========================================
   WHEEL SECTION (compact)
   ======================================== */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  animation: fadeSlideIn 0.5s ease;
}

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

.wheel-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pointer / Arrow */
.wheel-pointer {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  color: var(--accent);
  z-index: 10;
  filter: drop-shadow(0 2px 6px var(--accent-glow));
  line-height: 1;
  transition: transform 0.08s;
}

.wheel-pointer.tick {
  transform: translateX(-50%) scaleY(0.85);
}

#wheel-canvas {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  box-shadow:
    0 0 0 5px var(--bg-card),
    0 0 0 8px var(--accent),
    0 0 30px var(--accent-glow);
  transition: box-shadow 0.3s;
}

/* ========================================
   SPIN BUTTON (compact)
   ======================================== */
.spin-btn {
  width: 150px;
  height: 44px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  border: none;
  border-radius: 22px;
  background: linear-gradient(135deg, #e94560, #c81e45);
  color: white;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.spin-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 30px var(--accent-glow);
}

.spin-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.spin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pulse animation when ready to spin */
.spin-btn--ready {
  animation: pulse 1.8s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); }
  50% { box-shadow: 0 4px 40px var(--accent-glow), 0 0 60px var(--accent-glow); }
}

/* ========================================
   RESULT MODAL
   ======================================== */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
  padding: 16px;
}

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

.result-modal {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(233, 69, 96, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.result-modal__emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}

.result-modal__title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--success);
}

.result-modal__prize {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.result-modal__desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.result-modal__btn {
  padding: 12px 36px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  background: var(--success);
  color: white;
  cursor: pointer;
  transition: transform 0.15s;
}

.result-modal__btn:hover {
  transform: translateY(-1px);
}

/* ========================================
   WINNERS LIST — fills remaining space
   ======================================== */
.winners-section {
  width: 100%;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--input-border);
  flex: 1;
  min-height: 0; /* important: allows flex child to shrink below content size */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.winners-section__title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  flex-shrink: 0;
}

.winners-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  /* Hide scrollbar but keep scrollable */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.winners-list::-webkit-scrollbar {
  display: none;
}

.winners-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--input-border);
  animation: fadeSlideIn 0.3s ease;
  flex-shrink: 0;
}

.winners-list__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.winners-list__info {
  flex: 1;
  min-width: 0;
}

.winners-list__name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.winners-list__prize {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.winners-list__time {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.winners-list__empty {
  text-align: center;
  padding: 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ========================================
   CONFETTI CANVAS
   ======================================== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

/* ========================================
   RESPONSIVE (small phones)
   ======================================== */
@media (max-height: 600px) {
  #app {
    padding: 10px 14px 8px;
  }

  .header {
    margin-bottom: 8px;
  }

  .header__title {
    font-size: 1.3rem;
  }

  .code-form__input {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .code-form__btn {
    padding: 8px 20px;
  }

  #wheel-canvas {
    width: 200px;
    height: 200px;
  }

  .spin-btn {
    width: 130px;
    height: 38px;
    font-size: 1rem;
  }

  .wheel-section {
    gap: 10px;
  }
}

@media (max-width: 380px) {
  .header__title {
    font-size: 1.3rem;
  }

  #wheel-canvas {
    width: 200px;
    height: 200px;
  }
}
