/* ═══════════════════════════════════════════════════════════════════════════
   Find the Invisible Duck — styles.css
   Warm pastel palette, fully responsive, smooth transitions.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  /* Palette */
  --clr-bg-start:       #fff8ed;
  --clr-bg-end:         #fce4c4;
  --clr-surface:        #ffffff;
  --clr-surface-tint:   #fffbf2;
  --clr-border:         #e8d5b0;
  --clr-border-soft:    #f0e4cc;

  --clr-duck-yellow:    #F5C842;
  --clr-duck-dark:      #E6A800;
  --clr-duck-orange:    #FF8C42;
  --clr-blue:           #5BA8E5;
  --clr-blue-dark:      #3a8bc7;
  --clr-mint:           #5DCFA0;
  --clr-mint-dark:      #3dbc88;
  --clr-red:            #E86060;
  --clr-red-dark:       #c94444;

  --clr-text:           #2c2016;
  --clr-text-muted:     #7a6848;
  --clr-text-on-yellow: #1a1200;

  /* Spacing / shape */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.10);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.15);

  /* Typography */
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-size-base: 15px;
  --line-height: 1.6;

  /* Layout */
  --hud-height: 52px;
  --card-max-width: 480px;
  --panel-max-width: 520px;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--clr-text);
  background: linear-gradient(145deg, var(--clr-bg-start) 0%, var(--clr-bg-end) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ── .hidden ─────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Screen base ─────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

/* Overlay screens sit on top of the game screen */
.screen-overlay {
  background: rgba(30, 15, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 100;
}

/* ── #screen-game layout ─────────────────────────────────────────────────── */
#screen-game {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  background: transparent;
}

/* ── HUD ─────────────────────────────────────────────────────────────────── */
#hud {
  flex: 0 0 var(--hud-height);
  height: var(--hud-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: rgba(255, 248, 237, 0.95);
  border-bottom: 1px solid var(--clr-border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  gap: 8px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hud-item {
  font-size: 13px;
  color: var(--clr-text-muted);
  white-space: nowrap;
}

.hud-item strong {
  font-weight: 700;
  color: var(--clr-text);
}

/* ── #play-area ──────────────────────────────────────────────────────────── */
#play-area {
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  cursor: crosshair;
  background: linear-gradient(160deg, #fffdf5 0%, #fef6e0 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 320px;
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Primary — duck yellow */
.btn-primary {
  background: var(--clr-duck-yellow);
  border-color: var(--clr-duck-dark);
  color: var(--clr-text-on-yellow);
}
.btn-primary:hover {
  background: #f8d44a;
  box-shadow: var(--shadow-md);
}

/* Secondary — soft blue */
.btn-secondary {
  background: var(--clr-blue);
  border-color: var(--clr-blue-dark);
  color: #ffffff;
}
.btn-secondary:hover {
  background: #6db8f0;
  box-shadow: var(--shadow-md);
}

/* Ghost — transparent with border */
.btn-ghost {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--clr-border);
  color: var(--clr-text);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--clr-duck-dark);
  box-shadow: var(--shadow-sm);
}

/* Danger — soft red */
.btn-danger {
  background: var(--clr-red);
  border-color: var(--clr-red-dark);
  color: #ffffff;
}
.btn-danger:hover {
  background: #ed7070;
  box-shadow: var(--shadow-md);
}

/* Icon buttons in HUD */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.85);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: var(--shadow-sm);
  padding: 0;
  line-height: 1;
}
.btn-icon:hover {
  background: #ffffff;
  box-shadow: var(--shadow-md);
}
.btn-icon:active {
  transform: scale(0.93);
}

/* ── Overlay card ────────────────────────────────────────────────────────── */
.overlay-card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(90vw, var(--card-max-width));
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--clr-border-soft);
}

.overlay-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--clr-text);
  text-align: center;
}

.overlay-card p {
  color: var(--clr-text-muted);
  text-align: center;
  font-size: 14px;
}

/* ── Menu ────────────────────────────────────────────────────────────────── */
#screen-menu {
  background: transparent;
}

.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 24px;
  width: min(90vw, 400px);
}

.game-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--clr-text);
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.tagline {
  font-size: 14px;
  color: var(--clr-text-muted);
  text-align: center;
}

.menu-score-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 200, 66, 0.18);
  border: 1px solid var(--clr-duck-dark);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 14px;
}
.menu-score-display .label {
  color: var(--clr-text-muted);
}
.menu-score-display .value {
  font-weight: 800;
  color: var(--clr-text);
}

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

/* ── Mascot ──────────────────────────────────────────────────────────────── */
#mascot-container {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mascot-svg {
  width: 120px;
  height: 120px;
  animation: mascot-float 3s ease-in-out infinite;
  filter: drop-shadow(0 6px 12px rgba(245, 200, 66, 0.35));
}

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

/* ── Panel screens (settings / stats / how-to-play) ─────────────────────── */
#screen-settings,
#screen-stats,
#screen-how-to-play {
  background: linear-gradient(145deg, var(--clr-bg-start) 0%, var(--clr-bg-end) 100%);
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
}

.panel-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(90vw, var(--panel-max-width));
  padding-bottom: 24px;
}

.panel-inner h2 {
  font-size: 22px;
  font-weight: 800;
}

/* ── Fieldset / radio presets ────────────────────────────────────────────── */
fieldset {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: var(--clr-surface-tint);
}

legend {
  font-weight: 700;
  font-size: 13px;
  color: var(--clr-text-muted);
  padding: 0 6px;
}

#difficulty-presets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#difficulty-presets label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 0;
}

#difficulty-presets input[type="radio"] {
  accent-color: var(--clr-duck-yellow);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ── Slider rows ─────────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-row label {
  flex: 0 0 190px;
  font-size: 14px;
  color: var(--clr-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-row label span {
  font-weight: 700;
  color: var(--clr-text-muted);
  min-width: 44px;
}

.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--clr-duck-orange);
  height: 6px;
  cursor: pointer;
}

/* ── Lock notice ─────────────────────────────────────────────────────────── */
.notice {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #7a5a00;
}

/* ── Score breakdown ─────────────────────────────────────────────────────── */
.score-breakdown {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  font-size: 14px;
  padding: 5px 0;
  border-bottom: 1px solid var(--clr-border-soft);
  align-items: center;
}

.score-row span:last-child {
  font-weight: 700;
  min-width: 70px;
  text-align: right;
}

.score-total {
  border-top: 2px solid var(--clr-border);
  border-bottom: none;
  padding-top: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--clr-text);
}

.score-cumulative {
  border-bottom: none;
  font-size: 15px;
  font-weight: 800;
  color: var(--clr-duck-dark);
}

/* ── Stat rows ───────────────────────────────────────────────────────────── */
.final-stats,
#stats-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--clr-border-soft);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row span {
  color: var(--clr-text-muted);
}

.stat-row strong {
  font-weight: 800;
  color: var(--clr-text);
}

/* ── How to Play ─────────────────────────────────────────────────────────── */
.instructions {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--clr-text);
}

.instructions li {
  line-height: 1.5;
}

#screen-how-to-play h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--clr-text);
}

#screen-how-to-play ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--clr-text-muted);
}

/* ── Duck elements in play area ──────────────────────────────────────────── */
.duck-hidden {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.duck-visible {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: duck-found-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  z-index: 5;
}

.duck-found-svg {
  width: 100%;
  height: 100%;
}

.burst-ring {
  animation: burst-ring-expand 0.5s ease-out both;
}

@keyframes duck-found-bounce {
  0%   { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(5deg);  opacity: 1; }
  100% { transform: scale(1) rotate(0deg);     opacity: 1; }
}

@keyframes burst-ring-expand {
  0%   { r: 20; opacity: 0.8; }
  100% { r: 48; opacity: 0; }
}

/* ── Misclick ripple ─────────────────────────────────────────────────────── */
.misclick-ripple {
  position: absolute;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  margin-top: -20px;
  border-radius: 50%;
  border: 2px solid var(--clr-red);
  pointer-events: none;
  animation: misclick-ripple-out 0.6s ease-out both;
  z-index: 4;
}

@keyframes misclick-ripple-out {
  0%   { transform: scale(0.4); opacity: 0.8; }
  100% { transform: scale(2.0); opacity: 0; }
}

/* ── Proximity indicator ─────────────────────────────────────────────────── */
#proximity-indicator,
.proximity-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  margin-top: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 200, 50, 0.45) 0%, rgba(255, 140, 66, 0.15) 60%, transparent 100%);
  pointer-events: none;
  transform-origin: center;
  transition: transform 0.1s ease-out, opacity 0.1s ease-out;
  z-index: 3;
}

/* ── Animations — reduced-motion override ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mascot-svg            { animation: none; }
  .duck-visible          { animation: none; opacity: 1; transform: scale(1); }
  .burst-ring            { animation: none; }
  .misclick-ripple       { animation: none; }
  *                      { transition-duration: 0.001ms !important; }
}

/* ── Mobile layout (≤640px) ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --hud-height: 44px;
    --font-size-base: 14px;
  }

  .btn {
    font-size: 14px;
    padding: 10px 18px;
  }

  .game-title {
    font-size: 21px;
  }

  #hud {
    padding: 0 8px;
    gap: 4px;
  }

  .hud-left {
    gap: 8px;
  }

  .hud-item {
    font-size: 11px;
  }

  #hud-difficulty-wrap {
    display: none;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .overlay-card {
    padding: 24px 18px;
    gap: 12px;
  }

  .overlay-card h2 {
    font-size: 18px;
  }

  .panel-inner {
    gap: 12px;
  }

  .slider-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .slider-row label {
    flex: none;
  }

  .slider-row input[type="range"] {
    width: 100%;
  }

  .menu-inner {
    gap: 10px;
    padding: 20px 16px;
  }

  #mascot-container {
    width: 90px;
    height: 90px;
  }

  .mascot-svg {
    width: 90px;
    height: 90px;
  }
}

/* ── Narrow viewport — extra-small screens ───────────────────────────────── */
@media (max-width: 375px) {
  .hud-left {
    gap: 5px;
  }
  .hud-item {
    font-size: 10px;
  }
  .btn {
    font-size: 13px;
    padding: 9px 14px;
  }
}
