:root {
  --cream: #f4f5f7;
  --cream-soft: #e9edf2;
  --cream-deep: #d8dee8;
  --ivory: #ffffff;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --ink-muted: #6b7280;
  --ink-line: rgba(31, 41, 55, 0.14);
  --ink-line-strong: rgba(31, 41, 55, 0.32);
  --burgundy: #111827;
  --burgundy-deep: #0f172a;
  --available: #15803d;
  --number-invalid: #2563eb;
  --number-invalid-bg: rgba(37, 99, 235, 0.1);
  --number-invalid-ring: rgba(37, 99, 235, 0.2);
  --font-sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: var(--font-sans);
  --radius: 4px;
  --shadow-soft: 0 1px 2px rgba(42, 37, 40, 0.06), 0 8px 24px rgba(42, 37, 40, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--cream);
  background-image: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 24px 40px;
  text-align: center;
}

.toolbar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 76px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 0 14px;
}

.app-title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.draw-layout,
.draw-layout--wheel {
  display: block;
  width: 100%;
}

.wheel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.wheel-wrap {
  position: relative;
  order: 1;
  display: grid;
  place-items: center;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: 0;
  padding: 80px 20px 34px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #ffffff, #eef2f7);
  border-top: 1px solid var(--ink-line);
  border-bottom: 1px solid var(--ink-line);
}

.wheel-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(31, 41, 55, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 41, 55, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 1;
}

#wheelCanvas {
  position: relative;
  z-index: 1;
  width: min(86vw, 580px);
  height: auto;
  aspect-ratio: 1;
  filter: drop-shadow(0 22px 44px rgba(0, 0, 0, 0.34));
  transform: rotate(var(--wheel-rotation, 0deg));
  transition: transform var(--spin-duration, 0ms) cubic-bezier(0.12, 0.76, 0.1, 1);
}

.pointer {
  position: absolute;
  z-index: 3;
  top: 72px;
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 50px solid var(--number-invalid);
  filter: drop-shadow(0 7px 8px rgba(37, 99, 235, 0.2));
}

.wheel-center {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  top: calc(80px + min(86vw, 580px) / 2);
  left: 50%;
  width: min(13vw, 70px);
  min-width: 44px;
  aspect-ratio: 1;
  border: 7px solid var(--ivory);
  border-radius: 50%;
  background: var(--number-invalid);
  box-shadow: 0 16px 28px rgba(31, 41, 55, 0.18);
  transform: translate(-50%, -50%);
}

.winner-card {
  position: relative;
  order: 2;
  width: 100%;
  margin: 52px 8px 34px;
  padding: 46px 22px 28px;
  color: var(--burgundy);
  background: transparent;
  border: 0;
}

.winner-card::before {
  content: "Generated Number";
  position: absolute;
  top: 12px;
  left: 50%;
  padding: 0 6px;
  color: var(--burgundy);
  background: var(--cream);
  font-family: var(--font-sans);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.winner-label {
  display: none;
}

.winner-card strong {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  color: var(--burgundy);
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 28vw, 8.8rem);
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.wheel-actions {
  order: 3;
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.range-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  padding: 16px;
  text-align: left;
  background: var(--ivory);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius);
}

.range-validation {
  grid-column: 1 / -1;
  margin-top: 0;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 0 22px;
  border-radius: 0;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.primary-button {
  gap: 10px;
  color: var(--ivory);
  background: var(--ink);
  border: 1px solid var(--ink);
}

.primary-button:hover:not(:disabled) {
  color: var(--ivory);
  background: var(--burgundy);
  border-color: var(--burgundy);
}

.ghost-button {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink-line-strong);
}

.ghost-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--cream-soft);
  border-color: var(--ink);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

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

.admin-overlay,
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: rgba(42, 37, 40, 0.55);
  backdrop-filter: blur(2px);
}

.admin-overlay.hidden,
.login-overlay.hidden {
  display: none;
}

.admin-panel,
.login-card {
  width: min(100%, 480px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 32px 28px;
  text-align: left;
  color: var(--ink);
  background: var(--ivory);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel-heading {
  position: relative;
  margin-bottom: 28px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.4rem, 12vw, 4.3rem);
}

h2 {
  font-size: clamp(2rem, 9vw, 3.2rem);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.control-grid--single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field span,
.metric-label {
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

input,
textarea {
  display: block;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--ink-line-strong);
  border-radius: 0;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--ivory);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
textarea:hover {
  border-color: var(--ink);
}

input:focus,
textarea:focus {
  border-color: var(--ink);
  background: var(--cream-soft);
  box-shadow: 0 0 0 3px rgba(42, 37, 40, 0.08);
}

textarea {
  min-height: 138px;
  resize: vertical;
  line-height: 1.45;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: 100%;
  margin: 24px 0 0;
  padding: 18px 0;
  border-top: 1px solid var(--ink-line);
  border-bottom: 1px solid var(--ink-line);
}

.mini-grid div {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 4px 8px;
  text-align: center;
  border-right: 1px solid var(--ink-line);
}

.mini-grid div:last-child {
  border-right: 0;
}

.mini-grid strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.validation {
  min-height: 1.5em;
  margin: 14px 0 0;
  color: var(--number-invalid);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.login-brand {
  display: block;
  margin-bottom: 24px;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

@media (min-width: 560px) {
  .wheel-wrap {
    padding-top: 90px;
  }

  #wheelCanvas {
    width: min(72vw, 600px);
  }

  .wheel-center {
    top: calc(90px + min(72vw, 600px) / 2);
  }
}

@media (min-width: 860px) {
  .app-shell {
    width: min(100%, 680px);
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .control-grid,
  .range-panel,
  .mini-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .mini-grid {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .mini-grid div {
    border-right: 0;
    border-bottom: 1px solid var(--ink-line);
    padding: 13px 8px;
  }

  .winner-card {
    padding-top: 38px;
  }

  .pointer {
    top: 74px;
    border-left-width: 18px;
    border-right-width: 18px;
    border-top-width: 42px;
  }
}
