@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323:wght@400&display=swap');

  :root {
    --yellow: #F5C800;
    --orange: #E84A1A;
    --dark-orange: #C03A10;
    --black: #1A1008;
    --white: #FFF8E7;
    --red: #CC2200;
    --bg: #F5C800;
    --bg2: #E84A1A;
    --text: #1A1008;
    --panel: rgba(26,16,8,0.92);
    --panel-border: #E84A1A;
  }
  .dark {
    --bg: #1A1008;
    --bg2: #2A1A08;
    --text: #F5C800;
    --panel: rgba(245,200,0,0.12);
    --panel-border: #F5C800;
  }

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

  body {
    font-family: 'Press Start 2P', monospace;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
  }

  canvas { display: block; }

  #app {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  /* SCREENS */
  .screen {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    align-items: center;
    justify-content: center;
    flex-direction: column;
  }
  .screen.active { display: flex; }

  /* DARK MODE TOGGLE */
  #darkToggle {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 1000;
    background: var(--orange);
    border: 3px solid var(--black);
    color: var(--white);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 8px 10px;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--black);
    transition: all 0.1s;
  }
  #darkToggle:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--black); }

  /* TITLE SCREEN */
  #titleScreen {
    background: var(--bg);
  }
  .title-bg {
    position: absolute; top:0;left:0;width:100%;height:100%;
    overflow: hidden;
    z-index: 0;
  }
  .title-stripe {
    position: absolute;
    width: 100%; height: 40%;
    bottom: 0;
    background: var(--orange);
    border-top: 6px solid var(--black);
  }
  .title-dots-left, .title-dots-right {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 10px;
  }
  .title-dots-left { left: 30px; }
  .title-dots-right { right: 30px; }
  .dot {
    width: 12px; height: 12px;
    background: var(--orange);
    border-radius: 0;
  }
  .dark .dot { background: var(--yellow); }

  .title-content {
    position: relative; z-index: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 6px;
    margin-top: -80px;
    transform: scale(1.1);
    transform-origin: center top;
  }
  .title-pod { font-size: 9px; color: var(--orange); letter-spacing: 2px; }
  .dark .title-pod { color: var(--yellow); }
  .title-sub { font-family: 'VT323', monospace; letter-spacing: 3px; font-size: 16px; color: var(--white); background: var(--black); padding: 2px 8px; }
  .dark .title-sub { color: var(--yellow); background: transparent; }
  .title-main {
    font-size: clamp(28px, 5vw, 52px);
    color: var(--orange);
    text-shadow: 4px 4px 0 var(--black), -2px -2px 0 var(--black);
    letter-spacing: 2px;
    line-height: 1.1;
    margin: 0;
    text-align: center;
  }
  .title-main .vs-text {
    display: block;
    font-size: 0.38em;
    color: var(--black);
    text-shadow: none;
    letter-spacing: 4px;
    margin: 2px 0;
  }
  .dark .title-main { color: var(--yellow); }
  .dark .title-main .vs-text { color: var(--orange); }
  .title-vs {
    font-size: 18px;
    color: var(--black);
    background: var(--yellow);
    padding: 4px 12px;
    border: 3px solid var(--black);
  }
  .dark .title-vs { background: var(--orange); color: var(--white); }

  .title-chars {
    display: flex; gap: 60px; align-items: flex-end;
    margin: 20px 0 28px;
  }
  .title-char { display: flex; flex-direction: column; align-items: center; gap: 0; }
  .title-char canvas { border: 3px solid var(--black); background: rgba(0,0,0,0.1); display: block; }
  .dark .title-char canvas { border-color: var(--yellow); box-shadow: 4px 4px 0 var(--yellow); }
  .char-label {
    font-size: 8px;
    background: var(--orange);
    color: var(--white);
    padding: 4px 8px;
    border: 2px solid var(--black);
    border-top: none;
    text-align: center;
  }
  .char-name-label {
    font-size: 11px;
    font-family: 'Press Start 2P', monospace;
    background: var(--black);
    color: var(--yellow);
    padding: 10px 10px 5px;
    border: 2px solid var(--black);
    border-top: none;
    text-align: center;
    width: 100%;
  }
  .dark .char-label { background: var(--black); color: var(--yellow); border-color: var(--yellow); }
  .dark .char-name-label { background: var(--orange); color: var(--black); border-color: var(--orange); }
  .title-vs-badge {
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: var(--white);
    background: var(--orange);
    border: 4px solid var(--black);
    box-shadow: 4px 4px 0 var(--black);
    padding: 8px 14px;
    align-self: center;
    margin-bottom: 40px;
  }
  .dark .title-vs-badge { background: var(--black); color: var(--yellow); border-color: var(--yellow); box-shadow: 4px 4px 0 var(--yellow); }

  .menu-btns {
    display: flex; flex-direction: column; gap: 12px;
    margin-top: 16px;
    align-items: center;
  }
  .btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 14px 28px;
    border: 4px solid var(--black);
    cursor: pointer;
    box-shadow: 5px 5px 0 var(--black);
    transition: all 0.08s;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 220px;
    text-align: center;
  }
  .btn:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--black); }
  .btn-primary { background: var(--orange); color: var(--white); }
  .btn-primary:hover { background: var(--dark-orange); }
  .btn-secondary { background: var(--yellow); color: var(--black); }
  .btn-secondary:hover { background: #d4a800; }
  .btn-ghost { background: var(--black); color: var(--yellow); }
  .btn-ghost:hover { background: #2a2010; }
  .btn-danger { background: var(--red); color: var(--white); }
  .btn-danger:hover { background: #aa1800; }
  .btn-sm { font-size: 9px; padding: 10px 18px; min-width: 160px; }

  /* OVERLAY SCREENS */
  .overlay {
    position: fixed; top:0;left:0;width:100%;height:100%;
    background: rgba(26,16,8,0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
  }
  .overlay.active { display: flex; }
  .overlay-box {
    background: var(--yellow);
    border: 6px solid var(--black);
    box-shadow: 8px 8px 0 var(--black);
    padding: 36px 40px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
  }
  .dark .overlay-box { background: #2A1A08; color: var(--yellow); }
  .overlay-title {
    font-size: 18px;
    color: var(--orange);
    text-shadow: 3px 3px 0 var(--black);
    margin-bottom: 20px;
    text-align: center;
  }
  .dark .overlay-title { color: var(--yellow); }
  .overlay-text {
    font-family: 'VT323', monospace;
    font-size: 20px;
    line-height: 1.7;
    color: var(--black);
    margin-bottom: 10px;
  }
  .dark .overlay-text { color: var(--yellow); }
  .overlay-close {
    margin-top: 24px;
    display: flex;
    justify-content: center;
  }
  .key-badge {
    display: inline-block;
    background: var(--black);
    color: var(--yellow);
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 4px 10px;
    border: 2px solid var(--yellow);
    margin: 0 4px;
  }
  .dark .key-badge { background: var(--orange); color: var(--black); border-color: var(--black); }

  /* CHARACTER SELECT */
  #charSelect {
    background: var(--bg);
  }
  .char-select-grid {
    display: flex; gap: 32px; margin: 24px 0;
    flex-wrap: wrap; justify-content: center;
  }
  .char-card {
    border: 4px solid var(--black);
    box-shadow: 5px 5px 0 var(--black);
    padding: 20px;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    background: var(--white);
    transition: all 0.1s;
    min-width: 140px;
  }
  .dark .char-card { background: #2a1a08; }
  .char-card:hover { transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--black); }
  .char-card.selected { background: var(--yellow); border-color: var(--orange); }
  .dark .char-card.selected { background: var(--orange); }
  .char-card.locked { opacity: 0.5; cursor: not-allowed; }
  .char-name { font-size: 9px; color: var(--black); }
  .dark .char-name { color: var(--yellow); }
  .char-flavor { font-family: 'VT323', monospace; font-size: 15px; color: var(--orange); text-align: center; }
  .lock-icon { font-size: 20px; }

  /* GAME SCREEN */
  #gameScreen {
    background: var(--bg);
    padding: 0;
    overflow: hidden;
  }
  #gameCanvas {
    border: 4px solid var(--black);
    box-shadow: 6px 6px 0 var(--black);
    display: block;
    image-rendering: pixelated;
  }
  .dark #gameCanvas {
    border-color: var(--yellow);
    box-shadow: 6px 6px 0 var(--yellow);
  }

  /* GAME OVER */
  #gameOverScreen { background: var(--bg); }
  .go-score-box {
    background: var(--black);
    border: 4px solid var(--orange);
    padding: 24px 40px;
    margin: 16px 0;
    text-align: center;
  }
  .go-label { font-size: 8px; color: var(--yellow); margin-bottom: 8px; }
  .go-value { font-size: 32px; color: var(--orange); text-shadow: 3px 3px 0 var(--red); }
  .go-new-best {
    font-size: 10px;
    color: var(--yellow);
    background: var(--orange);
    padding: 6px 14px;
    border: 2px solid var(--yellow);
    margin-top: 8px;
    display: none;
  }

  /* LEADERBOARD */
  #leaderboardScreen { background: var(--bg); overflow-y: auto; }
  .lb-table {
    width: 100%; max-width: 500px;
    border-collapse: collapse;
    margin: 16px 0;
  }
  .lb-table th {
    background: var(--black);
    color: var(--yellow);
    font-size: 9px;
    padding: 10px 14px;
    text-align: left;
    border: 2px solid var(--orange);
  }
  .lb-table td {
    font-family: 'VT323', monospace;
    font-size: 20px;
    padding: 8px 14px;
    border: 2px solid var(--black);
    background: var(--white);
    color: var(--black);
  }
  .dark .lb-table td { background: #2a1a08; color: var(--yellow); }
  .lb-table tr.highlight td { background: var(--yellow); color: var(--black); }
  .dark .lb-table tr.highlight td { background: var(--orange); color: var(--white); }
  .lb-rank-1 td { border-left: 4px solid gold; }
  .lb-rank-2 td { border-left: 4px solid silver; }
  .lb-rank-3 td { border-left: 4px solid #cd7f32; }

  /* NICKNAME MODAL */
  #nickModal {
    position: fixed; top:0;left:0;width:100%;height:100%;
    background: rgba(26,16,8,0.9);
    display: none; align-items: center; justify-content: center;
    z-index: 900;
  }
  #nickModal.active { display: flex; }
  .nick-box {
    background: var(--yellow);
    border: 6px solid var(--black);
    box-shadow: 8px 8px 0 var(--black);
    padding: 36px;
    text-align: center;
    max-width: 420px; width: 90%;
  }
  .dark .nick-box { background: #2a1a08; color: var(--yellow); }
  .nick-title { font-size: 14px; color: var(--orange); margin-bottom: 16px; }
  .nick-subtitle { font-family: 'VT323', monospace; font-size: 18px; color: var(--black); margin-bottom: 20px; }
  .dark .nick-subtitle { color: var(--yellow); }
  #nickInput {
    font-family: 'Press Start 2P', monospace;
    font-size: 22px;
    width: 180px;
    padding: 10px;
    border: 4px solid var(--black);
    background: var(--black);
    color: var(--yellow);
    text-align: center;
    letter-spacing: 8px;
    text-transform: uppercase;
    margin-bottom: 20px;
    display: block;
    margin: 0 auto 20px;
  }
  #nickInput:focus { outline: none; border-color: var(--orange); }

  /* PAUSE */
  #pauseOverlay {
    position: fixed; top:0;left:0;width:100%;height:100%;
    background: rgba(26,16,8,0.85);
    display: none; align-items: center; justify-content: center;
    z-index: 600;
  }
  #pauseOverlay.active { display: flex; }
  .pause-box {
    background: var(--yellow);
    border: 6px solid var(--black);
    box-shadow: 8px 8px 0 var(--black);
    padding: 40px;
    text-align: center;
    min-width: 300px;
  }
  .dark .pause-box { background: #2a1a08; }
  .pause-title { font-size: 22px; color: var(--orange); margin-bottom: 28px; }
  .pause-btns { display: flex; flex-direction: column; gap: 12px; }

  /* PIXEL FLOWER decoration */
  .pixel-flower {
    position: absolute;
    font-size: 28px;
    pointer-events: none;
    opacity: 0.7;
  }

  /* SETTINGS */
  .settings-row {
    display: flex; align-items: center; justify-content: space-between;
    margin: 14px 0;
    gap: 16px;
  }
  .settings-label { font-family: 'VT323', monospace; font-size: 20px; color: var(--black); }
  .dark .settings-label { color: var(--yellow); }
  .toggle-switch {
    width: 52px; height: 28px;
    background: var(--black);
    border: 3px solid var(--black);
    cursor: pointer;
    position: relative;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  }
  .toggle-switch::after {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    background: var(--yellow);
    top: 2px; left: 2px;
    transition: left 0.15s;
  }
  .toggle-switch.on::after { left: 26px; background: var(--orange); }
  .toggle-switch.on { background: #333; }

  .screen-title {
    font-size: clamp(14px,2.5vw,22px);
    color: var(--orange);
    text-shadow: 3px 3px 0 var(--black);
    margin-bottom: 20px;
    text-align: center;
  }
  .dark .screen-title { color: var(--yellow); }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 8px; }
  ::-webkit-scrollbar-track { background: var(--black); }
  ::-webkit-scrollbar-thumb { background: var(--orange); }

  /* Scanlines effect */
  body::after {
    content: '';
    position: fixed;
    top:0;left:0;width:100%;height:100%;
    background: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0,0,0,0.04) 3px,
      rgba(0,0,0,0.04) 4px
    );
    pointer-events: none;
    z-index: 9999;
  }