:root {
  --gb-body: #9ca3af;
  --gb-body-dark: #64748b;
  --gb-screen: #8bac0f;
  --gb-dark: #306230;
  --gb-bezel: #374151;
  --gb-button: #9f1239;
  --gb-button-dark: #4c0519;
  --primary: #39ff14;
  --accent: #ffb000;
  --error: #ff3333;
  --white: #ffffff;
  --text-dark: #1f2937;
  
  --pastel-1: #fbcfe8;
  --pastel-2: #e0e7ff;
  --pastel-3: #fef3c7;
  --pastel-4: #d1fae5;
}

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

body {
  background: linear-gradient(-45deg, var(--pastel-1), var(--pastel-2), var(--pastel-3), var(--pastel-4));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  font-family: 'Press Start 2P', 'Noto Sans KR', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  padding: 0;
  position: relative;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- Structured Background Pokemon --- */
.bg-pokemon-container {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 50px 0;
  overflow: hidden;
}

.bg-row {
  display: flex;
  white-space: nowrap;
  gap: 80px;
  width: fit-content;
}

.bg-row.left { animation: marqueeLeft 40s linear infinite; }
.bg-row.right { animation: marqueeRight 40s linear infinite; }

@keyframes marqueeLeft {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@keyframes marqueeRight {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

.bg-sprite {
  width: 80px;
  height: 80px;
  opacity: 0.1;
  image-rendering: pixelated;
  filter: brightness(0);
}

/* --- Navigation Menu Bar --- */
.nav-bar {
  width: 100%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 4px solid #000;
  padding: 15px 20px;
  display: flex;
  justify-content: center;
  gap: 30px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-link {
  font-size: 12px;
  text-decoration: none;
  color: #000;
  font-weight: bold;
  cursor: pointer;
  padding: 5px 10px;
  transition: transform 0.2s;
}

.nav-link:hover { transform: scale(1.1); color: var(--gb-button); }

/* --- Main Title --- */
.main-title-wrap {
  text-align: center;
  margin: 40px 0;
}

.main-title {
  font-size: 36px;
  color: #000;
  text-shadow: 4px 4px 0 var(--white);
  margin-bottom: 15px;
}

.main-subtitle {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 16px;
  color: #4b5563;
  background: rgba(255, 255, 255, 0.6);
  padding: 12px 24px;
  border-radius: 12px;
  border: 2px solid #000;
  display: inline-block;
  max-width: 90%;
}

/* --- Game Boy --- */
.gb-frame {
  position: relative;
  width: 100%;
  max-width: 460px;
  background-color: var(--gb-body);
  border-radius: 2.5rem;
  padding: 35px;
  box-shadow: 
    20px 25px 0 0 rgba(0,0,0,0.1),
    inset -4px -4px 10px rgba(0,0,0,0.2),
    inset 4px 4px 10px rgba(255,255,255,0.3);
  border-bottom: 18px solid var(--gb-body-dark);
  border-right: 18px solid var(--gb-body-dark);
  margin-bottom: 40px;
}

.gb-header-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.gb-line { height: 4px; width: 100px; background: rgba(0,0,0,0.1); border-radius: 99px; }
.gb-logo-text { font-size: 8px; font-style: italic; font-weight: bold; color: var(--gb-bezel); letter-spacing: 1px; }

.gb-bezel {
  background: var(--gb-bezel);
  border-radius: 12px;
  padding: 40px 40px 25px;
  box-shadow: inset 0 5px 15px rgba(0,0,0,0.6);
  position: relative;
  margin-bottom: 15px;
}

.gb-screen-container {
  background: var(--gb-screen);
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 4px;
  border: 8px solid rgba(48, 98, 48, 0.9);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.25);
}

.lcd-scanline {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(139, 172, 15, 0) 50%, rgba(155, 188, 15, 0.1) 50%);
  background-size: 100% 4px;
  z-index: 5;
  pointer-events: none;
}

.battery-area {
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.battery-led {
  width: 10px;
  height: 10px;
  background: #dc2626;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.9);
}

.battery-text { color: #dc2626; font-size: 9px; font-weight: bold; }

/* --- Screens Content --- */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 20px;
  z-index: 10;
  color: var(--gb-dark);
  text-transform: uppercase;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.screen.active { display: flex; }

.pokemon-area { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }

.silhouette-wrap {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(0,0,0,0.08);
  border-radius: 15px;
  margin-bottom: 15px;
}

.pokemon-sprite {
  max-width: 120px;
  max-height: 120px;
  image-rendering: pixelated;
  object-fit: contain;
  transition: opacity 0.3s;
}

.pokemon-sprite.hidden-sprite { filter: brightness(0); opacity: 0.9; }

#unknownIcon {
  font-size: 60px;
  font-weight: bold;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.timer-wrap { width: 100%; margin-top: 10px; }
.timer-bar-bg { height: 10px; background: rgba(48, 98, 48, 0.2); border-radius: 5px; overflow: hidden; }
.timer-bar { height: 100%; background: var(--gb-dark); width: 100%; transition: width 0.1s linear; }

/* --- Physical Controls --- */
.gb-controls {
  margin-top: 45px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  height: 200px;
}

.dpad {
  width: 110px;
  height: 110px;
  position: relative;
  filter: drop-shadow(0 5px 0 rgba(0,0,0,0.4));
  margin: auto;
}

.dpad-h { width: 110px; height: 36px; top: 37px; position: absolute; background: #374151; border-radius: 4px; }
.dpad-v { width: 36px; height: 110px; left: 37px; position: absolute; background: #374151; border-radius: 4px; }

.buttons-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  transform: rotate(-25deg) translateY(15px);
}

.gb-btn-wrap { display: flex; flex-direction: column; align-items: center; }
.gb-button { width: 60px; height: 60px; background: var(--gb-button); border-radius: 50%; box-shadow: 0 6px 0 0 var(--gb-button-dark), 0 10px 12px 0 rgba(0,0,0,0.4); }
.gb-btn-label { margin-top: 15px; font-size: 12px; color: #4b5563; font-weight: bold; transform: rotate(25deg); }

.start-select-container { display: flex; justify-content: center; gap: 60px; margin-top: 35px; }
.pill-btn-wrap { display: flex; flex-direction: column; align-items: center; transform: rotate(-25deg); }
.pill-btn { width: 55px; height: 16px; background: #4b5563; border-radius: 99px; box-shadow: inset 0 3px 5px rgba(0,0,0,0.6); }
.pill-label { margin-top: 12px; font-size: 10px; color: #4b5563; font-weight: bold; }

/* --- External UI --- */
.external-ui {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 25px;
  margin-top: 20px;
}

.score-board {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 5px solid #000;
  padding: 15px 25px;
  box-shadow: 6px 6px 0 0 #000;
}

.px-btn {
  width: 100%;
  padding: 24px;
  background: var(--primary);
  border: 5px solid #000;
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 6px 6px 0 0 #000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  transition: transform 0.1s;
}

.px-btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 0 #000; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.choice-btn {
  padding: 25px 10px;
  background: #fff;
  border: 5px solid #000;
  font-family: 'Noto Sans KR', 'Press Start 2P', sans-serif;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 6px 6px 0 0 #000;
  line-height: 1.4;
}

.choice-btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: 0 0 0 0 #000; }

.diff-select { background: #fff; border: 5px solid #000; padding: 25px; box-shadow: 6px 6px 0 0 #000; }
.diff-btns { display: flex; gap: 12px; }
.diff-btn { flex: 1; padding: 15px 5px; border: 3px solid #000; font-family: 'Press Start 2P', monospace; font-size: 10px; cursor: pointer; box-shadow: 4px 4px 0 0 #000; }
.diff-btn.selected { background: #000; color: var(--primary); }

.result-msg {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 20px;
  font-weight: bold;
  padding: 20px;
  border: 5px solid #000;
  background: #fff;
  text-align: center;
  box-shadow: 6px 6px 0 0 #000;
}

/* --- Info Section --- */
.info-section {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border: 5px solid #000;
  padding: 30px;
  margin: 50px 0;
  box-shadow: 8px 8px 0 0 #000;
  font-family: 'Noto Sans KR', sans-serif;
}

.info-section h2 { font-family: 'Press Start 2P', monospace; font-size: 14px; margin-bottom: 20px; border-bottom: 4px solid var(--primary); display: inline-block; padding-bottom: 5px; }
.info-section p { font-size: 16px; margin-bottom: 15px; color: #4b5563; line-height: 1.6; }

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: #fff;
  border: 6px solid #000;
  width: 100%;
  max-width: 550px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 40px;
  position: relative;
  box-shadow: 12px 12px 0 0 rgba(0,0,0,0.3);
}

.modal-body { font-size: 16px; line-height: 1.8; color: #333; }

/* Utils */
.hidden { display: none !important; }
.game-started .main-title-wrap, .game-started .info-section { display: none; }

@media (max-width: 600px) {
  .gb-frame { border-radius: 0; border-right: none; border-bottom: none; padding: 25px; }
  .choices { grid-template-columns: 1fr; }
  .px-btn, .choice-btn { font-size: 16px; }
}
