/* =============================================
   CSS Variables
   ============================================= */

:root {
  --cream:    #FFF8F0;
  --ink:      #2A2438;
  --ink-mid:  #5A506A;
  --ink-soft: #9A90AA;

  --blush:    #F4A0B8;
  --mint:     #80D8B0;
  --sky:      #90C8F0;
  --lavender: #C0A0E8;
  --peach:    #FFBB88;
  --sage:     #A0C8A0;
  --lemon:    #F0D060;
  --lilac:    #D8A8E0;
}

/* =============================================
   Reset & Base
   ============================================= */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
}

button {
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  border: none;
  outline: none;
}

/* =============================================
   Screen base
   ============================================= */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* =============================================
   Start Screen
   ============================================= */

#start-screen {
  background: var(--cream);
  flex-direction: column;
  overflow-y: auto;
  align-items: center;
}

.floating-pixels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-pixel {
  position: absolute;
  bottom: -60px;
  border-radius: 5px;
  opacity: 0.75;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.75;
  }
  80% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-110vh) rotate(200deg);
    opacity: 0;
  }
}

.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 1;
  padding: 20px 24px;
  text-align: center;
  width: 100%;
}

.logo {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(3rem, 14vw, 6rem);
  line-height: 1;
  letter-spacing: -1px;
  user-select: none;
}

.logo-pixel { color: #A070DD; transition: color 0.6s ease; }
.logo-pick  { color: #48C99A; transition: color 0.6s ease; }

.tagline {
  font-weight: 600;
  font-size: clamp(1rem, 3vw, 1.2rem);
  color: var(--ink-mid);
}

.btn-play {
  font-weight: 800;
  font-size: 1.2rem;
  background: var(--ink);
  color: var(--cream);
  border-radius: 50px;
  padding: 16px 64px;
  min-height: 56px;
  margin-top: 8px;
  transition: transform 0.15s ease, background 0.15s ease;
  letter-spacing: 0.02em;
}

.btn-play:hover  { transform: scale(1.06); background: #3D3750; }
.btn-play:active { transform: scale(0.97); }

/* =============================================
   Game Screen
   ============================================= */

#game-screen {
  cursor: crosshair;
  padding: 0;
}

#game-canvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

/* HUD dark gradient at top for readability */
.hud-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.18), transparent);
  pointer-events: none;
  z-index: 5;
}

/* HUD row */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  z-index: 10;
  pointer-events: none;
}

.hud-score {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: white;
  text-shadow: 0 1px 6px rgba(0,0,0,0.25);
  min-width: 90px;
}

.timer-pill {
  background: rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 5px 20px;
  transition: background 0.3s ease;
}

.timer-pill.timer-urgent {
  background: rgba(255, 60, 60, 0.35);
}

.hud-timer {
  font-family: 'Fredoka One', cursive;
  font-size: 1.5rem;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
  display: block;
  line-height: 1.4;
}

.timer-pill.timer-urgent .hud-timer {
  color: #FFE0E0;
}

.hud-lives {
  display: flex;
  gap: 5px;
  min-width: 90px;
  justify-content: flex-end;
}

.heart {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.2));
  transition: opacity 0.2s ease;
}

.heart-full  { color: white; opacity: 1; }
.heart-empty { color: white; opacity: 0.25; }

/* Target patch */
#target-patch {
  position: absolute;
  border-radius: 4px;
  cursor: crosshair;
}

/* Home / menu button */
.home-btn {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.85);
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  z-index: 20;
  min-height: 36px;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}

.home-btn:hover  { background: rgba(255,255,255,0.32); }
.home-btn:active { transform: translateX(-50%) scale(0.95); }

/* Wrong click — red border flash */
#game-canvas.wrong-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 16px rgba(220, 30, 30, 0.55);
  pointer-events: none;
  z-index: 20;
  animation: wrongFlash 0.4s ease-out forwards;
}

@keyframes wrongFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Screen shake on death */
@keyframes shake {
  0%,  100% { transform: translateX(0); }
  12%        { transform: translateX(-10px); }
  25%        { transform: translateX(10px); }
  37%        { transform: translateX(-8px); }
  50%        { transform: translateX(8px); }
  62%        { transform: translateX(-5px); }
  75%        { transform: translateX(5px); }
  88%        { transform: translateX(-2px); }
}

#game-screen.shake {
  animation: shake 0.5s ease-in-out;
}

/* Green ripple on correct click */
.ripple {
  position: fixed;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(80, 220, 140, 0.65);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 50;
  animation: rippleAnim 0.6s ease-out forwards;
}

@keyframes rippleAnim {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(9); opacity: 0; }
}

/* =============================================
   Result Screen
   ============================================= */

#result-screen {
  transition: background-color 0.4s ease;
  overflow-y: auto;
  align-items: center;
}

#result-card {
  background: white;
  border-radius: 28px;
  padding: 40px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 40px);
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  text-align: center;
  margin: 20px 0;
}

#result-emoji {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 4px;
}

#result-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--ink);
  line-height: 1.1;
}

#result-desc {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-mid);
  margin-bottom: 4px;
}

#result-score {
  font-family: 'Fredoka One', cursive;
  font-size: 3.5rem;
  color: var(--ink);
  line-height: 1;
  margin-top: 4px;
}

.result-label {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: -4px;
}

.result-divider {
  width: 100%;
  height: 1px;
  background: #EDE8F5;
  margin: 6px 0;
}

#result-rounds,
#result-hardest,
#result-percentile {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink-mid);
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.btn-share {
  font-weight: 800;
  font-size: 1rem;
  background: var(--ink);
  color: white;
  border-radius: 50px;
  padding: 15px 24px;
  min-height: 52px;
  transition: transform 0.15s ease, background 0.15s ease;
  letter-spacing: 0.02em;
}

.btn-share:hover  { transform: scale(1.03); background: #3D3750; }
.btn-share:active { transform: scale(0.97); }

.btn-play-again {
  font-weight: 700;
  font-size: 1rem;
  background: transparent;
  color: var(--ink-mid);
  border: 2px solid #DDD5EE;
  border-radius: 50px;
  padding: 13px 24px;
  min-height: 52px;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-play-again:hover  { border-color: var(--ink-mid); color: var(--ink); transform: scale(1.03); }
.btn-play-again:active { transform: scale(0.97); }

/* =============================================
   Start screen — filter rows
   ============================================= */

#filter-rows {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 380px;
}

.filter-row {
  background: white;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  padding: 6px;
  display: flex;
  align-items: center;
}

.filter-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9A90AA;
  padding: 0 10px;
  min-width: 64px;
  white-space: nowrap;
}

.filter-options {
  display: flex;
  align-items: center;
  flex: 1;
}

.filter-btn {
  border-radius: 12px;
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all .15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 4px;
  min-height: 48px;
  color: #9A90AA;
}

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

.filter-icon {
  font-size: 15px;
  line-height: 1;
}

.filter-name {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  color: inherit;
}

.filter-desc {
  font-size: 10px;
  font-weight: 600;
  color: inherit;
  opacity: 0.75;
}

.filter-divider {
  width: 1px;
  background: rgba(0,0,0,0.08);
  height: 28px;
  flex-shrink: 0;
}

.filter-coming-soon {
  opacity: 0.45;
  cursor: not-allowed;
}

.coming-soon-pill {
  font-size: 9px;
  font-weight: 700;
  background: #FFF3C0;
  color: #B8880A;
  border-radius: 6px;
  padding: 2px 5px;
}

.combo-preview {
  font-size: 12px;
  font-weight: 700;
  color: #9A90AA;
  text-align: center;
  min-height: 1.2em;
}

/* Floating pixels greyscale mode */
.floating-pixel {
  transition: filter 0.3s ease;
}

.floating-pixels.greyscale .floating-pixel {
  filter: grayscale(1);
}

/* =============================================
   Result screen additions
   ============================================= */

.result-combo-pill {
  font-size: 11px;
  font-weight: 700;
  color: #9A90AA;
  background: #F5F0FF;
  border-radius: 20px;
  padding: 4px 12px;
  margin-bottom: 2px;
  white-space: nowrap;
}

#result-elapsed,
#result-wrong-picks {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* =============================================
   Mobile tweaks
   ============================================= */

@media (max-width: 400px) {
  .hud {
    padding: 14px 16px;
  }

  .hud-score {
    font-size: 1.6rem;
  }

  #result-card {
    padding: 32px 28px;
  }

  #result-score {
    font-size: 2.8rem;
  }
}
