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

body {
  font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: #0f0f1a;
  color: #e0e0f0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  max-width: 640px;
  width: 100%;
  padding: 2rem;
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #888;
  margin-bottom: 2rem;
}

/* Start box */
.start-box {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.start-box input {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 2px solid #333;
  background: #1a1a2e;
  color: #e0e0f0;
  font-size: 1rem;
  width: 200px;
  outline: none;
  transition: border-color 0.2s;
}

.start-box input:focus {
  border-color: #a78bfa;
}

button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  color: #0f0f1a;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

button:hover {
  opacity: 0.85;
}

/* Rules */
.rules {
  background: #1a1a2e;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  text-align: left;
  margin-bottom: 2rem;
}

.rules h3 {
  margin-bottom: 0.5rem;
  color: #a78bfa;
}

.rules ul {
  padding-left: 1.25rem;
  line-height: 1.8;
  color: #aaa;
  font-size: 0.9rem;
}

/* Ranking */
.ranking h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  color: #38bdf8;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background: #1a1a2e;
  padding: 0.5rem;
  color: #888;
  font-weight: 600;
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid #222;
}

tr.gold td { color: #fbbf24; font-weight: 700; }
tr.silver td { color: #94a3b8; font-weight: 600; }
tr.bronze td { color: #b87333; font-weight: 600; }

/* Game HUD */
.game-container {
  max-width: 480px;
}

.hud {
  display: flex;
  justify-content: space-around;
  background: #1a1a2e;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hud-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #e0e0f0;
}

/* Question */
.question-box {
  background: #1a1a2e;
  border-radius: 1rem;
  padding: 1.75rem 1.5rem 1.5rem;
}

.question {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.feedback {
  height: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.feedback.correct { color: #4ade80; }
.feedback.wrong   { color: #f87171; }

/* Numpad */
.numpad-display {
  font-size: 2.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: #0f0f1a;
  border: 2px solid #333;
  border-radius: 0.75rem;
  padding: 0.4rem 1rem;
  margin: 0 auto 0.75rem;
  width: 160px;
  color: #e0e0f0;
  transition: border-color 0.15s;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 300px;
  margin: 0 auto;
}

.num-btn {
  background: #12122a;
  border: 2px solid #2a2a4a;
  border-radius: 0.75rem;
  color: #e0e0f0;
  font-size: 1.6rem;
  font-weight: 700;
  padding: 0.85rem 0;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.08s;
  -webkit-text-fill-color: #e0e0f0;
  user-select: none;
}

.num-btn:hover {
  background: #1e1e40;
  border-color: #a78bfa;
}

.num-btn:active {
  transform: scale(0.91);
  background: #2a1a52;
}

.del-btn {
  color: #f87171;
  -webkit-text-fill-color: #f87171;
  font-size: 1.4rem;
}

.ok-btn {
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  border-color: transparent;
  color: #0f0f1a;
  -webkit-text-fill-color: #0f0f1a;
  font-size: 1.2rem;
}

/* Result */
.result {
  background: #1a1a2e;
  border-radius: 1rem;
  padding: 2.5rem 2rem;
}

.result h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 2rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-value.highlight {
  font-size: 2rem;
  background: linear-gradient(135deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result button {
  margin: 0 0.5rem;
}

/* Mode selection cards */
.mode-cards {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.mode-card {
  flex: 1;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 2px solid #333;
  background: #1a1a2e;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.mode-card:hover {
  border-color: #a78bfa;
}

.mode-card.selected {
  border-color: #a78bfa;
  background: #241a42;
}

.mode-card-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.mode-card-desc {
  font-size: 0.8rem;
  color: #888;
}

#startBtn {
  margin-bottom: 1.5rem;
}

/* Mode label in game */
.mode-label {
  font-size: 0.8rem;
  color: #a78bfa;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

/* 3-choice buttons (beginner mode) */
.choice-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.choice-btn {
  width: 110px;
  height: 80px;
  font-size: 2rem;
  font-weight: 800;
  border-radius: 1rem;
  background: #0f0f1a;
  border: 2px solid #333;
  color: #e0e0f0;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.choice-btn:hover {
  border-color: #a78bfa;
  transform: scale(1.06);
}

.choice-btn:active {
  transform: scale(0.94);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-8px); }
  80%       { transform: translateX(8px); }
}

.shake {
  animation: shake 0.4s;
}

.ranking {
  margin-top: 2rem;
}

.hidden {
  display: none !important;
}
