/* ---------- Base / Layout ---------- */
:root{
  --container-max-width:420px;
  --accent-1: #d81b60;
  --accent-2: #8e24aa;
  --start-grad-a: #ec407a;
  --start-grad-b: #d81b60;
}

*{box-sizing:border-box}
html,body{
  height:100%;
  margin:0;
  padding:0;
}

/* Soft pastel background */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  justify-content: center; /* horiz center */
  align-items: center;     /* vert center */
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
  color: #333;
  flex-direction: column;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  overflow-x: hidden;
  padding: 18px; /* prevents tight edges on small screens */
}

/* ---------- Game container (frosted panel) ---------- */
.game-container {
  width: 100%;
  max-width: var(--container-max-width);
  padding: 18px;                 /* reduced padding to avoid scroll on laptops */
  border-radius: 18px;
  background: rgba(255,255,255,0.72); /* lighter frost so colors pop */
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Start overlay */
#start-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 800px at 50% 40%, rgba(99,102,241,0.18), rgba(10,16,30,0.45));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
}

#start-overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(92vw, 460px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  padding: 26px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,0.26), rgba(255,255,255,0.12));
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: 0 12px 36px rgba(0,0,0,0.35), 0 0 0 3px rgba(99,102,241,0.18) inset;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.overlay-card h2 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.3px;
  background: linear-gradient(45deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay-card .sub {
  opacity: 0.95;
  color: #333;
}

#overlay-start-btn {
  background: linear-gradient(90deg, #22c55e, #3b82f6);
  box-shadow: 0 10px 20px rgba(34,197,94,0.25), 0 8px 24px rgba(59,130,246,0.25);
  border: none;
  color: #fff;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

#overlay-start-btn:hover {
  transform: translateY(-1px) scale(1.04);
}

/* Restart overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 800px at 50% 40%, rgba(99,102,241,0.18), rgba(10,16,30,0.45));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
}

.overlay.hidden {
  display: none;
}

.ghost-btn {
  background: rgba(255,255,255,0.28);
  color: #111;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.12));
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.ghost-btn:hover {
  transform: translateY(-1px) scale(1.03);
  filter: brightness(1.04);
}

#restart-game-btn {
  background: linear-gradient(45deg, var(--start-grad-a), var(--start-grad-b));
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(216,27,96,0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#restart-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(142,36,170,0.22);
}

/* Title with gradient text */
h1{
  margin: 10px 0 8px 0;
  font-size: clamp(1.4rem, 4.5vw, 1.9rem);
  font-weight: 700;
  background: linear-gradient(45deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height:1;
}

/* Game info stacked and compact */
#game-info{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  margin-bottom:10px;
  color:#333;
  font-weight:600;
}

/* ---------- Game board (white inner panel so colors stand out) ---------- */
#game-board{
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:12px;
  border-radius:14px;
  padding:10px;
  background: rgba(255,255,255,1); /* solid white panel */
  box-shadow: inset 0 6px 18px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
}

/* ---------- Color buttons (vivid solid colors) ---------- */
.color-button{
  width:100%;
  height:100%;
  border-radius:10px;
  cursor:pointer;
  border:none;
  transition: transform .14s ease, box-shadow .18s ease, background-color .12s ease;
  display:block;
  outline:none;
}

/* base vivid colors */
#red   { background:#e53935; }
#green { background:#43a047; }
#blue  { background:#1e88e5; }
#yellow{ background:#fbc02d; }

/* darker active states for clear selection */
#red.active    { background:#b71c1c; box-shadow: 0 6px 18px rgba(183,28,28,0.26); }
#green.active  { background:#2e7d32; box-shadow: 0 6px 18px rgba(46,125,50,0.22); }
#blue.active   { background:#0d47a1; box-shadow: 0 6px 18px rgba(13,71,161,0.22); }
#yellow.active { background:#f57f17; box-shadow: 0 6px 18px rgba(245,127,23,0.18); }

.color-button:hover { transform: scale(1.03); }

/* Make sure keyboard focus is visible */
.color-button:focus { box-shadow: 0 0 0 4px rgba(0,0,0,0.06); }


/* Timer & message */
#timer-display{ margin-top:12px; font-weight:700; color:#333; }
#timer-display span{ color:#d81b60; }

#message { margin-top:10px; min-height:20px; font-weight:700; color:#444; }


/* Level transition FX */
.level-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  background: radial-gradient(600px 600px at 50% 50%, rgba(255,255,255,0.7), rgba(255,255,255,0));
}

.level-flash.show {
  animation: levelFlash 0.75s ease-out forwards;
}

@keyframes levelFlash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

.level-banner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 65;
  pointer-events: none;
}

.level-banner .text {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.5);
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 26px;
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  opacity: 0;
  transform: scale(0.9);
  animation: levelBanner 950ms ease-out forwards;
  background: linear-gradient(45deg, var(--start-grad-a), var(--start-grad-b));
  color: #fff;
  box-shadow: 0 12px 32px rgba(216,27,96,0.3);
}

@keyframes levelBanner {
  0% { opacity: 0; transform: scale(0.9); }
  20% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1); }
}

/* small tweaks */
.hidden{ display:none !important; }

/* ---------- Responsive: ensure Start visible on laptops and no scroll ---------- */
/* For medium height screens make container a bit tighter */
@media (max-height: 820px){
  .game-container { padding:14px; }
  #game-board { max-width: 260px; gap:10px; padding:8px; }
  #start-btn { padding:10px 18px; }
}

/* For small screens */
@media (max-width:600px){
  .game-container{ padding:12px; border-radius:12px; }
  #game-board{ max-width: 260px; gap:8px; padding:8px; }
}

/* 3D Blink Animation */
@keyframes blink3D {
  0% {
    transform: scale(1) translateZ(0);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  }
  40% {
    transform: scale(0.9) translateZ(10px);
    box-shadow: 0 0 20px rgba(0,0,0,0.5), 0 0 30px currentColor;
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1) translateZ(0);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    filter: brightness(1);
  }
}

/* Active state with 3D blink */
.color-button.active {
  animation: blink3D 0.35s ease forwards;
}
