/* --- GLOBAL STYLES & THEME VARIABLES --- */
:root {
  --color-bg-dark: #0b1120;
  --color-primary: #00f0ff;      /* Water Cyan */
  --color-secondary: #10b981;    /* Shell Green */
  --color-accent: #f59e0b;       /* Berry Gold */
  --color-panel-bg: rgba(15, 23, 42, 0.75);
  --color-glass-border: rgba(255, 255, 255, 0.08);
  --font-retro: 'Press Start 2P', monospace;
  --font-sans: 'Outfit', sans-serif;
  --glow-cyan: 0 0 15px rgba(0, 240, 255, 0.4);
  --glow-green: 0 0 15px rgba(16, 185, 129, 0.4);
  --cabinet-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--color-bg-dark);
  color: #f8fafc;
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  padding: 2rem 1rem 4rem 1rem;
}

/* Background animated stars & bubbles */
.stars-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at bottom, #1e293b 0%, #020617 100%);
  z-index: -2;
  overflow: hidden;
}

.stars-bg::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 2px;
  background: white;
  box-shadow: 
    10vw 20vh #fff, 25vw 45vh rgba(255,255,255,0.4), 45vw 15vh #fff, 75vw 60vh #fff,
    85vw 30vh rgba(255,255,255,0.5), 90vw 80vh #fff, 60vw 90vh #fff, 15vw 75vh #fff;
  border-radius: 50%;
  opacity: 0.6;
}

.bubbles-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.bubble {
  position: absolute;
  bottom: -50px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 50%;
  animation: floatUp 8s infinite linear;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0;
  }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% {
    transform: translateY(-110vh) translateX(50px) scale(0.5);
    opacity: 0;
  }
}

/* --- MAIN CONTAINER (ARCADE CABINET LAYOUT) --- */
.arcade-container {
  display: flex;
  gap: 2rem;
  width: 90%;
  max-width: 1250px;
  height: 970px;
  justify-content: center;
  align-items: stretch;
  z-index: 1;
}

/* --- SIDE PANELS --- */
.side-panel {
  flex: 1;
  background: var(--color-panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-glass-border);
  border-radius: 20px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--cabinet-shadow);
  border-top: 2px solid rgba(0, 240, 255, 0.2);
}

.side-panel h2 {
  font-family: var(--font-retro);
  font-size: 0.9rem;
  color: var(--color-primary);
  text-shadow: var(--glow-cyan);
  text-align: center;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid rgba(0, 240, 255, 0.2);
  padding-bottom: 0.75rem;
}

/* Left Panel (Controls/Tips) */
.control-group {
  margin-bottom: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.key {
  display: inline-block;
  background: #334155;
  color: #f8fafc;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  border-bottom: 3px solid #1e293b;
  margin-right: 0.25rem;
}

.control-group p {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.tips-box {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
}

.tips-box h3 {
  font-family: var(--font-retro);
  font-size: 0.7rem;
  color: var(--color-secondary);
  text-shadow: var(--glow-green);
  margin-bottom: 0.75rem;
}

.tips-box ul {
  list-style: none;
}

.tips-box li {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 0.5rem;
  position: relative;
  padding-left: 1rem;
  line-height: 1.3;
}

.tips-box li::before {
  content: "•";
  color: var(--color-secondary);
  position: absolute;
  left: 0;
  font-weight: bold;
}

/* Right Panel (Leaderboard & Badge) */
.leaderboard-list {
  list-style: none;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.5rem;
  font-family: var(--font-retro);
  font-size: 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-list li:first-child {
  color: var(--color-accent);
}

.rank {
  width: 50px;
}

.name {
  flex-grow: 1;
  color: #94a3b8;
}

.leaderboard-list li:first-child .name {
  color: #fff;
}

.score {
  font-family: var(--font-retro);
}

.network-badge {
  margin-top: auto;
  text-align: center;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.75rem;
  border-radius: 12px;
}

.network-badge p {
  font-size: 0.7rem;
  font-family: var(--font-retro);
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.badge-status {
  display: inline-block;
  font-family: var(--font-retro);
  font-size: 0.7rem;
  color: var(--color-secondary);
  text-shadow: var(--glow-green);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- CENTER CABINET WRAPPER --- */
.game-wrapper {
  width: 520px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 8px solid #334155;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 
    var(--cabinet-shadow),
    inset 0 0 20px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}

/* Glowing side stripes representing custom Poké-Colors */
.game-wrapper::before, .game-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--color-primary), var(--color-secondary));
  z-index: 5;
}
.game-wrapper::before { left: 0; }
.game-wrapper::after { right: 0; }

.game-header {
  padding: 1.25rem;
  background: #1e293b;
  border-bottom: 4px solid #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.game-title {
  font-family: var(--font-retro);
  font-size: 1.1rem;
  letter-spacing: 1px;
  color: var(--color-primary);
  text-shadow: var(--glow-cyan);
}

.lcd-display {
  width: 100%;
  background-color: #020617;
  border: 2px solid #334155;
  border-radius: 8px;
  display: flex;
  padding: 0.5rem 1rem;
  justify-content: space-between;
}

.lcd-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.lcd-label {
  font-size: 0.6rem;
  font-family: var(--font-retro);
  color: #475569;
}

.lcd-value {
  font-family: var(--font-retro);
  font-size: 1rem;
  color: var(--color-accent);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* --- THE GAME SCREEN (CANVAS VIEWPORT) --- */
.screen-container {
  position: relative;
  width: 480px;
  height: 720px;
  margin: 0 auto;
  border: 4px solid #020617;
  background-color: #e0f2fe; /* Sky/Ocean light blue background */
  overflow: hidden;
}

/* CRT scanline simulation overlay */
.screen-container::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.12) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  z-index: 10;
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
}

#gameCanvas {
  display: block;
  background: linear-gradient(to bottom, #7dd3fc, #bae6fd 70%, #e0f2fe);
}

/* --- SCREEN OVERLAYS (START, GAME OVER, PAUSE) --- */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 47, 73, 0.85); /* Pokémon-esque dark blue overlay */
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 2rem;
  text-align: center;
}

.screen-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Start screen logo */
.logo-area {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.squirtle-logo-holder {
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, var(--color-primary) 0%, rgba(0,0,0,0) 70%);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  animation: hoverSquirtle 3s infinite ease-in-out;
}

#logoSquirtle {
  width: 90px;
  height: 90px;
  object-fit: contain;
  image-rendering: pixelated;
}

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

.neon-text {
  font-family: var(--font-retro);
  font-size: 1.4rem;
  line-height: 1.4;
  color: #fff;
  text-shadow: 0 0 10px var(--color-primary), 0 0 20px var(--color-primary);
}

.neon-text .highlight {
  color: var(--color-secondary);
  text-shadow: 0 0 10px var(--color-secondary), 0 0 20px var(--color-secondary);
}

.blink-text {
  font-family: var(--font-retro);
  font-size: 0.65rem;
  color: #fff;
  animation: blink 1.2s infinite;
  margin-bottom: 2rem;
  letter-spacing: 0.5px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.game-info {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 1rem;
}

/* Game Over overlay screen */
.game-over-title {
  font-family: var(--font-retro);
  font-size: 1.5rem;
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  margin-bottom: 1.5rem;
}

.stats-panel {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid #ef4444;
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-retro);
  font-size: 0.75rem;
  color: #cbd5e1;
}

.stat-val {
  color: #fff;
}

#newHighScoreRow {
  display: none;
  justify-content: center;
  color: var(--color-accent);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
  animation: blink 0.8s infinite;
  margin-top: 0.5rem;
}

.arcade-btn {
  font-family: var(--font-retro);
  font-size: 0.8rem;
  background: var(--color-secondary);
  color: #fff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px #047857, 0 6px 15px rgba(0,0,0,0.3);
  transition: all 0.1s ease;
}

.arcade-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0px #047857, 0 2px 10px rgba(0,0,0,0.3);
}

/* Pause Screen overlay */
.pause-title {
  font-family: var(--font-retro);
  font-size: 1.5rem;
  color: var(--color-primary);
  text-shadow: var(--glow-cyan);
  margin-bottom: 1rem;
}

/* --- CABINET BOTTOM FOOTER (PHYSICAL BUTTONS) --- */
.game-footer {
  padding: 1.25rem 1.5rem;
  background: #1e293b;
  border-top: 4px solid #0f172a;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.cabinet-buttons {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
}

.button-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.btn-label, .joystick-label {
  font-family: var(--font-retro);
  font-size: 0.5rem;
  color: #64748b;
}

/* Virtual Joystick representation */
.joystick-base {
  width: 60px;
  height: 60px;
  background: #0f172a;
  border-radius: 50%;
  border: 3px solid #475569;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.joystick {
  width: 28px;
  height: 28px;
  background: radial-gradient(circle, #ef4444 0%, #b91c1c 100%);
  border-radius: 50%;
  position: absolute;
  top: 13px;
  left: 13px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease;
}

/* Physical style circular arcade buttons */
.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #1e293b;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.red-btn {
  background: radial-gradient(circle, #ef4444 0%, #b91c1c 100%);
  box-shadow: 0 4px 0 #7f1d1d, 0 6px 10px rgba(0,0,0,0.4);
}
.red-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #7f1d1d, 0 2px 5px rgba(0,0,0,0.4);
}

.yellow-btn {
  background: radial-gradient(circle, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 4px 0 #78350f, 0 6px 10px rgba(0,0,0,0.4);
}
.yellow-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #78350f, 0 2px 5px rgba(0,0,0,0.4);
}

/* --- RESPONSIVE MOBILE SCALING --- */
@media (max-width: 1024px) {
  .side-panel {
    display: none; /* Hide sides on tablets and phones */
  }
  .arcade-container {
    height: auto;
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .game-wrapper {
    width: 100%;
    border-radius: 0;
    border: none;
  }
  .screen-container {
    width: 100%;
    height: auto;
    aspect-ratio: 2/3;
  }
  #gameCanvas {
    width: 100%;
    height: auto;
  }
  .arcade-container {
    height: 100vh;
    padding: 0;
  }
}

/* --- SITE CREDIT FOOTER --- */
.site-credit {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
}

.site-credit a {
  font-family: var(--font-retro);
  font-size: 0.55rem;
  color: #475569;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.site-credit a:hover {
  color: var(--color-primary);
  text-shadow: var(--glow-cyan);
}
