/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f1a;
  --surface: #141627;
  --surface2: #1c1f38;
  --border: rgba(255,255,255,0.08);
  --text: #e8eaf6;
  --text-muted: #7b7fa8;
  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
}

html { font-size: 16px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ─── Stars Background ─────────────────────────────────────────────────────── */
.stars-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(108,99,255,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 70%, rgba(0,180,216,0.10) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Header ───────────────────────────────────────────────────────────────── */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 1rem 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.logo-icon { font-size: 2.2rem; }

.logo-text {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fff;
}

.logo-accent { color: var(--accent); }

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ─── Main Layout ──────────────────────────────────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ─── Controls Panel ───────────────────────────────────────────────────────── */
.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.control-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ─── Game Selector ────────────────────────────────────────────────────────── */
.game-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.game-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.5rem;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  font-family: inherit;
}

.game-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-2px);
}

.game-btn.active {
  border-color: var(--accent);
  background: rgba(108,99,255,0.15);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

.game-flag { font-size: 1.8rem; }
.game-name { font-weight: 700; font-size: 0.95rem; }
.game-sub  { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }

.game-btn.active .game-sub { color: rgba(255,255,255,0.6); }

/* ─── Controls Row ─────────────────────────────────────────────────────────── */
.controls-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 120px; }
.flex-2 { flex: 2; min-width: 200px; }

/* ─── Count Control ────────────────────────────────────────────────────────── */
.count-control {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}

.count-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.4rem;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.count-btn:hover { background: rgba(108,99,255,0.15); }

.count-value {
  min-width: 2.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  padding: 0 0.5rem;
}

/* ─── Rule Selector ────────────────────────────────────────────────────────── */
.rule-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rule-btn {
  padding: 0.45rem 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
}

.rule-btn:hover { border-color: var(--accent); color: var(--text); }

.rule-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ─── Rule Description ─────────────────────────────────────────────────────── */
.rule-description {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 1rem;
  transition: var(--transition);
}

/* ─── Generate Button ──────────────────────────────────────────────────────── */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #6c63ff 0%, #a855f7 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 24px rgba(108,99,255,0.4);
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(108,99,255,0.55);
}

.generate-btn:active { transform: translateY(0); }

.generate-btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

.generate-icon {
  font-size: 1.2rem;
  animation: none;
}

.generate-btn.loading .generate-icon {
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Results Section ──────────────────────────────────────────────────────── */
.results-section {
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.results-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.copy-btn {
  padding: 0.4rem 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.copy-btn:hover { border-color: var(--accent); color: var(--text); }
.copy-btn.copied { border-color: #2ec4b6; color: #2ec4b6; }

/* ─── Draws Grid ───────────────────────────────────────────────────────────── */
.draws-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ─── Draw Card ────────────────────────────────────────────────────────────── */
.draw-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: fadeUp 0.3s ease both;
}

.draw-index {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 1.5rem;
  text-align: right;
  letter-spacing: 0.05em;
}

.draw-numbers {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}

.separator {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin: 0 0.2rem;
}

/* ─── Lottery Balls ────────────────────────────────────────────────────────── */
.ball {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  transition: transform 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.ball:hover { transform: scale(1.15); }

.ball::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 25%;
  width: 30%;
  height: 18%;
  background: rgba(255,255,255,0.35);
  border-radius: 50%;
  transform: rotate(-30deg);
  pointer-events: none;
}

/* Main balls */
.ball-main {
  background: linear-gradient(145deg, #f5c518 0%, #e09a00 100%);
  color: #1a1200;
  box-shadow: 0 2px 8px rgba(245,197,24,0.4);
}

/* Bonus balls per game */
.ball-bonus-euromillions {
  background: linear-gradient(145deg, #00b4d8 0%, #0077b6 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,180,216,0.4);
}

.ball-bonus-swisslotto {
  background: linear-gradient(145deg, #2ec4b6 0%, #1a8a82 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46,196,182,0.4);
}

.ball-bonus-eurodreams {
  background: linear-gradient(145deg, #f77f00 0%, #c06000 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(247,127,0,0.4);
}

/* ─── Legend Section ───────────────────────────────────────────────────────── */
.legend-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
}

.legend-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.legend-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }

.legend-item strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.1rem;
}

.legend-item p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ─── Footer ───────────────────────────────────────────────────────────────── */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ─── Game-specific accent overrides ──────────────────────────────────────── */
body.game-swisslotto .generate-btn {
  background: linear-gradient(135deg, #e63946 0%, #ff6b6b 100%);
  box-shadow: 0 4px 24px rgba(230,57,70,0.4);
}

body.game-swisslotto .generate-btn:hover {
  box-shadow: 0 8px 32px rgba(230,57,70,0.55);
}

body.game-swisslotto .game-btn.active {
  border-color: #e63946;
  background: rgba(230,57,70,0.15);
  box-shadow: 0 0 20px rgba(230,57,70,0.3);
}

body.game-swisslotto .rule-btn.active {
  background: #e63946;
  border-color: #e63946;
  box-shadow: 0 0 12px rgba(230,57,70,0.4);
}

body.game-swisslotto .rule-description { border-color: #e63946; }
body.game-swisslotto .ball-main {
  background: linear-gradient(145deg, #e63946 0%, #b02030 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(230,57,70,0.4);
}

body.game-eurodreams .generate-btn {
  background: linear-gradient(135deg, #6a4c93 0%, #a855f7 100%);
  box-shadow: 0 4px 24px rgba(106,76,147,0.4);
}

body.game-eurodreams .generate-btn:hover {
  box-shadow: 0 8px 32px rgba(106,76,147,0.55);
}

body.game-eurodreams .game-btn.active {
  border-color: #a855f7;
  background: rgba(168,85,247,0.15);
  box-shadow: 0 0 20px rgba(168,85,247,0.3);
}

body.game-eurodreams .rule-btn.active {
  background: #6a4c93;
  border-color: #6a4c93;
}

body.game-eurodreams .rule-description { border-color: #a855f7; }
body.game-eurodreams .ball-main {
  background: linear-gradient(145deg, #a855f7 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(168,85,247,0.4);
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .controls-panel { padding: 1.25rem; }
  .game-selector { grid-template-columns: 1fr; gap: 0.5rem; }
  .game-btn { flex-direction: row; justify-content: flex-start; padding: 0.75rem 1rem; }
  .controls-row { flex-direction: column; }
  .legend-grid { grid-template-columns: 1fr; }
  .draw-card { flex-wrap: wrap; }
  .ball { width: 2.1rem; height: 2.1rem; font-size: 0.75rem; }
}
