@font-face {
  font-family: 'Press Start 2P';
  src: url('./PressStart2P-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Space Mono', monospace;
  background: #1a1a1a;
  color: #ffffff;
  overflow-x: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 100vw;
  overflow: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  position: relative; /* Establish stacking context for header */
  z-index: 2;        /* Ensure header is above game area */
}

.header-title {
  font-family: 'Press Start 2P', 'Space Mono', monospace;
  font-size: clamp(14px, 4.5vw, 28px);
  font-weight: 700;
  letter-spacing: 1px;
}

#app.playing .header-title {
  /* Reduce size responsively instead of truncating with ellipsis */
  font-size: clamp(12px, 3.6vw, 18px);
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.score-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.score-label {
  font-size: 12px;
  color: #888;
  font-weight: 400;
}

.score {
  font-size: 24px;
  font-weight: 700;
  color: #00ff88;
}

.mute-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.mute-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  gap: 20px;
  position: relative; /* Establish stacking context for game area */
  z-index: 1;        /* Ensure game area is below header */
}

.word-display {
  text-align: center;
  margin-bottom: 10px;
}

.color-word {
  font-family: 'Press Start 2P', 'Space Mono', monospace;
  font-size: 48px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.level-container, .lives-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-label, .lives-label {
    font-size: 10px;
    color: #888;
    font-weight: 400;
}

.level {
    font-size: 18px;
    font-weight: 700;
    color: #00aaff;
}

.lives {
    display: flex;
    gap: 4px;
}

.life {
    font-size: 14px;
    transition: opacity 0.3s ease;
}

.life.lost {
    opacity: 0.3;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.color-circles {
    display: grid;
    gap: 15px;
    max-width: 400px;
    width: 100%;
    justify-content: center;
}

.color-circles.grid-one-column {
    grid-template-columns: repeat(1, 1fr);
}

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

.color-circles.grid-6 {
    grid-template-columns: repeat(3, 1fr);
}

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

.color-circles.grid-9 {
    grid-template-columns: repeat(3, 1fr);
}

.color-circles.grid-12 {
    grid-template-columns: repeat(3, 1fr);
}

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

.color-circle {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12); /* slightly darker rim */
    cursor: pointer;
    transition: transform 160ms cubic-bezier(.2,.9,.2,1), box-shadow 160ms ease, filter 160ms ease;
    box-shadow: 0 14px 30px rgba(0,0,0,0.55), inset 0 -8px 22px rgba(0,0,0,0.28);
    position: relative;
    overflow: hidden;
    justify-self: center;
    background-image: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.03) 8%, transparent 30%), linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.06));
    will-change: transform;
}

.color-circle::before {
  content: '';
  position: absolute;
  top: 12%;
  left: 12%;
  width: 76%;
  height: 76%;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.28), rgba(255,255,255,0.06) 20%, transparent 55%);
  border-radius: 50%;
  transform: translateZ(0);
  transition: transform 220ms ease, opacity 220ms ease;
  pointer-events: none;
  opacity: 1;
}

.color-circle::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 2px 8px rgba(255,255,255,0.06), inset 0 -8px 24px rgba(0,0,0,0.25);
  pointer-events: none;
  mix-blend-mode: overlay;
}

.color-circle:active { 
  transform: scale(0.96); 
  filter: brightness(0.95) saturate(1.05); 
}

.color-circle:hover { 
  transform: translateY(-6px) scale(1.02); 
  box-shadow: 0 18px 42px rgba(0,0,0,0.6); 
}

.color-circle.correct {
  animation: correctPulse 0.5s ease;
  box-shadow: 0 18px 48px rgba(0,255,136,0.18), inset 0 0 36px rgba(0,255,136,0.06);
  transform: scale(1.06);
}

.color-circle.wrong {
  animation: wrongShake 0.45s ease;
  box-shadow: 0 14px 36px rgba(255,64,64,0.16);
  transform: translateY(0);
}

.timer {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 20px;
}

.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, #00ff88, #ffaa00, #ff4444);
  border-radius: 3px;
  transition: width linear;
}

.start-screen, .game-over {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  z-index: 100;
}

.hidden {
  display: none !important;
}

.game-title {
  font-size: 96px;
  font-weight: 700;
  margin-bottom: 20px;
  background: none;
  -webkit-text-fill-color: initial;
  color: #fff;
}

.game-description {
  font-size: 18px;
  color: #ccc;
  margin-bottom: 40px;
  line-height: 1.5;
}

.start-btn, .restart-btn {
  background: linear-gradient(45deg, #00ff88, #00aaff);
  border: none;
  padding: 16px 32px;
  font-size: 18px;
  font-weight: 700;
  color: #000;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.start-btn:hover, .restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 255, 136, 0.3);
}

.instructions {
  margin-top: 40px;
  font-size: 14px;
  color: #888;
  line-height: 1.8;
}

.instructions p {
  margin: 8px 0;
}

.final-score, .best-score {
  font-size: 20px;
  margin: 10px 0;
}

.final-score {
  color: #00ff88;
}

.best-score {
  color: #ffaa00;
}

.footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: #666;
  background: rgba(255, 255, 255, 0.02);
}

.footer a {
  color: #00ff88;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: #00aaff;
}

.menu { position: relative; }
.menu-btn { font-size: 28px; padding: 12px 14px; background:none;border:1px solid rgba(255,255,255,0.2);color:#fff;border-radius:8px; z-index:1000; position:relative; }
.menu-backdrop{ position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:999998; }
.menu-panel { position: fixed; right: 12px; top: 12px; width: min(92vw, 420px); z-index:999999; padding: 14px 12px; font-size: 18px; background:#111; border:1px solid rgba(255,255,255,0.1); border-radius:10px; display:flex; flex-direction:column; gap:8px; transform-origin: top right; transform: scale(0.98); opacity:0; transition: opacity .15s ease, transform .15s ease; }
.menu-panel:not(.hidden){ opacity:1; transform: scale(1); }
.menu-header{ font-size:14px; color:#999; padding:4px 6px 2px; letter-spacing:.08em; text-transform:uppercase; }
.menu-item { font-size: 18px; padding: 14px 16px; background:#1a1a1a; color:#fff; border:1px solid rgba(255,255,255,0.1); border-radius:8px; text-align:left; }
.menu-item + .menu-item { margin-top: 6px; }
.menu-item.active{ border-color:#00ff88; box-shadow: inset 0 0 0 1px rgba(0,255,136,0.4); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 300; }
.modal-card { width: min(92vw, 420px); background:#151515; border:1px solid rgba(255,255,255,0.1); border-radius:16px; padding:18px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-title { font-size:20px; margin-bottom:8px; }
.modal-text { color:#ccc; font-size:14px; line-height:1.6; margin-bottom:16px; }
.modal-actions { display:flex; gap:10px; justify-content:flex-end; }
.modal-btn { padding:10px 14px; border-radius:10px; border:1px solid rgba(255,255,255,0.15); font-weight:700; }
.modal-btn.primary { background: linear-gradient(45deg,#00ff88,#00aaff); color:#000; border:none; }
.modal-btn.ghost { background: transparent; color:#fff; }

/* Mobile optimizations */
@media (max-width: 480px) {
  .color-word {
    font-size: 36px;
  }
  
  .color-circle {
    width: 76px;
    height: 76px;
  }
  
  .game-title {
    font-family: 'Press Start 2P', 'Space Mono', monospace;
    font-size: 64px;
    line-height: 0.95;
  }
  
  .header {
    padding: 15px;
  }
  
  .game-info {
    gap: 8px;
  }
  
  .level {
    font-size: 16px;
  }
  
  .life {
    font-size: 12px;
  }
  
  .header-title {
    font-size: clamp(12px, 6.5vw, 24px);
    line-height: 1;
    white-space: normal;
  }
  
  .status-row {
    gap: 12px;
  }
  
  #app.playing .header-title {
    font-size: clamp(10px, 5.5vw, 16px);
    max-width: 100%;
    white-space: normal;
  }
}

@media (max-height: 700px) {
  .game-area {
    gap: 15px;
  }
  
  .word-display {
    margin-bottom: 5px;
  }
  
  .color-word {
    font-size: 26px;
  }
  
  .color-circle {
    width: 60px;
    height: 60px;
  }
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 30px rgba(0, 255, 136, 0.6); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}