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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a1a;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game-container canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 10;
  pointer-events: none;
}

.screen.active {
  display: flex;
  pointer-events: auto;
}

.screen > div {
  width: 100%;
  height: 100%;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-primary {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.btn-secondary {
  background: linear-gradient(135deg, #555, #777);
  color: #fff;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #666, #888);
}

.btn-large {
  padding: 18px 50px;
  font-size: 1.4rem;
  border-radius: 16px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
}

.btn-small:hover {
  background: rgba(255,255,255,0.25);
}

.btn-icon {
  padding: 8px 12px;
  font-size: 1.2rem;
  border-radius: 8px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  line-height: 1;
}

.btn-icon:hover {
  background: rgba(0,0,0,0.6);
}

#menu-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(39,174,96,0.3) 0%, rgba(0,0,0,0.7) 100%);
}

.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  padding: 20px;
}

.game-title {
  font-size: 4rem;
  line-height: 1.1;
  text-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.title-salad {
  display: block;
  color: #2ecc71;
  font-size: 3.5rem;
}

.title-ninja {
  display: block;
  color: #e74c3c;
  font-size: 4.5rem;
  letter-spacing: 4px;
}

.game-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.menu-footer {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

#map-select-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.8) 100%);
}

.map-select-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 20px;
  width: 100%;
  max-width: 700px;
}

.screen-title {
  color: #fff;
  font-size: 2rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.maps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

.map-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
  font-family: inherit;
  text-align: center;
}

.map-card.unlocked:hover {
  transform: translateY(-4px);
  background: rgba(255,255,255,0.2);
  border-color: #2ecc71;
}

.map-card.unlocked:focus-visible {
  outline: 3px solid #2ecc71;
  outline-offset: 2px;
}

.map-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.map-card-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.map-card-stars {
  font-size: 1.3rem;
  letter-spacing: 4px;
}

.star-filled {
  color: #f1c40f;
}

.star-empty {
  color: rgba(255,255,255,0.3);
}

.map-card-score {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
}

.map-card-lock {
  font-size: 1.5rem;
  position: absolute;
  top: 8px;
  right: 8px;
}

#game-hud {
  pointer-events: none;
}

#game-hud.active {
  pointer-events: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  width: 100%;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-left {
  align-items: flex-start;
}

.hud-right {
  align-items: flex-end;
  flex-direction: row;
  gap: 8px;
  pointer-events: auto;
}

.hud-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.hud-score .hud-value {
  color: #2ecc71;
}

.hud-timer .hud-value {
  color: #f1c40f;
}

.hud-lives {
  display: flex;
  gap: 4px;
}

.life-icon {
  font-size: 1.4rem;
  color: #e74c3c;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.hud-combo {
  margin-top: 4px;
}

.combo-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f39c12;
  text-shadow: 0 2px 8px rgba(243, 156, 18, 0.5);
  animation: comboPop 0.3s ease-out;
}

@keyframes comboPop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

#pause-screen {
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
  background: rgba(30,30,30,0.9);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  max-width: 420px;
  width: 90%;
  margin: auto;
}

#results-screen {
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.results-content {
  gap: 16px;
}

.stars-container {
  display: flex;
  gap: 12px;
  font-size: 3rem;
}

.result-star {
  color: rgba(255,255,255,0.2);
  transition: color 0.3s, transform 0.3s;
}

.result-star.star-earned {
  color: #f1c40f;
  text-shadow: 0 0 20px rgba(241, 196, 15, 0.6);
  animation: starAppear 0.5s ease-out both;
}

.result-star.star-empty {
  color: rgba(255,255,255,0.2);
}

@keyframes starAppear {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.4) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.results-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stat-label {
  color: rgba(255,255,255,0.7);
  font-size: 0.95rem;
}

.stat-value {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}

.results-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

#gameover-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(231,76,60,0.3) 0%, rgba(0,0,0,0.9) 100%);
}

.gameover-content {
  text-align: center;
}

.gameover-title {
  font-size: 3.5rem;
  color: #e74c3c;
  text-shadow: 0 4px 20px rgba(231,76,60,0.5);
  letter-spacing: 4px;
  animation: gameOverPulse 2s ease-in-out infinite;
}

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

.gameover-subtitle {
  color: #f1c40f;
  font-size: 1.2rem;
  font-style: italic;
  margin-top: 4px;
}

.gameover-stats {
  width: 100%;
  margin: 12px 0;
}

.gameover-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 600px) {
  .game-title {
    font-size: 2.8rem;
  }
  .title-salad {
    font-size: 2.4rem;
  }
  .title-ninja {
    font-size: 3.2rem;
  }
  .maps-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .btn-large {
    padding: 14px 36px;
    font-size: 1.2rem;
  }
  .hud-value {
    font-size: 1.4rem;
  }
  .overlay-content {
    padding: 24px;
    margin: 16px;
  }
  .gameover-title {
    font-size: 2.5rem;
  }
  .stars-container {
    font-size: 2.5rem;
  }
  .screen-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 400px) {
  .game-title {
    font-size: 2.2rem;
  }
  .title-salad {
    font-size: 1.8rem;
  }
  .title-ninja {
    font-size: 2.5rem;
  }
  .menu-footer {
    flex-direction: column;
    align-items: center;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-title {
    font-size: 2rem;
  }
  .title-salad {
    font-size: 1.6rem;
  }
  .title-ninja {
    font-size: 2.2rem;
  }
  .game-subtitle {
    font-size: 0.9rem;
  }
  .overlay-content {
    padding: 16px;
    gap: 10px;
  }
  .maps-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
