* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #020306; }
body { font-family: 'Nunito', sans-serif; color: #eafcff; display: flex; align-items: center; justify-content: center; height: 100vh; height: 100svh; touch-action: none; }

#game-root { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, #0a1420 0%, #020306 70%); }

#game-canvas {
  display: block; aspect-ratio: 16 / 9;
  width: min(98vw, calc(80svh * 16 / 9)); height: auto; max-height: 80svh;
  background: #05060a; border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 3px #05060a, 0 0 0 6px #143a4a, 0 0 24px rgba(80,220,255,0.12);
  image-rendering: pixelated;
}

.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 0; z-index: 20; pointer-events: none; }
.hud.hidden { display: none; }
.hud-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; pointer-events: auto; width: min(98vw, calc(80svh * 16 / 9)); }
.hud-chips { display: flex; align-items: center; gap: 6px; }
.hud-chip { background: rgba(5,6,10,0.78); border: 1px solid rgba(80,220,255,0.35); border-radius: 14px; padding: 5px 12px; font-size: 0.8rem; font-weight: 800; color: #8fe8ff; }
.hud-chip.combo { color: #c9a8ff; border-color: rgba(201,168,255,0.4); }
.hud-chip.hidden { display: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18); background: rgba(5,6,10,0.78); color: #fff; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.icon-btn:active { transform: scale(0.92); }

.grade-flash { font-family: 'Press Start 2P', monospace; font-size: 0.85rem; color: #ffd24a; text-shadow: 0 0 10px rgba(255,210,74,0.7); opacity: 0; transition: opacity 0.15s; }
.grade-flash.show { opacity: 1; }

.jump-surface { position: absolute; inset: 0; z-index: 15; background: transparent; border: none; }
.jump-surface.hidden { display: none; }

.screen { position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 16px; }
.screen.active { display: flex; }
.overlay-screen { background: rgba(2,3,6,0.85); backdrop-filter: blur(3px); }

.title-card, .panel-card { width: min(92vw, 440px); max-height: 90vh; overflow-y: auto; background: linear-gradient(180deg, #0c1a26, #060d16); border: 3px solid #2a7a9a; border-radius: 16px; padding: 26px 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,0.55), 0 0 26px rgba(80,220,255,0.1); }

.title-runner { width: 18px; height: 26px; background: #ffffff; border-radius: 5px; box-shadow: 0 0 16px #ffffff, 0 0 30px rgba(80,220,255,0.6); }
.game-title { font-family: 'Press Start 2P', monospace; font-size: 1.1rem; color: #8fe8ff; text-shadow: 0 0 12px rgba(80,220,255,0.6); text-align: center; }
.subtitle { font-size: 0.9rem; opacity: 0.8; margin-top: -6px; color: #c9a8ff; }

.menu-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.btn-pixel { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 0.95rem; padding: 13px 18px; border-radius: 10px; border: none; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,0.35); letter-spacing: 0.01em; }
.btn-pixel:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.btn-primary { background: linear-gradient(180deg,#8fe8ff,#3fa9ff); color: #052030; }
.btn-secondary { background: linear-gradient(180deg,#8a6fd9,#5a3a9a); color: #f2eefc; }
.btn-text { background: transparent; color: #9fc8e8; box-shadow: none; font-size: 0.85rem; }

.title-footer { display: flex; align-items: center; justify-content: space-between; width: 100%; font-size: 0.75rem; opacity: 0.65; margin-top: 4px; }
.howto-list { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 0.86rem; line-height: 1.4; }
h2 { font-family: 'Press Start 2P', monospace; font-size: 0.95rem; color: #8fe8ff; text-align: center; }

.chapter-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chapter-tab { padding: 7px 12px; border-radius: 10px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.16); font-size: 0.7rem; font-weight: 700; cursor: pointer; }
.chapter-tab.active { background: #3fa9ff; color: #052030; }

.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; max-height: 40vh; overflow-y: auto; }
.level-tile { aspect-ratio: 1; border-radius: 10px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; cursor: pointer; gap: 2px; font-size: 0.8rem; }
.level-tile.locked { opacity: 0.35; cursor: not-allowed; }
.level-tile .lt-medal { font-size: 0.75rem; }
.levels-card { max-height: 92vh; }

.medal-row { font-size: 2rem; }
.results-score-val { font-family: 'Press Start 2P', monospace; font-size: 1.6rem; color: #8fe8ff; }
.result-detail { font-size: 0.85rem; opacity: 0.85; }

.nn-score-nudge { background: rgba(255,255,255,0.08); border-radius: 10px; padding: 10px; width: 100%; text-align: center; font-size: 0.85rem; }
.nn-nudge-btns { display: flex; gap: 8px; margin-top: 8px; justify-content: center; }
.nn-nudge-signup { background: #3fa9ff; color: #052030; padding: 8px 14px; border-radius: 8px; text-decoration: none; font-weight: 800; font-size: 0.8rem; }
.nn-nudge-later { background: transparent; border: 1px solid rgba(255,255,255,0.3); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 0.8rem; }
