:root {
  --red: #c0392b;
  --black-btn: #2a2a2a;
  --green: #1b7a3f;
  --bg: #0d3b1a;
  --gold: #f0c040;
  --border: #8B6914;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ── History strip ─────────────────────────────────── */

.history-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.35);
  flex-shrink: 0;
  min-height: 54px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.history-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.45;
  white-space: nowrap;
  flex-shrink: 0;
}

.history-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: center;
}
.history-chips::-webkit-scrollbar { display: none; }

.history-empty {
  font-size: 12px;
  opacity: 0.3;
  font-style: italic;
}

.chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
  letter-spacing: -0.5px;
}
.chip.red    { background: var(--red); }
.chip.black  { background: #1a1a1a; border-color: rgba(255,255,255,0.15); }
.chip.green  { background: var(--green); }
.chip.newest { border-color: var(--gold); box-shadow: 0 0 6px rgba(240,192,64,0.5); }

/* ── Display section ─────────────────────────────────── */

.display-section {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 0 0 auto;
  height: 30vh;
  min-height: 180px;
  max-height: 280px;
  padding: 8px 10px;
  gap: 8px;
}

.wheel-container {
  flex: 0 0 auto;
  width: 30vh;
  min-width: 160px;
  max-width: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

.number-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.current-number {
  font-size: clamp(68px, 18vw, 130px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -3px;
  color: rgba(255,255,255,0.25);
  transition: color 0.15s;
}

.current-color-label {
  font-size: clamp(12px, 3vw, 18px);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 3px;
  opacity: 0.8;
  transition: color 0.15s;
}

.stats {
  margin-top: 6px;
  text-align: center;
  width: 100%;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 3px 0;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.5;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.stat-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  border: 1.5px solid rgba(255,255,255,0.2);
  letter-spacing: -0.5px;
}
.stat-chip.red   { background: var(--red); }
.stat-chip.black { background: #1a1a1a; border-color: rgba(255,255,255,0.15); }
.stat-chip.green { background: var(--green); }
.stat-chip.hot   { border-color: rgba(255, 120, 60, 0.7); }
.stat-chip.cold  { border-color: rgba(80, 140, 255, 0.7); }

.stats-placeholder {
  font-size: 11px;
  opacity: 0.3;
  font-style: italic;
}

/* ── Input section ─────────────────────────────────── */

.input-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 8px 8px;
  gap: 6px;
  min-height: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.number-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}

.grid-row {
  display: flex;
  gap: 5px;
  flex: 1;
  min-height: 0;
}

.num-btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-weight: 800;
  font-size: clamp(15px, 2.8vw, 24px);
  cursor: pointer;
  border-bottom: 3px solid rgba(0,0,0,0.35);
  transition: transform 0.06s, filter 0.06s;
  min-width: 0;
  padding: 0;
  letter-spacing: -0.5px;
}

.num-btn:active {
  transform: scale(0.91);
  filter: brightness(1.35);
  border-bottom-width: 1px;
}

.num-btn.red   { background: var(--red); }
.num-btn.black { background: var(--black-btn); }
.num-btn.green { background: var(--green); }
.num-btn.zero  { flex: 2.5; font-size: clamp(16px, 3.2vw, 26px); }

.clear-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.45);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  align-self: flex-end;
  min-width: 160px;
}

.clear-btn.confirming {
  background: rgba(200, 30, 30, 0.25);
  border-color: rgba(200, 30, 30, 0.5);
  color: #ff8080;
}

/* ── Landscape adjustments ─────────────────────────── */

@media (orientation: landscape) and (max-height: 600px) {
  .display-section {
    height: 42vh;
    max-height: none;
  }

  .wheel-container {
    width: 38vh;
    max-width: none;
  }

  .current-number {
    font-size: clamp(48px, 12vh, 110px);
  }
}

@media (orientation: landscape) and (min-height: 600px) {
  .display-section {
    height: 36vh;
    max-height: none;
  }
}
