/* style.css — Mobile-first styles for Fruktfesten */

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

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  background: #1a1a2e;
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Menu Screen ─────────────────────────────────────────────────────────── */
#menu-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
}

#menu-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  text-align: center;
}

.menu-title {
  font-size: clamp(2.4rem, 10vw, 3.8rem);
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #f9ca24, #f0932b, #eb4d4b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(240,147,43,0.5));
}

.menu-subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

#highscore-display {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

#highscore-display span {
  color: #f9ca24;
  font-weight: 700;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  padding: 14px 28px;
  border: none;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  text-decoration: none;
  letter-spacing: 0.3px;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, #f9ca24, #f0932b);
  color: #1a1a2e;
  box-shadow: 0 4px 20px rgba(240,147,43,0.5);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 28px rgba(240,147,43,0.7);
}

.btn-secondary {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.2);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

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

.btn-danger {
  background: linear-gradient(135deg, #eb4d4b, #c0392b);
  color: #fff;
  box-shadow: 0 4px 16px rgba(235,77,75,0.5);
}

.btn.hidden {
  display: none;
}

/* ── Game Screen ─────────────────────────────────────────────────────────── */
#game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  position: relative;
}

#game-screen.hidden {
  display: none;
}

#menu-screen.hidden {
  display: none;
}

#game-top-bar {
  width: 100%;
  max-width: 440px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 10px 2px;
  flex-shrink: 0;
}

#pause-btn {
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
}

#pause-btn:active {
  background: rgba(255,255,255,0.25);
}

/* ── Canvas wrapper ──────────────────────────────────────────────────────── */
#canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 440px;
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

/* ── Overlays ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,25,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 12px;
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.overlay-title {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 900;
  margin-bottom: 4px;
}

.overlay-title.win {
  background: linear-gradient(135deg, #f9ca24, #6ab04c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 6px rgba(249,202,36,0.5));
}

.overlay-title.loss {
  background: linear-gradient(135deg, #eb4d4b, #f0932b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.overlay-title.pause {
  color: #fff;
}

.overlay-subtitle {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.75);
  max-width: 280px;
  line-height: 1.5;
  margin-bottom: 6px;
}

.score-block {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 14px 24px;
  margin: 6px 0;
  min-width: 220px;
}

.score-block .label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-block .value {
  font-size: 2rem;
  font-weight: 800;
  color: #f9ca24;
  margin-top: 2px;
}

.score-block .highscore-row {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.4);
  margin-top: 4px;
}

.score-block .highscore-row span {
  color: rgba(255,255,255,0.7);
  font-weight: 600;
}

.overlay-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  width: 100%;
  max-width: 240px;
}

/* ── Fruit legend (win screen decorative row) ────────────────────────────── */
.fruit-row {
  font-size: 1.6rem;
  letter-spacing: 2px;
  margin: 6px 0;
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-height: 600px) {
  .menu-title { font-size: 2rem; }
  #menu-content { gap: 10px; }
  .overlay-title { font-size: 1.8rem; }
  .score-block .value { font-size: 1.6rem; }
}

@media (min-width: 480px) {
  #canvas-wrapper {
    max-width: 420px;
  }
}
