* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: #0f0f23;
  color: #fff;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrapper {
  text-align: center;
  position: relative;
  padding: 1rem;
  width: 100%;
  max-width: 500px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.back-btn {
  color: #888;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.back-btn:hover { color: #f0c040; }
.back-btn { background: #2a2a5e; padding: 0.3rem 0.7rem; border-radius: 6px; }
.pause-btn { background: #2a2a5e; color: #fff; border: none; padding: 0.3rem 0.7rem; border-radius: 6px; font-size: 1rem; cursor: pointer; margin-left: 0.4rem; transition: background 0.2s; }
.pause-btn:hover { background: #3a3a7e; }
.top-bar h1 { font-size: 1.4rem; }

.score-board {
  display: flex;
  gap: 0.8rem;
  font-size: 0.85rem;
  color: #aaa;
  align-items: center;
  flex-wrap: wrap;
}

.score-board strong { color: #4cff72; }

/* Game area */
#game-area {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 auto 1rem;
  background: #1a1a3e;
  border: 2px solid #2a2a5e;
  border-radius: 12px;
  padding: 1.2rem 2rem;
  min-height: 420px;
  position: relative;
  overflow: hidden;
}


/* Countdown overlay inside game area */
#countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-size: 2.5rem;
  font-weight: bold;
  color: #ffe040;
  border-radius: 12px;
}

#countdown-overlay.hidden { display: none; }

#number-column, #answer-column {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

#answer-column {
  padding-top: 23px;
}

.num-cell {
  width: 48px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  border-radius: 8px;
  background: #2a2a5e;
  transition: background 0.2s, transform 0.2s;
}

.ans-cell {
  width: 48px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  border-radius: 8px;
  background: transparent;
  color: #555;
  transition: all 0.3s;
}

.ans-cell.active {
  background: #2a2a5e;
  border: 2px solid #f0c040;
  color: #f0c040;
  transform: scale(1.1);
}

.ans-cell.correct {
  background: #1a3e1a;
  color: #4cff72;
  border: 2px solid #4cff72;
}

.ans-cell.wrong {
  background: #3e1a1a;
  color: #ff4c6a;
  border: 2px solid #ff4c6a;
  animation: cellShake 0.3s ease;
}

@keyframes cellShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Highlight pair being summed */
.num-cell.highlight {
  background: #3a3a7e;
  color: #f0c040;
  transform: scale(1.05);
}

/* Numpad */
#input-area {
  margin-top: 0.5rem;
}

#numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  max-width: 300px;
  margin: 0 auto;
}

.numpad-btn {
  width: 100%;
  height: 48px;
  font-size: 1.3rem;
  font-weight: 700;
  background: #1a1a3e;
  color: #fff;
  border: 2px solid #2a2a5e;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.numpad-btn:active, .numpad-btn:hover {
  background: #2a2a5e;
  border-color: #f0c040;
}

/* Overlay */
#overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 35, 0.92);
  border-radius: 12px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  z-index: 20;
}

#overlay.show { display: flex; }

/* Report Card */
.report-card {
  background: #1a1a3e;
  border: 2px solid #2a2a5e;
  border-radius: 16px;
  padding: 1.5rem;
  width: 90%;
  max-width: 360px;
  animation: reportSlideIn 0.4s ease;
}

@keyframes reportSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.report-header {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.report-item {
  background: #0f0f23;
  border-radius: 10px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.report-label {
  font-size: 0.7rem;
  color: #888;
}

.report-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0c040;
}

.report-bar-wrap {
  margin-bottom: 0.8rem;
}

.report-bar-label {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 0.3rem;
  text-align: left;
}

.report-bar {
  height: 8px;
  background: #0f0f23;
  border-radius: 4px;
  overflow: hidden;
}

.report-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #ff4c6a, #f0c040, #4cff72);
  transition: width 1s ease;
  width: 0%;
}

.report-best {
  font-size: 0.8rem;
  color: #f0c040;
  margin-bottom: 0.8rem;
}

.report-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

#overlay-text { font-size: 1.4rem; color: #ccc; }

#gameover-info { text-align: center; }

#restart-btn, #menu-btn {
  margin-top: 0.5rem;
  padding: 0.6rem 1.8rem;
  font-size: 1rem;
  background: #f0c040;
  color: #0f0f23;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  min-width: 180px;
  text-align: center;
}

#restart-btn:hover, #menu-btn:hover { background: #ffd866; }

#menu-btn {
  background: #2a2a5e;
  color: #fff;
}

#menu-btn:hover { background: #3a3a7e; }

.hidden { display: none !important; }

.how-to {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: #888;
  line-height: 1.6;
}

.how-to p:first-child { color: #f0c040; margin-bottom: 0.3rem; }

/* Combo popup */
.combo-popup {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd700;
  pointer-events: none;
  animation: comboFloat 0.8s ease forwards;
  z-index: 10;
}

@keyframes comboFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(1.2); }
}

@media (max-width: 400px) {
  .num-cell, .ans-cell { width: 40px; height: 36px; font-size: 1.2rem; }
  #game-area { padding: 0.8rem 1rem; }
  .numpad-btn { height: 42px; font-size: 1.1rem; }
}

/* Level Modal */
#level-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 15, 35, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.3s ease;
}

#level-modal.hidden { display: none; }

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.level-modal-content {
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.level-modal-content h2 {
  font-size: 1.6rem;
  margin-bottom: 0.3rem;
}

.level-modal-content > p {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.level-options {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.level-btn {
  background: #1a1a3e;
  border: 2px solid #2a2a5e;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  color: #fff;
  font-family: inherit;
}

.level-btn:hover {
  transform: translateY(-3px);
  border-color: #f0c040;
  box-shadow: 0 0 15px rgba(240, 192, 64, 0.2);
}

.level-icon { font-size: 1.8rem; }
.level-name { font-size: 1rem; font-weight: 700; }
.level-desc { font-size: 0.75rem; color: #888; margin-left: auto; }

@media (max-width: 599px) { .hamburger-btn { display: none !important; } }
