* {
  box-sizing: border-box;
}

:root {
  --surface: #191b24;
  --grid-dot: rgba(50, 52, 62, 0.45);
  --accent: #c8ff00;
  --panel: #21242f;
  --panel-border: #2e3140;
  --text: #e8eaf0;
  --muted: #9a9db0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'SN Pro', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: var(--surface);
  background-image: radial-gradient(var(--grid-dot) 1px, var(--surface) 1px);
  background-size: 20px 20px;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.app__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.app__title {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.app__lead {
  margin: 0.5rem auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.stage {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
  justify-content: center;
}

/* ---------- Wheel ---------- */

.wheel-wrap {
  position: relative;
  width: min(420px, 90vw);
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.45));
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 34px solid #ff4d6d;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
  z-index: 3;
  transition: transform 0.1s ease;
}

.pointer.tick {
  transform: translateX(-50%) rotate(-14deg);
}

.spin-btn {
  position: absolute;
  z-index: 2;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 5px solid #12141b;
  background: radial-gradient(circle at 32% 28%, #e6ff6b, var(--accent) 55%, #9dcc00);
  color: #16181f;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(0.85rem, 2.4vw, 1.15rem);
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.spin-btn:hover:not(:disabled) {
  transform: scale(1.06);
  filter: brightness(1.06);
}

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

.spin-btn:disabled {
  cursor: wait;
  filter: saturate(0.5) brightness(0.85);
}

/* ---------- Panel ---------- */

.panel {
  flex: 1 1 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel__block {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}

.panel__title {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.sectors-input {
  width: 100%;
  resize: vertical;
  background: #16181f;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font-family: 'SN Pro', system-ui, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
}

.sectors-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.panel__row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #2a2d3a;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: #343848;
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #16181f;
}

.panel__hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.sectors-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sectors-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: #16181f;
  border: 1px solid var(--panel-border);
  font-size: 0.9rem;
}

.sectors-list li span:nth-child(2) {
  flex: 1;
}

.sectors-list__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.result {
  min-height: 3.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: #16181f;
  border: 1px dashed var(--panel-border);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--muted);
  transition: color 0.2s ease;
}

.result.win {
  color: var(--accent);
  border-color: var(--accent);
  border-style: solid;
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.profile__row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile__avatar {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: #16181f;
  border: 1px solid var(--accent);
  border-radius: 50%;
}

.profile__info {
  display: flex;
  flex-direction: column;
}

.profile__name {
  font-weight: 700;
  font-size: 0.95rem;
}

.profile__tickets {
  color: var(--accent);
  font-weight: 800;
  font-size: 1.05rem;
}

.profile__tickets.bump {
  animation: pop 0.4s ease;
}

.history {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.history li {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: #16181f;
  border: 1px solid var(--panel-border);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.history li span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ---------- Confetti ---------- */

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.9;
  }
}

/* ---------- Декор фона ---------- */

.deco-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.deco {
  position: absolute;
  top: -8vh;
  opacity: 0.55;
  animation: deco-fall linear infinite;
  filter: drop-shadow(0 0 6px rgba(200, 255, 0, 0.25));
}

@keyframes deco-fall {
  0% {
    transform: translateY(-10vh) rotate(0deg) translateX(0);
  }
  50% {
    transform: translateY(55vh) rotate(180deg) translateX(18px);
  }
  100% {
    transform: translateY(115vh) rotate(360deg) translateX(-10px);
  }
}

.app {
  position: relative;
  z-index: 1;
}

/* ---------- Открывающийся подарок ---------- */

.gift-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(10, 11, 16, 0.88);
}

.gift-overlay.show {
  display: flex;
}

.gift {
  position: relative;
  width: 180px;
  height: 180px;
}

.gift__box,
.gift__lid {
  position: absolute;
  left: 50%;
  font-size: 100px;
  line-height: 1;
}

.gift__box {
  bottom: 0;
  transform: translateX(-50%);
}

.gift__lid {
  bottom: 55px;
  transform: translateX(-50%);
  font-size: 56px;
}

.gift-overlay.show .gift__box {
  animation: gift-shake 1.2s ease-in-out;
}

.gift-overlay.show .gift__lid {
  animation: lid-fly 1.2s ease-in forwards;
}

.gift__burst {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  font-size: 64px;
  opacity: 0;
}

.gift-overlay.show .gift__burst {
  animation: burst 1s ease-out 1.1s forwards;
}

.gift__text {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 800;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.7);
}

.gift-overlay.show .gift__text {
  animation: pop 0.5s ease 1.5s forwards;
}

@keyframes gift-shake {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  15% { transform: translateX(-54%) rotate(-8deg); }
  30% { transform: translateX(-46%) rotate(8deg); }
  45% { transform: translateX(-54%) rotate(-8deg); }
  60% { transform: translateX(-46%) rotate(8deg); }
  75% { transform: translateX(-52%) rotate(-5deg); }
}

@keyframes lid-fly {
  0%, 70% { transform: translateX(-50%) translateY(0) rotate(0); opacity: 1; }
  85% { transform: translateX(-50%) translateY(-70px) rotate(-30deg); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-130px) rotate(-60deg); opacity: 0; }
}

@keyframes burst {
  0% { opacity: 0; transform: translateX(-50%) scale(0.3); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.4); }
  100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
}

/* ---------- Змейка ---------- */

.left-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  flex: 0 0 auto;
}

.snake {
  width: min(420px, 90vw);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.snake__head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.snake__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.snake__meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

#snakeCanvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background: #10121a;
  display: block;
}

.snake__start {
  width: 100%;
  padding: 0.55rem;
  background: var(--accent);
  border-color: var(--accent);
  color: #16181f;
}

.snake__controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.snake__row {
  display: flex;
  gap: 0.3rem;
}

.snake__pad {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #2a2d3a;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.snake__pad:hover {
  background: #343848;
}

.snake__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .stage {
    flex-direction: column;
    align-items: center;
  }

  .panel {
    max-width: min(420px, 90vw);
  }
}
