:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #111827;
  --primary: #38bdf8;
  --accent: #f97316;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --success: #4ade80;
  --danger: #f87171;
  --wheel-shadow: rgba(15, 23, 42, 0.45);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Cairo", "Tahoma", sans-serif;
  background: radial-gradient(circle at top, #1e293b, #0f172a 60%);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.app-header,
.app-footer {
  padding: 1.5rem clamp(1rem, 3vw, 3rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-header {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.branding h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: 0.01em;
}

.branding p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.state-bar button,
.actions button {
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#reset-wheel {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

#reset-wheel:hover,
.actions button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(15, 23, 42, 0.25);
}

.app-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(320px, 1fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  padding: clamp(1.5rem, 3vw, 3rem);
  align-items: start;
}

.input-panel,
.wheel-panel {
  background: rgba(17, 24, 39, 0.7);
  border-radius: 1.5rem;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow: 0 25px 50px -20px rgba(15, 23, 42, 0.65);
}

.input-panel h2,
.result-panel h2 {
  margin-top: 0;
  font-size: 1.4rem;
}

.mode-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  background: rgba(30, 41, 59, 0.65);
  border-radius: 999px;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.6rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, transform 0.2s ease;
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  color: #0f172a;
  transform: translateY(-1px);
}

.mode-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mode-form.hidden {
  display: none;
}

label {
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

textarea,
input[type="number"] {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  font-size: 1rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.range-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 1rem;
}

.actions {
  margin-top: 1.75rem;
  display: flex;
  justify-content: flex-start;
}

#spin-button {
  background: linear-gradient(135deg, var(--accent), #facc15);
  color: #0f172a;
  font-size: 1.1rem;
  min-width: 200px;
}

.wheel-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
}

.wheel-wrapper {
  position: relative;
  width: min(420px, 90vw);
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#wheel-canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 35px 60px -25px var(--wheel-shadow), inset 0 0 0 12px rgba(15, 23, 42, 0.75);
  transition: transform 4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

#wheel-canvas.spinning-fast {
  animation: spinLoop 0.8s linear infinite;
}

@keyframes spinLoop {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.pointer {
  position: absolute;
  top: -16px;
  right: 50%;
  transform: translateX(50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-bottom: 26px solid #f4f4f5;
  filter: drop-shadow(0 6px 10px rgba(15, 23, 42, 0.6));
}

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  font-weight: 700;
  color: #fefce8;
  text-shadow: 0 12px 25px rgba(15, 23, 42, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.countdown.active {
  opacity: 1;
}

.result-panel {
  width: 100%;
  background: rgba(15, 23, 42, 0.75);
  border-radius: 1.25rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.result-display {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 700;
  min-height: 2.8rem;
}

.result-display.idle {
  color: var(--muted);
}

.result-display.success {
  color: var(--success);
}

.result-display.error {
  color: var(--danger);
}

.app-footer {
  justify-content: center;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.85);
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .state-bar {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    justify-content: stretch;
  }

  #spin-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .app-header,
  .app-footer {
    text-align: center;
    align-items: center;
  }

  .branding,
  .state-bar {
    width: 100%;
    align-items: center;
    justify-content: center;
  }

  .range-fields {
    grid-template-columns: 1fr;
  }
}

