/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== DEBUG PANEL ===== */
.debug-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 165, 0, 0.08);
  border: 1px dashed rgba(255, 165, 0, 0.45);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.debug-label {
  color: #FFA500;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.debug-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: #FFD166;
  letter-spacing: 0.2em;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.5);
}



:root {
  --bg: #0b0d17;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.09);
  --border-glow: rgba(99,179,237,0.35);

  --accent: #6C63FF;
  --accent2: #00D4FF;
  --accent3: #FF6B9D;
  --gold: #FFD166;

  --plus-color: #4ADE80;
  --minus-color: #F87171;

  --text-primary: #F0F0FF;
  --text-secondary: #8892AA;
  --text-muted: #4A5568;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;

  --shadow-card: 0 8px 32px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 40px rgba(108,99,255,0.25);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 60px;
}

/* ===== BACKGROUND ORBS ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  animation: drift 14s ease-in-out infinite alternate;
}
.orb-1 { width: 500px; height: 500px; background: var(--accent); top: -150px; left: -150px; animation-duration: 16s; }
.orb-2 { width: 400px; height: 400px; background: var(--accent2); bottom: -100px; right: -100px; animation-duration: 20s; animation-delay: -5s; }
.orb-3 { width: 300px; height: 300px; background: var(--accent3); top: 50%; left: 50%; transform: translate(-50%,-50%); animation-duration: 12s; animation-delay: -8s; }

@keyframes drift {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.08); }
}

/* ===== CONTAINER ===== */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 12px rgba(108,99,255,0.6));
  animation: pulse-icon 3s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(108,99,255,0.6)); }
  50%       { filter: drop-shadow(0 0 24px rgba(0,212,255,0.8)); }
}

.title {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #6C63FF, #00D4FF, #FF6B9D);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.score-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(0,212,255,0.1));
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  backdrop-filter: blur(10px);
  min-width: 90px;
}

.score-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent2);
  text-transform: uppercase;
}

.score-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  transition: var(--transition);
}

/* ===== RULES CARD ===== */
.rules-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.rules-toggle {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  transition: var(--transition);
}
.rules-toggle:hover { background: var(--surface-hover); }

.chevron { transition: transform 0.3s ease; font-size: 0.75rem; color: var(--text-secondary); }
.chevron.open { transform: rotate(180deg); }

.rules-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
.rules-body.open { max-height: 400px; }

.rule-items {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.rule-item strong { color: var(--text-primary); }
.rule-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ===== GAME AREA ===== */
.game-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 600px) {
  .game-area { grid-template-columns: 1fr; }
}

/* ===== INPUT SECTION ===== */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.attempt-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.attempt-indicator span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.attempt-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}
.dot.active { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.dot.used   { background: var(--accent); }

/* ===== DIGIT INPUTS ===== */
.digit-inputs {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.digit-box {
  width: 62px;
  height: 72px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: var(--transition);
  caret-color: var(--accent2);
}

.digit-box::placeholder { color: var(--text-muted); font-size: 1.2rem; }

.digit-box:focus {
  border-color: var(--accent);
  background: rgba(108,99,255,0.1);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.2), 0 0 20px rgba(108,99,255,0.15);
  transform: translateY(-2px);
}

.digit-box.filled {
  border-color: rgba(0,212,255,0.4);
  color: var(--accent2);
}

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

/* ===== BUTTONS ===== */
.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-guess {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-guess::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn-guess:hover::before { opacity: 1; }
.btn-guess:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(108,99,255,0.5); }
.btn-guess:active { transform: translateY(0); }
.btn-guess:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-arrow { font-size: 1.2rem; transition: transform 0.2s; }
.btn-guess:hover .btn-arrow { transform: translateX(4px); }

.btn-new {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-new:hover { border-color: var(--accent); color: var(--text-primary); background: rgba(108,99,255,0.1); }

/* ===== ERROR ===== */
.error-msg {
  min-height: 20px;
  font-size: 0.82rem;
  color: var(--minus-color);
  text-align: center;
  font-weight: 500;
  transition: opacity 0.3s;
}

/* ===== HISTORY ===== */
.history-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.history-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(108,99,255,0.3) transparent;
}

.empty-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 0;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; }
.empty-history p { font-size: 0.85rem; text-align: center; line-height: 1.6; }

/* ===== HISTORY ITEM ===== */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  animation: slideIn 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards;
  opacity: 0;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.history-num {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 24px;
}

.history-guess {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.15em;
}

.history-result {
  display: flex;
  gap: 6px;
}

.badge {
  padding: 3px 10px;
  border-radius: 99px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-plus {
  background: rgba(74,222,128,0.12);
  color: var(--plus-color);
  border: 1px solid rgba(74,222,128,0.25);
}

.badge-minus {
  background: rgba(248,113,113,0.12);
  color: var(--minus-color);
  border: 1px solid rgba(248,113,113,0.25);
}

.badge-zero {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
}

/* ===== WIN MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: linear-gradient(145deg, #12142a, #1a1d35);
  border: 1px solid rgba(108,99,255,0.35);
  border-radius: var(--radius-xl);
  padding: 48px 40px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 60px rgba(108,99,255,0.2);
  transform: scale(0.85) translateY(30px);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow: hidden;
}

.modal-overlay.show .modal-card {
  transform: scale(1) translateY(0);
}

.modal-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

.modal-icon {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: bounce 0.6s ease 0.3s both;
}

@keyframes bounce {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.modal-title {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), #FF6B9D);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.stat-box {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 100px;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
}

.btn-play-again {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.03em;
}
.btn-play-again:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(108,99,255,0.5); }

/* ===== FLASH EFFECTS ===== */
@keyframes flashHit {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,0); border-color: var(--border); }
  30%  { box-shadow: 0 0 0 12px rgba(74,222,128,0.3); border-color: rgba(74,222,128,0.7); background: rgba(74,222,128,0.08); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); border-color: var(--border); background: var(--surface); }
}
@keyframes flashMiss {
  0%   { transform: translateX(0); background: var(--surface); border-color: var(--border); }
  15%  { transform: translateX(-8px); background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.6); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
  100% { transform: translateX(0); background: var(--surface); border-color: var(--border); }
}
@keyframes flashGameOver {
  0%   { background: var(--surface); }
  20%  { background: rgba(248,113,113,0.15); }
  40%  { background: rgba(0,0,0,0.3); }
  60%  { background: rgba(248,113,113,0.10); }
  80%  { background: rgba(0,0,0,0.2); }
  100% { background: var(--surface); }
}

.flash-hit {
  animation: flashHit 0.7s ease forwards;
}
.flash-miss {
  animation: flashMiss 0.7s ease forwards;
}
.flash-gameover {
  animation: flashGameOver 0.7s ease forwards;
}

/* ===== SCORE POP ===== */
@keyframes scorePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}
.score-pop { animation: scorePop 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards; }

/* ===== HISTORY MISS ===== */
.history-item.history-miss {
  border-color: rgba(248,113,113,0.25);
  background: rgba(248,113,113,0.05);
}
.history-item.history-miss .history-guess {
  color: rgba(240,240,255,0.5);
}

/* ===== GAME OVER MODAL ===== */
.modal-overlay.gameover .modal-card {
  background: linear-gradient(145deg, #1a0d0d, #2a1212);
  border-color: rgba(248,113,113,0.35);
  box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 60px rgba(248,113,113,0.2);
}
.modal-overlay.gameover .modal-title {
  background: linear-gradient(135deg, #F87171, #FF3CAC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== REVEAL NUMBER ===== */
.stat-box.stat-reveal {
  border-color: rgba(248,113,113,0.4);
  background: rgba(248,113,113,0.08);
}
.reveal-number {
  color: #F87171;
  text-shadow: 0 0 16px rgba(248,113,113,0.6);
  letter-spacing: 0.15em;
}
