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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --success-hover: #16a34a;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --accent: #f59e0b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

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

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1.25rem;
}

.hidden {
  display: none !important;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

input[type="number"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

.main {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 360px);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 700px) {
  .main {
    grid-template-columns: 1fr;
  }
}

.draw-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.sorteio-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.progress-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.roulette-stage {
  position: relative;
  width: min(100%, 320px);
  height: 320px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-outer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: transform 0.1s linear;
}

.wheel-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 6px solid #d4a017;
  box-shadow:
    0 0 0 3px #8b6914,
    0 0 30px rgba(212, 160, 23, 0.3),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.wheel-rim::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 7deg,
    rgba(251, 191, 36, 0.55) 7deg 9deg
  );
  pointer-events: none;
}

.wheel-disk {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from -90deg,
    #b91c1c 0deg 10deg,
    #0f172a 10deg 20deg
  );
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4);
}

.wheel-hub {
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3d4f6f, #1a2332 60%, #0f1419);
  border: 3px solid #d4a017;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
}

.wheel-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 22px solid #fbbf24;
  z-index: 10;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

.roulette-stage.spinning .wheel-pointer {
  animation: pointer-tick 0.12s ease infinite;
}

.roulette-stage.spinning .wheel-rim {
  box-shadow:
    0 0 0 3px #8b6914,
    0 0 50px rgba(212, 160, 23, 0.5),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.number-display {
  position: relative;
  z-index: 5;
  background: linear-gradient(180deg, #1e2d42 0%, #141c28 100%);
  border: 3px solid #d4a017;
  border-radius: 14px;
  min-width: 200px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.number-display.revealed {
  border-color: #fbbf24;
  box-shadow:
    0 0 50px rgba(251, 191, 36, 0.35),
    0 8px 32px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.08);
  animation: reveal-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.number-display .placeholder {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0 1rem;
  text-align: center;
}

.slot-machine {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  background: #0a0f16;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.reel {
  width: 36px;
  height: 58px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, #1a2838, #0d1520);
  border-radius: 6px;
  border: 1px solid #2d3f56;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

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

.reel::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(10, 15, 22, 0.95), transparent);
}

.reel::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(10, 15, 22, 0.95), transparent);
}

.reel.static {
  display: flex;
  align-items: center;
  justify-content: center;
}

.reel.static .reel-digit {
  height: 58px;
}

.reel-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.reel-digit {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  flex-shrink: 0;
}

.reel.stopped .reel-digit.target,
.slot-machine.revealed .reel-digit {
  color: #fbbf24;
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.5);
}

.roulette-stage.spinning .reel:not(.stopped) .reel-digit {
  color: #93c5fd;
}

@keyframes pointer-tick {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  50% { transform: translateX(-50%) rotate(8deg); }
}

@keyframes reveal-pop {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.draw-actions {
  margin-bottom: 1rem;
}

.secondary-actions {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8125rem;
  padding: 0.4rem 0.75rem;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--text-muted);
  color: var(--text);
}

.results-panel {
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.results-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.results-header h2 {
  margin-bottom: 0;
}

.results-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.results-actions .btn {
  width: 100%;
  text-align: center;
  padding: 0.5rem 0.5rem;
}

.results-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.results-list {
  list-style: none;
  flex: 1;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.results-list::-webkit-scrollbar {
  width: 6px;
}

.results-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.results-list li {
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.results-list li:last-child {
  margin-bottom: 0;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.results-list li.nao-vendido {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.05);
}

.results-list li.vendido {
  border-color: rgba(34, 197, 94, 0.2);
}

.results-list .sorteio-num {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.results-list .ticket-num {
  color: var(--text);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.results-list li.nao-vendido .ticket-num {
  color: var(--text-muted);
  text-decoration: line-through;
}

.status-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge.vendido {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
}

.empty-results {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 2rem 0.5rem;
}

.completed {
  text-align: center;
  margin-top: 1.25rem;
}

.completed h2 {
  color: var(--success);
  font-size: 1.25rem;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0.5rem;
}

.completed p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.completed .btn {
  margin: 0 0.375rem;
}
