/* Salad Ninja - Styles */
:root {
  --green-dark: #0d3b1e;
  --green-mid: #1a5c2e;
  --green-bright: #2d8f4e;
  --green-light: #5cdb7a;
  --lime: #a8e6a0;
  --gold: #ffd700;
  --gold-dark: #e6a800;
  --tomato: #e74c3c;
  --carrot: #e67e22;
  --cream: #fff8e7;
  --ink: #1a1a1a;
  --panel: rgba(13, 59, 30, 0.88);
  --panel-border: rgba(168, 230, 160, 0.35);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --focus: 0 0 0 3px var(--gold), 0 0 0 6px rgba(255, 215, 0, 0.35);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--green-dark);
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

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

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  z-index: 0;
  touch-action: none;
  cursor: crosshair;
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(160deg, rgba(13, 59, 30, 0.72) 0%, rgba(26, 92, 46, 0.55) 50%, rgba(10, 40, 20, 0.8) 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
}

.screen[hidden] {
  display: none !important;
}

.screen-overlay {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.screen-content {
  width: min(100%, 520px);
  text-align: center;
  padding: 1.75rem 1.5rem;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fadeInUp 0.45s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Logo */
.logo {
  font-size: clamp(2.4rem, 10vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--cream);
  text-shadow:
    0 2px 0 var(--green-mid),
    0 4px 12px rgba(0, 0, 0, 0.4),
    0 0 40px rgba(93, 219, 122, 0.35);
}

.logo span {
  color: var(--green-light);
  display: inline-block;
}

.tagline {
  margin-top: 0.5rem;
  margin-bottom: 1.75rem;
  font-size: 1rem;
  color: var(--lime);
  opacity: 0.9;
}

.screen-title {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  margin-bottom: 1.25rem;
  color: var(--cream);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, opacity 0.15s;
  touch-action: manipulation;
  min-height: 44px;
  min-width: 44px;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, var(--green-light) 0%, var(--green-bright) 100%);
  color: var(--ink);
  box-shadow: 0 4px 0 #1e6b38, 0 6px 16px rgba(0, 0, 0, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #b8f0b0 0%, var(--green-light) 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--cream);
  border: 2px solid var(--panel-border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: var(--ink);
  box-shadow: 0 4px 0 #b8860b, 0 6px 16px rgba(0, 0, 0, 0.25);
}

.btn-danger {
  background: linear-gradient(180deg, #ff6b5b 0%, var(--tomato) 100%);
  color: white;
  box-shadow: 0 4px 0 #a93226;
}

.btn-lg {
  font-size: 1.35rem;
  padding: 1rem 2.75rem;
  min-width: 200px;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  min-height: 36px;
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid var(--panel-border);
  font-size: 1.25rem;
  color: var(--cream);
}

.start-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.start-content .btn-lg {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 0 #1e6b38, 0 6px 16px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(93, 219, 122, 0.4); }
  50% { box-shadow: 0 4px 0 #1e6b38, 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 12px rgba(93, 219, 122, 0); }
}

/* Map grid */
.maps-content {
  width: min(100%, 640px);
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.map-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 1rem;
  border-radius: 14px;
  border: 2px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--cream);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-height: 140px;
  touch-action: manipulation;
}

.map-card:hover:not(:disabled):not(.locked) {
  transform: translateY(-3px);
  border-color: var(--green-light);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.map-card:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.map-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.map-card .map-name {
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 0.35rem;
  line-height: 1.2;
}

.map-card .map-best {
  font-size: 0.8rem;
  color: var(--lime);
  margin-bottom: 0.5rem;
}

.map-card .map-stars {
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-top: auto;
}

.map-card .lock-icon {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 1.1rem;
}

.map-card[data-map="kitchen"] { border-color: rgba(255, 200, 100, 0.4); }
.map-card[data-map="garden"] { border-color: rgba(100, 200, 100, 0.4); }
.map-card[data-map="market"] { border-color: rgba(120, 100, 255, 0.4); }
.map-card[data-map="temple"] { border-color: rgba(255, 180, 50, 0.5); }

/* HUD */
.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hud[hidden] {
  display: none !important;
}

.hud-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  align-items: flex-start;
  pointer-events: none;
}

.hud-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.35rem 0.7rem;
  min-width: 64px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.hud-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lime);
  opacity: 0.85;
}

.hud-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}

.hud-pause {
  pointer-events: auto;
  margin-left: auto;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
}

.hud-level-name {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  opacity: 0.7;
  background: var(--panel);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
}

.combo-flash {
  color: var(--gold);
  animation: comboPop 0.3s ease;
}

@keyframes comboPop {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Results */
.stars-display {
  font-size: 2.5rem;
  letter-spacing: 0.15em;
  min-height: 3rem;
  margin-bottom: 1rem;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.stars-display .star {
  display: inline-block;
  opacity: 0;
  transform: scale(0) rotate(-30deg);
}

.stars-display .star.show {
  animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes starPop {
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.results-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--lime);
  opacity: 0.85;
}

.stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: stretch;
}

.results-actions .btn {
  width: 100%;
}

.pause-content {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: min(100%, 320px);
}

.pause-content .btn {
  width: 100%;
}

/* Game Over */
.gameover-title {
  margin-bottom: 0.5rem;
  color: var(--gold);
}

.gameover-msg {
  font-size: 1.15rem;
  color: var(--lime);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

/* Slice trail */
.slice-trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

.slice-trail line {
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(255, 255, 200, 0.9));
}

/* Toast */
.toast {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(0, 0, 0, 0.75);
  color: var(--gold);
  font-weight: 800;
  font-size: 1.4rem;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: 2px solid var(--gold);
  pointer-events: none;
  animation: toastIn 0.35s ease;
}

.toast[hidden] {
  display: none !important;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.9); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* Responsive */
@media (max-width: 480px) {
  .screen-content {
    padding: 1.25rem 1rem;
  }

  .map-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hud-value {
    font-size: 1rem;
  }

  .hud-panel {
    padding: 0.25rem 0.5rem;
  }

  .results-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .screen-content {
    padding: 0.75rem 1rem;
    max-height: 95vh;
    overflow-y: auto;
  }

  .logo {
    font-size: 2rem;
  }

  .tagline {
    margin-bottom: 0.75rem;
  }

  .map-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .map-card {
    min-height: 100px;
    padding: 0.6rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
