﻿:root {
  --bg-image: url("./assets/bg.png");
  --poster-image: url("./assets/bg.png");
  --poster-ratio: 723 / 1024;
  --bg-fit: contain;
  --bg-dim: 0.06;
  --bg-blur: 0px;
  --text: #edf3ff;
  --muted: #a9b8d8;
  --card: rgba(7, 22, 52, 0.74);
  --card-border: rgba(255, 255, 255, 0.14);
  --primary-1: #efb34b;
  --primary-2: #ec7100;
  --wheel-size: 500px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Inter", "Segoe UI", "Segoe UI Variable Text", Tahoma, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: radial-gradient(120% 100% at 35% 8%, #1d4f9f 0%, #052968 44%, #01163f 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(120% 100% at 0% 0%, rgba(132, 178, 255, 0.16), transparent 60%), var(--bg-image);
  background-size: cover, var(--bg-fit);
  background-repeat: no-repeat;
  background-position: center, center;
  opacity: 0.34;
  filter: blur(var(--bg-blur));
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1460px;
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow: hidden;
}

.topbar {
  min-height: 72px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 22, 52, 0.76);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.brand {
  min-width: 0;
  flex: 1;
  border-radius: 0;
  border: 0;
  background: transparent;
  padding: 10px 14px 10px 16px;
  position: relative;
}

.brand::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, #f8c96a, #88c3ff);
}

.brand__title {
  font-size: clamp(20px, 1.45vw, 30px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: 0;
  padding-left: 10px;
  overflow-wrap: anywhere;
}

.brand__sub {
  padding-left: 10px;
  margin-top: 3px;
  color: #c3d0e8;
  font-size: clamp(11px, 0.72vw, 14px);
  line-height: 1.2;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(320px, 0.82fr) minmax(240px, 0.55fr);
  gap: 14px;
}

.stage,
.poster,
.side {
  min-width: 0;
  min-height: 0;
}

.stage {
  overflow: hidden;
}

.wheelCard {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 6px 4px 4px;
}

.wheelWrap {
  width: min(var(--wheel-size), 96%);
  aspect-ratio: 1 / 1;
  position: relative;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 24px 52px rgba(0, 0, 0, 0.56));
  margin-bottom: 12px;
}

.wheelWrap::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  border: 4px solid rgba(255, 255, 255, 0.74);
}

.wheel {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  background: rgba(7, 14, 30, 0.2);
  box-shadow: inset 0 0 0 6px rgba(39, 18, 12, 0.42);
}

.pointer {
  position: absolute;
  z-index: 3;
  top: -20px;
  left: 50%;
  width: 58px;
  height: 86px;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.pointer::before {
  content: "";
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 44px solid #ffffff;
}

.pointer::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.98);
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
}

.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.statusText {
  display: none;
}

.posterCard {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 22px;
  border: 1px solid var(--card-border);
  background: var(--card);
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.posterCard::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--poster-image);
  background-size: cover;
  background-position: center;
  filter: blur(9px) saturate(1.08);
  transform: scale(1.06);
  opacity: 0.9;
  pointer-events: none;
}

.posterCard::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 18, 46, 0.22), rgba(5, 18, 46, 0.34));
  pointer-events: none;
}

.posterImage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  display: block;
}

.panel {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 22px;
  border: 1px solid var(--card-border);
  background: var(--card);
  padding: 12px;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.panel__title {
  font-size: clamp(15px, 1vw, 21px);
  line-height: 1.15;
  font-weight: 800;
}

.history {
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.historyItem {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

.historyItem__name {
  font-size: clamp(12px, 0.8vw, 15px);
  line-height: 1.18;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.historyItem__prize {
  font-weight: 900;
  color: #f3f7ff;
}

.historyItem__time {
  margin-top: 4px;
  font-size: clamp(12px, 0.7vw, 14px);
  color: var(--muted);
  line-height: 1.2;
}

.btn {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.03);
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2));
  border-color: rgba(255, 255, 255, 0.18);
  color: #201000;
}

.btn--xl {
  min-width: clamp(160px, 14vw, 250px);
  height: clamp(48px, 4.5vw, 66px);
  border-radius: 999px;
  font-size: clamp(22px, 1.9vw, 34px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  font-family: "Inter", "Segoe UI", "Segoe UI Variable Text", Tahoma, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  text-rendering: optimizeLegibility;
}

.dialog {
  width: min(460px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 0;
  background: #0d1a2d;
  color: var(--text);
}

.dialog::backdrop {
  background: rgba(2, 7, 17, 0.7);
  backdrop-filter: blur(3px);
}

.dialog__inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--card-border);
}

.dialog__title {
  font-size: 17px;
  font-weight: 800;
}

.dialog__body {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialog__foot {
  padding: 12px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
}

.input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
}

.errorText {
  min-height: 18px;
  color: #ff8da5;
  font-size: 12px;
}

.dialog--result {
  width: min(760px, calc(100vw - 24px));
}

.dialog--result .dialog__inner {
  display: block;
}

.result {
  position: relative;
  overflow: hidden;
  padding: 28px 24px 26px;
  text-align: center;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confettiPiece {
  position: absolute;
  left: var(--left, 50%);
  top: -14%;
  width: var(--size, 10px);
  height: calc(var(--size, 10px) * 1.2);
  border-radius: 999px;
  opacity: 0;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
  animation: confettiRain var(--duration, 3000ms) linear forwards;
}

@keyframes confettiRain {
  0% {
    opacity: 0;
    transform: translate3d(0, -5vh, 0) rotate(0deg);
  }
  8% {
    opacity: 0.95;
  }
  85% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift, 0px), 112vh, 0) rotate(var(--rot, 360deg));
  }
}

.result__badge {
  position: relative;
  z-index: 6;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.result__image {
  position: relative;
  z-index: 6;
  display: block;
  width: min(430px, 86%);
  max-height: 360px;
  margin: 18px auto 2px;
  border-radius: 12px !important;
  object-fit: contain;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  overflow: visible;
  clip-path: none;
}

#resultPrizeImage {
  border-radius: 14px !important;
  overflow: hidden !important;
  clip-path: inset(0 round 14px);
}

.result__title {
  position: relative;
  z-index: 6;
  margin-top: 14px;
  font-size: clamp(20px, 3.2vw, 36px);
  font-weight: 900;
  line-height: 1.08;
}

.result__sub {
  position: relative;
  z-index: 6;
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(13px, 1.2vw, 18px);
  line-height: 1.25;
}

.result__actions {
  position: relative;
  z-index: 6;
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

@media (min-width: 1367px) {
  .main {
    grid-template-columns: minmax(340px, 1fr) clamp(390px, 36vw, 520px) minmax(240px, 0.58fr);
    column-gap: 0;
  }

  .stage {
    overflow: visible;
    padding-right: 12px;
  }

  .wheelCard {
    grid-template-rows: auto auto;
    align-content: start;
    gap: 14px;
    padding: 16px 4px 8px;
  }

  .wheelWrap {
    width: min(var(--wheel-size), 98%);
  }

  .controls {
    margin-top: 14px;
  }

  .statusText {
    min-height: 16px;
  }

  .poster {
    align-self: start;
  }

  .side {
    align-self: start;
  }

  .posterCard {
    height: auto;
    aspect-ratio: var(--poster-ratio);
    border-radius: 22px 0 0 22px;
    border-right: 0;
  }

  .panel {
    height: calc(clamp(390px, 36vw, 520px) / (var(--poster-ratio)));
    border-radius: 0 22px 22px 0;
    border-left: 0;
  }
}

@media (max-width: 1366px) {
  .main {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(300px, clamp(46dvh, 52dvh, 58dvh)) auto;
    grid-template-areas:
      "stage stage"
      "poster side";
    row-gap: 8px;
    column-gap: 0;
  }

  .stage {
    grid-area: stage;
    overflow: visible;
    padding-top: 6px;
  }

  .wheelCard {
    gap: 10px;
    padding: 12px 4px 8px;
  }

  .poster {
    grid-area: poster;
    width: auto;
    height: 100%;
    aspect-ratio: var(--poster-ratio);
    max-width: 100%;
    justify-self: end;
  }

  .side {
    grid-area: side;
  }

  .posterCard {
    border-radius: 10px 0 0 10px;
    border-right: 0;
    background: rgba(8, 24, 56, 0.45);
  }

  .posterImage {
    object-fit: contain;
    object-position: center top;
    background: rgba(6, 20, 48, 0.18);
  }

  .topbar {
    min-height: 66px;
    border-radius: 20px;
    padding: 8px;
  }

  .brand {
    border-radius: 10px;
    padding: 8px 10px 8px 12px;
  }

  .brand::before {
    left: 6px;
    top: 6px;
    bottom: 6px;
  }

  .brand__title {
    font-size: 26px;
    padding-left: 8px;
  }

  .brand__sub {
    font-size: 14px;
    margin-top: 2px;
    padding-left: 8px;
  }

  .panel {
    border-radius: 0 10px 10px 0;
    border-left: 0;
    padding: 6px;
    gap: 5px;
  }

  .panel__title {
    font-size: 13px;
  }

  .historyItem {
    padding: 8px 10px;
    border-radius: 8px;
  }

  .historyItem__name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .historyItem__time {
    font-size: 10px;
  }

  .panel .btn {
    height: 30px;
    font-size: 11px;
    border-radius: 9px;
    padding: 0 8px;
  }

  .btn--xl {
    min-width: 200px;
    height: 56px;
    font-size: 24px;
    line-height: 1.2;
  }
}

@media (max-width: 1366px) and (orientation: portrait) {
  .app {
    gap: 14px;
  }

  .stage {
    padding-top: 10px;
  }

  .wheelCard {
    padding-top: 16px;
  }

  .controls {
    margin-top: 10px;
    position: relative;
    z-index: 2;
  }
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(280px, clamp(42dvh, 50dvh, 56dvh)) auto;
    row-gap: 8px;
    column-gap: 0;
  }

  .posterCard {
    border-radius: 10px 0 0 10px;
    border-right: 0;
    background: rgba(8, 24, 56, 0.45);
  }

  .posterImage {
    object-fit: contain;
    object-position: center top;
    background: rgba(6, 20, 48, 0.18);
  }

  .panel {
    border-radius: 0 10px 10px 0;
    border-left: 0;
    padding: 6px;
    gap: 5px;
  }

  .panel__title {
    font-size: 11px;
  }

  .historyItem {
    padding: 6px 7px;
    border-radius: 8px;
  }

  .historyItem__name {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .historyItem__time {
    font-size: 8px;
  }

  .panel .btn {
    height: 28px;
    font-size: 10px;
    border-radius: 9px;
    padding: 0 8px;
  }
}

@media (max-width: 700px) {
  .app {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 8px;
  }

  .topbar {
    min-height: 64px;
    border-radius: 16px;
  }

  .brand__title {
    font-size: 20px;
  }

  .brand__sub {
    font-size: 11px;
    line-height: 1.2;
  }

  .main {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(240px, clamp(38dvh, 46dvh, 52dvh)) auto;
    row-gap: 8px;
    column-gap: 0;
  }

  .wheelCard {
    grid-template-rows: auto auto;
    align-content: start;
    gap: 4px;
    padding: 2px 2px 0;
  }

  .controls {
    margin-top: 10px;
    position: relative;
    z-index: 2;
  }

  .btn--xl {
    min-width: 160px;
    height: 46px;
    font-size: 22px;
  }

  .statusText {
    font-size: 10px;
    min-height: 16px;
  }

  .posterCard {
    border-radius: 10px 0 0 10px;
    border-right: 0;
    padding: 0;
    background: rgba(8, 24, 56, 0.45);
  }

  .posterImage {
    object-fit: contain;
    object-position: center top;
    background: rgba(6, 20, 48, 0.18);
  }

  .panel {
    border-radius: 0 10px 10px 0;
    border-left: 0;
    padding: 6px;
    gap: 5px;
  }

  .panel__title {
    font-size: 11px;
  }

  .historyItem {
    padding: 6px 7px;
    border-radius: 8px;
  }

  .historyItem__name {
    font-size: 10px;
  }

  .historyItem__time {
    font-size: 8px;
  }

  .panel .btn {
    height: 28px;
    font-size: 10px;
    border-radius: 9px;
    padding: 0 8px;
  }
}

