:root {
  --bg: #070604;
  --bg-soft: #11100c;
  --panel: rgba(19, 17, 12, 0.84);
  --panel-strong: rgba(30, 24, 13, 0.96);
  --line: rgba(232, 190, 91, 0.25);
  --gold: #f7d57d;
  --gold-2: #b7832d;
  --gold-3: #fff3b0;
  --text: #fff8e9;
  --muted: #cdbf9d;
  --danger: #ff6969;
  --success: #8dffb0;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-display: "Cinzel", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="royal"] {
  --bg: #05070d;
  --bg-soft: #0a1020;
  --panel: rgba(10, 16, 32, 0.86);
  --panel-strong: rgba(14, 21, 42, 0.94);
  --line: rgba(133, 173, 255, 0.25);
  --gold: #a7c4ff;
  --gold-2: #607cd8;
  --gold-3: #edf4ff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(247, 213, 125, 0.16), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(183, 131, 45, 0.14), transparent 30rem),
    linear-gradient(135deg, var(--bg), #000);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.bg-ornament {
  position: fixed;
  z-index: 0;
  width: 360px;
  height: 360px;
  border: 1px solid var(--line);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.4;
  filter: blur(0.2px);
}

.bg-ornament::before,
.bg-ornament::after {
  content: "";
  position: absolute;
  inset: 38px;
  border: 1px solid var(--line);
  border-radius: inherit;
}

.bg-ornament::after {
  inset: 84px;
}

.bg-ornament-one {
  top: -120px;
  left: -120px;
}

.bg-ornament-two {
  right: -140px;
  bottom: -130px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero-card,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)), var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 180px;
  padding: 30px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 440px;
  height: 440px;
  right: -170px;
  top: -220px;
  background: radial-gradient(circle, rgba(247, 213, 125, 0.28), transparent 62%);
  pointer-events: none;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--gold-3);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
}

.hero-copy h1 {
  margin: 8px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: 0.035em;
  background: linear-gradient(92deg, var(--gold-3), var(--gold), var(--gold-2), var(--gold-3));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 22px 80px rgba(247, 213, 125, 0.14);
  animation: shineText 7s linear infinite;
}

.subtitle {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.8vw, 1.18rem);
  line-height: 1.65;
}

.hero-actions,
.control-row,
.secondary-controls,
.main-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 22px;
  margin-top: 22px;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel-header h2 {
  margin: 5px 0 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--gold-3);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.btn {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 850;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn-primary,
.btn-start {
  background: linear-gradient(135deg, var(--gold-3), var(--gold), var(--gold-2));
  color: #1a1204;
  box-shadow: 0 14px 34px rgba(247, 213, 125, 0.24);
}

.btn-secondary {
  background: rgba(247, 213, 125, 0.12);
  border: 1px solid var(--line);
  color: var(--gold-3);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-stop {
  background: linear-gradient(135deg, #ffffff, var(--gold-3));
  color: #1d1203;
  box-shadow: 0 14px 34px rgba(255, 255, 255, 0.16);
}

.btn.danger {
  color: #ffd1d1;
  border-color: rgba(255, 105, 105, 0.28);
}

.upload-zone {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 230px;
  padding: 22px;
  border: 1.5px dashed rgba(247, 213, 125, 0.42);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(247, 213, 125, 0.09), rgba(255, 255, 255, 0.025));
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.upload-zone.dragging {
  border-color: var(--gold-3);
  background: rgba(247, 213, 125, 0.16);
  transform: scale(1.01);
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: rgba(247, 213, 125, 0.14);
  border: 1px solid var(--line);
  color: var(--gold-3);
  font-size: 1.7rem;
  font-weight: 900;
}

.upload-zone h3 {
  margin: 0 0 8px;
}

.upload-zone p {
  max-width: 310px;
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.field-label {
  display: inline-block;
  margin: 20px 0 8px;
  color: var(--gold-3);
  font-weight: 850;
  font-size: 0.9rem;
}

.manual-input {
  width: 100%;
  min-height: 138px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 14px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  outline: none;
  line-height: 1.5;
}

.manual-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(247, 213, 125, 0.08);
}

.control-row {
  margin-top: 12px;
}

.setting-box {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.16);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.stat-card {
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 5px;
  color: var(--gold-3);
  font-size: clamp(1.05rem, 2vw, 1.45rem);
}

.message-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.5;
  font-size: 0.9rem;
}

.message-box.success {
  border-color: rgba(141, 255, 176, 0.3);
  color: #dfffe8;
}

.message-box.error {
  border-color: rgba(255, 105, 105, 0.35);
  color: #ffd5d5;
}

.message-box.warning {
  border-color: rgba(247, 213, 125, 0.35);
  color: #fff1c3;
}

.slot-panel {
  min-height: 680px;
  display: flex;
  flex-direction: column;
}

.slot-header {
  align-items: center;
}

.draw-config {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.draw-config input {
  width: 92px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  text-align: center;
  outline: none;
  font-weight: 900;
}

.slot-machine {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 365px;
  margin-top: 6px;
}

.slot-glow {
  position: absolute;
  inset: 12% 8%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(247, 213, 125, 0.25), transparent 64%);
  filter: blur(18px);
}

.slot-frame {
  position: relative;
  width: min(780px, 100%);
  height: 330px;
  padding: 18px;
  border-radius: 38px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.02)),
    linear-gradient(135deg, var(--gold-3), var(--gold-2));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.22),
    0 26px 90px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(247, 213, 125, 0.13);
}

.reel-mask {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.93), rgba(17, 13, 5, 0.98)),
    #090805;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.reel-mask::before,
.reel-mask::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 86px;
  z-index: 4;
  pointer-events: none;
}

.reel-mask::before {
  top: 0;
  background: linear-gradient(180deg, #050402 20%, transparent);
}

.reel-mask::after {
  bottom: 0;
  background: linear-gradient(0deg, #050402 20%, transparent);
}

.reel-list {
  position: relative;
  z-index: 2;
  list-style: none;
  padding: 0;
  margin: 0;
  transform: translateY(0);
  transition: transform 0.08s linear;
}

.reel-list li {
  display: grid;
  place-items: center;
  height: 72px;
  padding: 0 22px;
  color: rgba(255, 248, 233, 0.48);
  font-size: clamp(1rem, 2.8vw, 2.1rem);
  font-weight: 950;
  text-align: center;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  line-height: 1.05;
}

.reel-list li:nth-child(4) {
  color: var(--gold-3);
  font-size: clamp(1.35rem, 4.1vw, 3rem);
  text-shadow: 0 0 28px rgba(247, 213, 125, 0.28);
}

.center-marker {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  height: 82px;
  transform: translateY(-50%);
  z-index: 3;
  border: 1px solid rgba(247, 213, 125, 0.42);
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(247, 213, 125, 0.05), rgba(247, 213, 125, 0.16), rgba(247, 213, 125, 0.05));
  box-shadow: inset 0 0 26px rgba(247, 213, 125, 0.08), 0 0 30px rgba(247, 213, 125, 0.12);
  pointer-events: none;
}

.slot-panel.rolling .slot-frame {
  animation: pulseFrame 0.8s ease-in-out infinite alternate;
}

.winner-showcase {
  display: grid;
  place-items: center;
  min-height: 128px;
  margin: 8px 0 18px;
  padding: 18px;
  text-align: center;
  border: 1px solid rgba(247, 213, 125, 0.24);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(247, 213, 125, 0.1), rgba(255, 255, 255, 0.028));
}

.winner-showcase p {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

.winner-showcase h3 {
  margin: 0;
  color: var(--gold-3);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 4.4rem);
  line-height: 1.05;
  text-transform: uppercase;
  text-shadow: 0 12px 50px rgba(247, 213, 125, 0.25);
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.main-controls {
  justify-content: center;
  margin-top: auto;
}

.main-controls .btn {
  min-height: 58px;
  padding: 0 28px;
  font-size: 1.05rem;
}

.secondary-controls {
  justify-content: center;
  margin-top: 14px;
}

.winner-panel {
  margin-top: 22px;
}

.winner-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.winner-list.empty {
  display: block;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  text-align: center;
}

.winner-list.empty p {
  margin: 0;
}

.winner-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "number name"
    "number time";
  gap: 4px 12px;
  align-items: center;
  min-height: 82px;
  padding: 14px;
  border: 1px solid rgba(247, 213, 125, 0.2);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.045);
}

.winner-number {
  grid-area: number;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-3), var(--gold-2));
  color: #1a1204;
  font-weight: 950;
}

.winner-person {
  grid-area: name;
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.25;
}

.winner-time {
  grid-area: time;
  color: var(--muted);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

body.fullscreen-mode .app-shell {
  width: min(1600px, calc(100% - 32px));
}

body.fullscreen-mode .hero-card {
  min-height: 120px;
}

body.fullscreen-mode .setup-panel,
body.fullscreen-mode .winner-panel {
  display: none;
}

body.fullscreen-mode .dashboard-grid {
  grid-template-columns: 1fr;
}

body.fullscreen-mode .slot-panel {
  min-height: calc(100vh - 190px);
}

body.fullscreen-mode .slot-frame {
  width: min(1120px, 100%);
  height: min(420px, 46vh);
}

body.fullscreen-mode .reel-list li {
  height: 86px;
}

@keyframes shineText {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes pulseFrame {
  from { filter: brightness(1); transform: translateY(0); }
  to { filter: brightness(1.12); transform: translateY(-2px); }
}

@media (max-width: 980px) {
  .hero-card,
  .panel-header,
  .slot-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .hero-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .hero-card,
  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .slot-frame {
    height: 300px;
    border-radius: 26px;
    padding: 12px;
  }

  .main-controls .btn,
  .btn {
    width: 100%;
  }

  .draw-config {
    justify-content: space-between;
  }
}
