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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 200, 50, 0.4); }
  50% { box-shadow: 0 0 25px rgba(255, 200, 50, 0.8), 0 0 50px rgba(255, 200, 50, 0.3); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes bossEntrance {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes attackSwing {
  0% { transform: translateX(0) scale(1); }
  30% { transform: translateX(30px) scale(1.15); }
  60% { transform: translateX(-10px) scale(1.05); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes hitShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-12px) rotate(-3deg); }
  30% { transform: translateX(10px) rotate(2deg); }
  45% { transform: translateX(-6px) rotate(-1deg); }
  60% { transform: translateX(4px) rotate(1deg); }
}

@keyframes flashRed {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 0, 0, 0); }
  50% { box-shadow: 0 0 40px rgba(255, 0, 0, 0.6), 0 0 80px rgba(255, 0, 0, 0.3); }
}

@keyframes enemyDefeat {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  30% { transform: scale(1.3); opacity: 1; filter: brightness(2); }
  100% { transform: scale(0) rotate(360deg); opacity: 0; filter: brightness(3); }
}

@keyframes sparkle {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(0); opacity: 0; }
}

@keyframes comboGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 200, 50, 0.3); }
  50% { box-shadow: 0 0 12px rgba(255, 200, 50, 0.7); }
}

.sparkle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.sparkle-particle {
  position: absolute;
  font-size: 1rem;
  animation: sparkle 0.8s ease-out forwards;
  pointer-events: none;
}

body {
  background: #0a0a1a;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#gameContainer {
  width: 100%;
  max-width: 520px;
  height: 100vh;
  max-height: 900px;
  background: linear-gradient(145deg, #0d0d24, #1a1a3e);
  border: 2px solid #334;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 60px rgba(100, 50, 200, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.btn-fullscreen {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #888;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.btn-fullscreen:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ccc;
}

.btn-music {
  position: absolute;
  top: 8px;
  right: 52px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #888;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.btn-music:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ccc;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

/* MENU SCREEN */
#menuScreen {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.game-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #f90;
  text-shadow: 0 0 20px rgba(255, 150, 0, 0.6), 0 0 40px rgba(255, 100, 0, 0.3);
  line-height: 1.2;
}

.game-subtitle {
  font-size: 0.95rem;
  color: #888;
  margin-bottom: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.player-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 12px 0;
}

.summary-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 6px;
}

.summary-card .label {
  font-size: 0.65rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.summary-card .value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #f90;
  margin-top: 2px;
}

.profile-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
}

.name-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 8px 12px;
  color: #eee;
  font-size: 0.95rem;
  outline: none;
  text-align: center;
  width: 180px;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: #f90;
  box-shadow: 0 0 10px rgba(255,150,0,0.15);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
  line-height: 1;
  color: #ccc;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.14);
}

#pauseOverlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 30;
  justify-content: center;
  align-items: center;
}

#pauseOverlay.active {
  display: flex;
}

.pause-modal {
  text-align: center;
  padding: 40px;
}

.pause-modal h2 {
  font-size: 2rem;
  color: #f90;
  margin-bottom: 24px;
}

.pause-modal .pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.save-feedback {
  font-size: 0.85rem;
  color: #4a4;
  margin-top: 12px;
  opacity: 0;
  transition: opacity 0.3s;
  min-height: 1.2em;
}

.btn {
  padding: 14px 32px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  max-width: 300px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #f90, #f60);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 100, 0, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: linear-gradient(135deg, #c33, #a00);
  color: #fff;
  box-shadow: 0 4px 20px rgba(200, 0, 0, 0.3);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  width: 100%;
  max-width: 300px;
}

.lang-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #ddd;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  width: 100%;
  max-width: 200px;
  text-align: center;
}

.lang-select option {
  background: #1a1a3e;
  color: #ddd;
}

/* MODE SELECT SCREEN */
.mode-title {
  font-size: 1.4rem;
  color: #f90;
  text-align: center;
  padding: 20px 0 16px;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 200, 50, 0.3);
  transform: translateY(-2px);
}

.mode-card:active {
  transform: translateY(1px);
}

.mode-icon {
  font-size: 1.6rem;
}

.mode-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #eee;
}

.mode-desc {
  font-size: 0.8rem;
  color: #888;
  line-height: 1.4;
}

/* SPEED RUN / PRACTICE OVERLAY */
.mode-banner {
  text-align: center;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mode-banner.classic { color: #f90; }
.mode-banner.speed { color: #0cf; }
.mode-banner.practice { color: #4a4; }

#speedTimer {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0cf;
  text-align: center;
}

.hide-mode {
  display: none !important;
}

#practiceNextBtn {
  margin-top: 8px;
}

/* BATTLE SCREEN */
#battleScreen {
  gap: 0;
  padding: 0;
  position: relative;
}

.battle-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}

.battle-header .floor {
  font-size: 0.8rem;
  color: #888;
  font-weight: 600;
}

.battle-header .streak {
  font-size: 0.8rem;
  color: #f90;
  font-weight: 700;
  flex: 1;
  text-align: center;
}

/* Combo meter */
.combo-meter {
  display: none;
  height: 10px;
  flex: 0 0 60px;
  max-width: 80px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255,200,50,0.15);
  margin-left: auto;
}

.combo-fill {
  height: 100%;
  background: linear-gradient(90deg, #f90, #ff0);
  border-radius: 5px;
  transition: width 0.3s ease;
  font-size: 0.55rem;
  color: #000;
  font-weight: 800;
  text-align: center;
  line-height: 10px;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.points-header {
  font-size: 0.8rem;
  color: #ff0;
  font-weight: 700;
  flex-shrink: 0;
}

.points-earned {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 0);
  font-size: 1.8rem;
  font-weight: 900;
  color: #ff0;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  text-shadow: 0 0 20px rgba(255, 255, 0, 0.5);
  transition: none;
}

.points-earned.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(0.5);
}

.points-earned.animate {
  opacity: 0;
  transform: translate(-50%, -80px) scale(1.3);
  transition: all 0.8s ease-out;
}

.enemy-area {
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(100, 50, 200, 0.08), transparent);
  flex-shrink: 0;
  position: relative;
}

.enemy-sprite {
  font-size: 4rem;
  display: block;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(255, 200, 0, 0.3));
  transition: all 0.3s;
  line-height: 1.3;
}

.enemy-sprite.boss-sprite {
  font-size: 5rem;
  animation: bossEntrance 0.6s ease-out, float 3s ease-in-out infinite 0.6s;
  filter: drop-shadow(0 0 40px rgba(255, 0, 0, 0.5));
}

.enemy-name {
  font-size: 1rem;
  font-weight: 700;
  color: #ddd;
  margin-top: 4px;
}

.hp-bar-container {
  width: 100%;
  height: 18px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  overflow: hidden;
  margin: 6px 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hp-bar {
  height: 100%;
  transition: width 0.4s ease;
  border-radius: 10px;
  position: relative;
}

.hp-bar.enemy-hp {
  background: linear-gradient(90deg, #c33, #f44);
  box-shadow: 0 0 10px rgba(255, 50, 50, 0.4);
}

.hp-bar.player-hp {
  background: linear-gradient(90deg, #4a4, #6e6);
  box-shadow: 0 0 10px rgba(50, 255, 50, 0.3);
}

.hp-text {
  font-size: 0.75rem;
  color: #aaa;
  text-align: center;
}

.battle-arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}

.sentence-box {
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 200, 50, 0.2);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.sentence-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.5;
  font-style: italic;
}

.error-type {
  font-size: 0.7rem;
  color: #f90;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.timer-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.timer {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.timer-danger {
  color: #f44;
  animation: pulse 0.5s ease-in-out infinite;
}

.choices-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.choice-btn {
  padding: 12px 10px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #ddd;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
}

.choice-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 200, 50, 0.3);
  transform: translateY(-1px);
}

.choice-btn:active {
  transform: translateY(1px);
}

.choice-btn.correct {
  background: rgba(50, 200, 80, 0.2);
  border-color: #4a4;
  color: #6e6;
}

.choice-btn.wrong {
  background: rgba(200, 50, 50, 0.2);
  border-color: #c44;
  color: #f66;
}

.choice-btn:disabled {
  cursor: default;
  opacity: 0.7;
  transform: none !important;
}

.typing-input {
  grid-column: 1 / -1;
  padding: 14px;
  border: 2px solid rgba(255, 200, 50, 0.3);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.typing-input:focus {
  border-color: #f90;
  box-shadow: 0 0 15px rgba(255, 150, 0, 0.2);
}

.typing-input.correct {
  border-color: #4a4;
  background: rgba(50, 200, 80, 0.15);
}

.typing-input.wrong {
  border-color: #c44;
  background: rgba(200, 50, 50, 0.15);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.player-info .hp-mini {
  flex: 1;
}

.player-sprite {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.player-stats {
  font-size: 0.7rem;
  color: #777;
  text-align: right;
  flex-shrink: 0;
}

.hint-text {
  font-size: 0.8rem;
  color: #ff0;
  text-align: center;
  transition: opacity 0.5s;
  opacity: 0;
  min-height: 1.2em;
  padding: 2px 0;
}

.battle-log {
  font-size: 0.75rem;
  color: #999;
  line-height: 1.6;
  max-height: 60px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  flex-shrink: 0;
}

.lesson-text {
  font-size: 0.75rem;
  color: #0cf;
  text-align: center;
  padding: 6px 10px;
  background: rgba(0, 200, 255, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(0, 200, 255, 0.15);
  line-height: 1.5;
  flex-shrink: 0;
}

.battle-log::-webkit-scrollbar {
  width: 3px;
}

.battle-log::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 3px;
}

.damage-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 0) scale(1);
  font-size: 2.5rem;
  font-weight: 900;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: all 0.6s ease-out;
  text-shadow: 0 0 20px currentColor;
}

.damage-number.attack {
  color: #f90;
}

.damage-number.hit {
  color: #f44;
}

.damage-number.block {
  color: #0cf;
  font-size: 1.8rem;
}

#resultPanel {
  display: none;
  text-align: center;
  padding: 10px;
  flex-shrink: 0;
}

/* GAME OVER SCREEN */
#gameOverScreen {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  position: absolute;
  inset: 0;
  z-index: 20;
}

#gameOverScreen h2 {
  font-size: 2rem;
  color: #f44;
  text-shadow: 0 0 30px rgba(255, 0, 0, 0.4);
}

.game-over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 300px;
  margin: 10px 0;
}

.go-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 12px;
}

.go-card .label {
  font-size: 0.65rem;
  color: #888;
  text-transform: uppercase;
}

.go-card .value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f90;
}

/* SHOP SCREEN */
#shopScreen {
  gap: 16px;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-header h2 {
  font-size: 1.4rem;
  color: #f90;
}

#shopItems {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
}

.shop-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-item-name {
  font-weight: 600;
  color: #ddd;
  font-size: 0.95rem;
}

.shop-item-level {
  font-size: 0.75rem;
  color: #888;
}

.shop-item button {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #f90, #f60);
  color: #fff;
  transition: all 0.2s;
}

.shop-item button:hover {
  transform: scale(1.05);
}

.shop-item button:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
  transform: none !important;
}

.shop-currency {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f90;
  padding: 10px;
}

/* LEADERBOARD SCREEN */
#leaderboardScreen {
  gap: 12px;
}

#leaderboardScreen h2 {
  font-size: 1.4rem;
  color: #f90;
}

#leaderboardList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 0.9rem;
}

.lb-empty {
  text-align: center;
  color: #666;
  padding: 40px;
}

/* HELP SCREEN */
#helpScreen {
  gap: 16px;
}

#helpScreen h2 {
  font-size: 1.4rem;
  color: #f90;
}

.help-content {
  flex: 1;
  overflow-y: auto;
  line-height: 1.8;
  color: #bbb;
  font-size: 0.9rem;
}

.help-content h3 {
  color: #ddd;
  margin: 16px 0 8px;
  font-size: 1rem;
}

.help-content ul {
  padding-left: 20px;
}

.help-content li {
  margin-bottom: 4px;
}

/* RESPONSIVE */
@media (max-width: 540px) {
  #gameContainer {
    border-radius: 0;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border: none;
  }
  .game-title { font-size: 1.7rem; }
  .enemy-sprite { font-size: 3rem; }
  .sentence-text { font-size: 0.9rem; }
}

@media (min-height: 800px) {
  .enemy-area { padding: 24px; }
  .enemy-sprite { font-size: 5rem; }
  .battle-arena { gap: 14px; padding: 16px 20px; }
}
