/* Google Font: Press Start 2P for retro title screen */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ============================================================
   CS50 Candy-Color Lecture Stage — SEGA Tetris
   Deep black stage + high-saturation candy accent colors
   ============================================================ */

/* ─── RESET & BASE ──────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body {
  background: #0A0A0A;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #CCCCCC;
  overflow: hidden;
  position: relative;
}

/* ─── THREE.JS 3D SPACE BACKGROUND ──────────── */
#three-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* ─── 3D WIREFRAME TITLE ──────────────────── */
#title-3d {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
  perspective: 700px;
  perspective-origin: 50% 40%;
}
#title-3d.active { display: flex; }

#title-3d .t3d-letter {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 64px;
  font-weight: 400;
  color: transparent;
  -webkit-text-stroke: 2.5px #FF44FF;
  text-stroke: 2.5px #FF44FF;
  text-shadow:
    0px 1px 0px rgba(255,68,255,0.40),
    1px 2px 0px rgba(255,68,255,0.22),
    2px 3px 0px rgba(255,68,255,0.12),
    3px 4px 0px rgba(255,68,255,0.06),
    0px 0px 20px rgba(255,68,255,0.12);
  letter-spacing: 6px;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  backface-visibility: hidden;
}
#title-3d .t3d-letter.space {
  display: inline-block;
  width: 28px;
}

#title-3d .t3d-sub {
  position: absolute;
  bottom: 28%;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: rgba(255,255,255,0.12);
  letter-spacing: 3px;
  opacity: 0;
  animation: t3dSubFadeIn 1s ease-out 2.2s forwards;
}
#title-3d .t3d-sub.blink {
  animation: t3dSubFadeIn 1s ease-out 2.2s forwards, pressAnyBlink 1.8s ease-in-out 4s infinite;
}
@keyframes t3dSubFadeIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes pressAnyBlink {
  0%, 100% { opacity: 1; color: rgba(255,255,255,0.12); }
  50% { opacity: 1; color: rgba(255,68,255,0.8); }
}

/* Mobile wireframe title sizing */
@media (max-width: 768px) {
  #title-3d .t3d-letter {
    font-size: 32px;
    -webkit-text-stroke: 1.5px #FF44FF;
    text-stroke: 1.5px #FF44FF;
    letter-spacing: 3px;
  }
  #title-3d .t3d-letter.space { width: 14px; }
  #title-3d .t3d-sub { font-size: 7px; bottom: 32%; letter-spacing: 1.5px; }
  #title-3d .t3d-sub.blink { animation: t3dSubFadeIn 1s ease-out 2.2s forwards, pressAnyBlink 1.8s ease-in-out 4s infinite; }
}
#three-bg canvas {
  display: block;
  width: 100vw !important;
  height: 100vh !important;
}

/* ─── WARP SPEED OVERLAY (bloom-like light) ── */
#warp-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.05s linear, background 0.1s ease;
}

/* ─── GAME WRAPPER (stage — frosted glass) ── */
#game-wrapper {
  position: relative;
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 32px;
  background: rgba(10,10,10,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.04);
  transition: background 0.3s ease;
}

/* ─── SIDE PANELS ─────────────────────────── */
#side-left, #side-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 120px;
  padding-top: 4px;
}

.panel {
  background: rgba(15,15,15,0.12);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 14px 10px;
  text-align: center;
  position: relative;
}

.panel-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: rgba(255,255,255,0.50);
  margin-bottom: 8px;
  font-weight: 600;
}

/* ─── CANDY-COLORED VALUE TEXT ─────────────── */
.panel-value {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-shadow: 0 0 20px rgba(0,0,0,0.6);
}
.panel-value.small { font-size: 20px; }

/* Score = Magenta */
#score-display, #high-display {
  color: #FF44FF;
}
/* Level = Cyan */
#level-display {
  color: #00FFFF;
}
/* Lines = Yellow */
#lines-display {
  color: #FFFF00;
}

/* ─── MINI-BOARD (hold / next) ─────────────── */
.mini-board {
  display: grid;
  grid-template-columns: repeat(4, 20px);
  grid-template-rows: repeat(4, 20px);
  gap: 2px;
  margin: 4px auto;
  width: 86px;
  justify-content: center;
}
.mini-board .cell {
  width: 20px; height: 20px;
  border-radius: 2px;
  background: rgba(255,255,255,0.03);
}
.mini-board .cell.filled {
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: none;
}

/* ─── BOARD WRAP (stage center — frosted glass) ── */
#board-wrap {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(13,13,13,0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

canvas#game {
  display: block;
  width: 300px; height: 600px;
  position: relative;
  z-index: 1;
}

/* ─── OVERLAY (title / game over) ──────────── */
#overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  z-index: 9;
}
#overlay.show { display: flex; }

#overlay h1 {
  font-size: 36px;
  font-weight: 900;
  color: #FF44FF;
  margin-bottom: 10px;
  letter-spacing: 4px;
}
#overlay h1.win {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  font-weight: 400;
  color: #FF44FF;
  letter-spacing: 2px;
  margin-bottom: 16px;
  text-shadow: 0 0 30px rgba(255,68,255,0.12);
  white-space: nowrap;
}
/* Stage accent line under title */
#overlay h1.win::after {
  content: '';
  display: block;
  width: 48px;
  height: 2px;
  background: rgba(255,68,255,0.20);
  margin: 12px auto 0;
}
#overlay .sub {
  font-size: 13px;
  color: #777777;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

/* ─── BUTTONS ──────────────────────────────── */
.btn {
  background: #1A1A1A;
  border: 1px solid rgba(255,255,255,0.10);
  color: #CCCCCC;
  padding: 10px 32px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 600;
  letter-spacing: 1px;
  font-family: inherit;
}
.btn:hover {
  background: #222222;
  border-color: rgba(255,255,255,0.20);
  color: #FFFFFF;
}
.btn:active { transform: scale(0.97); }

.btn.start-btn {
  animation: btnBlink 1.2s ease-in-out infinite;
}

@keyframes btnBlink {
  0%, 100% { opacity: 1; border-color: rgba(255,255,255,0.10); }
  50% { opacity: 0.6; border-color: rgba(255,255,255,0.25); }
}

/* ─── HUD (in-panel stats) ────────────────── */
#hud-score { font-size: 13px; }
.hud-label {
  font-size: 10px;
  color: #444;
  letter-spacing: 1px;
}
.hud-number {
  font-size: 26px;
  font-weight: 700;
  color: #FF44FF;
  font-variant-numeric: tabular-nums;
}

/* ─── CONTROLS HINT ───────────────────────── */
#controls-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 11px;
  color: #444;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
#controls-hint span { color: #666; margin: 0 4px; }

/* ─── TITLE STORY ─────────────────────────── */
#title-story {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  overflow: hidden;
  z-index: 11;
  pointer-events: none;
}
#title-story.active { display: flex; }
#title-story .story-scroll {
  position: absolute;
  left: 16px; right: 16px;
  top: 100%;
  animation: storyScroll 70s linear infinite;
}
@keyframes storyScroll {
  0% { transform: translateY(0); }
  100% { transform: translateY(-100%); }
}
#title-story .story-text {
  font-size: 12px;
  line-height: 1.85;
  color: #666;
  text-align: left;
  letter-spacing: 0.4px;
  white-space: pre-wrap;
}
#title-story .story-title {
  font-size: 14px;
  font-weight: 800;
  color: #FF44FF;
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: 2px;
}

/* ─── KEYFRAMES ───────────────────────────── */
@keyframes overlayFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes titlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes slideIn {
  0% { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}
.mini-board.slide-in { animation: slideIn 0.2s ease-out; }
#overlay.show { animation: overlayFadeIn 0.8s ease-out; }
#overlay h1.win { animation: titlePulse 2s ease-in-out infinite; }

/* ─── HUD ANIMATIONS ──────────────────────── */
@keyframes scoreBounce {
  0% { transform: scale(1); }
  25% { transform: scale(1.18); color: #FFFFFF; }
  55% { transform: scale(0.94); }
  100% { transform: scale(1); }
}
@keyframes linesPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.35); color: #FFFF00; }
  100% { transform: scale(1); }
}
@keyframes levelFlash {
  0% { opacity: 0; }
  8% { opacity: 0.85; }
  30% { opacity: 0.55; }
  100% { opacity: 0; }
}
@keyframes comboFadeUp {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  15% { transform: translateY(-20px) scale(1.15); opacity: 1; }
  40% { transform: translateY(-18px) scale(1); opacity: 1; }
  100% { transform: translateY(-50px) scale(0.75); opacity: 0; }
}
@keyframes levelUpText {
  0% { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
  20% { transform: translate(-50%,-50%) scale(1.15); opacity: 1; }
  50% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
}
.anim-score { animation: scoreBounce 0.35s ease-out; }
.anim-lines { animation: linesPop 0.40s ease-out; }

#level-flash {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255,255,255,0.85);
  pointer-events: none; z-index: 5;
  opacity: 0; border-radius: 4px;
}
#level-flash.active { animation: levelFlash 0.4s ease-out; }
#level-flash .level-text {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 28px; font-weight: 900;
  color: #FFFF00;
  letter-spacing: 3px; white-space: nowrap;
}
#level-flash.active .level-text {
  animation: levelUpTextSEGA 1s ease-out;
}

/* ─── COMBO POPUP ─────────────────────────── */
#combo-pop {
  position: absolute;
  font-size: 14px; font-weight: 800;
  color: #FFFF00;
  pointer-events: none; z-index: 6;
}
#combo-pop.active { animation: comboFadeUp 0.70s ease-out forwards; }

/* ─── SCREEN SHAKE ────────────────────────── */
@keyframes shake-soft {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-2px,2px); }
  50% { transform: translate(2px,-1px); }
  75% { transform: translate(-1px,2px); }
}
@keyframes shake-medium {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-4px,3px); }
  30% { transform: translate(3px,-4px); }
  45% { transform: translate(-3px,2px); }
  60% { transform: translate(4px,-2px); }
  75% { transform: translate(-2px,3px); }
  90% { transform: translate(2px,-3px); }
}
@keyframes shake-strong {
  0%,100% { transform: translate(0,0); }
  12% { transform: translate(-6px,4px); }
  25% { transform: translate(5px,-6px); }
  37% { transform: translate(-4px,5px); }
  50% { transform: translate(6px,-3px); }
  62% { transform: translate(-5px,4px); }
  75% { transform: translate(3px,-6px); }
  87% { transform: translate(-4px,5px); }
}
.shake-soft { animation: shake-soft ease-out; }
.shake-medium { animation: shake-medium ease-out; }
.shake-strong { animation: shake-strong ease-out; }

/* ─── HOLD PANEL ──────────────────────────── */
#hold-panel { position: relative; }
.hold-overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  border-radius: 5px;
  display: none;
  pointer-events: none;
}
.hold-overlay.active { display: block; }

/* ─── GAME OVER EFFECTS ───────────────────── */
@keyframes gameOverRedFlash {
  0% { opacity: 0; }
  8% { opacity: 0.7; }
  20% { opacity: 0.4; }
  40% { opacity: 0.15; }
  100% { opacity: 0; }
}
@keyframes gameOverNeonPulse {
  0% { opacity: 0; color: #FF2244; }
  15% { opacity: 1; }
  30% { opacity: 0.6; }
  50% { opacity: 1; }
  70% { opacity: 0.7; }
  100% { opacity: 1; }
}
@keyframes gameOverScoreIn {
  0% { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}
#game-over-red-flash {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, rgba(200,0,0,0.5) 0%, rgba(200,0,0,0.2) 60%, transparent 100%);
  pointer-events: none; z-index: 3;
  opacity: 0;
}
#game-over-red-flash.active { animation: gameOverRedFlash 1.0s ease-out; }
#game-over-neon-wrap {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none; z-index: 7;
  opacity: 0;
}
#game-over-neon-wrap.active { opacity: 1; transition: opacity 0.3s ease; }
#game-over-neon-wrap .go-title {
  font-size: 32px; font-weight: 900;
  color: #FF2244;
  letter-spacing: 5px;
  opacity: 0;
}
#game-over-neon-wrap .go-title.active { animation: gameOverNeonPulse 2s ease-out forwards; }
#game-over-neon-wrap .go-score {
  font-size: 16px; font-weight: 700;
  color: #CCCCCC;
  margin-top: 14px;
  opacity: 0;
}
#game-over-neon-wrap .go-score.active { animation: gameOverScoreIn 1.0s ease-out 0.8s forwards; }

/* ─── LEVEL-UP EDGE GLOW ──────────────────── */
@keyframes edgeGlowPulse {
  0% { opacity: 0; }
  8% { opacity: 0.6; }
  25% { opacity: 0.4; }
  60% { opacity: 0.15; }
  100% { opacity: 0; }
}
#level-up-edge-glow {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 4;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,68,255,0.35) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(0,255,255,0.35) 0%, transparent 50%);
  opacity: 0;
}
#level-up-edge-glow.active { animation: edgeGlowPulse 1.2s ease-out; }

/* ─── PAUSE OVERLAY ───────────────────────── */
#pause-overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.90);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  z-index: 10;
}
#pause-overlay.show { display: flex; }
.pause-title {
  font-size: 30px; font-weight: 900;
  color: #FFFF00;
  letter-spacing: 5px;
  margin-bottom: 24px;
}
.pause-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.pause-btn {
  background: #1A1A1A;
  border: 1px solid rgba(255,255,255,0.10);
  color: #CCCCCC;
  padding: 10px 36px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 200px;
  font-family: inherit;
}
.pause-btn:hover {
  background: #222222;
  border-color: rgba(255,255,255,0.20);
  color: #FFFFFF;
}
.pause-btn:active { transform: scale(0.96); }
.pause-btn.danger { border-color: rgba(255,68,68,0.15); color: #FF6666; }
.pause-btn.danger:hover {
  background: #2A1A1A;
  border-color: rgba(255,68,68,0.30);
  color: #FF8888;
}

/* ─── SETTINGS OVERLAY ────────────────────── */
#settings-overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.92);
  display: none;
  flex-direction: column;
  border-radius: 4px;
  z-index: 12;
  padding: 16px 14px;
  overflow-y: auto;
}
#settings-overlay.show { display: flex; }
.st-title {
  font-size: 16px; font-weight: 900;
  color: #FFFF00;
  text-align: center;
  letter-spacing: 3px;
  margin-bottom: 10px;
}
.st-section {
  font-size: 10px; color: #555;
  letter-spacing: 2px; font-weight: 700;
  margin: 8px 0 4px 6px;
}
.st-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  margin: 2px 0;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
}
.st-row .st-label { font-size: 12px; color: #999; letter-spacing: 0.5px; }
.st-row .st-key {
  font-size: 12px; font-weight: 600;
  color: #CCCCCC;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 4px;
  padding: 3px 10px;
  min-width: 50px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.st-row .st-key:hover {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #FFF;
}
.st-row .st-key.listening {
  border-color: #FFFF00;
  background: rgba(255,255,0,0.10);
  color: #FFFF00;
  animation: btnBlink 0.4s ease-in-out infinite;
}
.st-row .st-key.gamepad { min-width: 35px; padding: 3px 6px; }
.st-btns { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.st-btn {
  background: #1A1A1A;
  border: 1px solid rgba(255,255,255,0.10);
  color: #CCCCCC;
  padding: 7px 20px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
  font-family: inherit;
}
.st-btn:hover {
  background: #222;
  border-color: rgba(255,255,255,0.20);
  color: #FFF;
}
.st-btn:active { transform: scale(0.96); }
.st-btn.danger { border-color: rgba(255,68,68,0.15); color: #FF6666; }
.st-btn.danger:hover {
  background: #2A1A1A;
  border-color: rgba(255,68,68,0.30);
  color: #FF8888;
}
.st-note {
  font-size: 10px;
  color: rgba(255,255,255,0.15);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 0.5px;
}
.kd-symbol { font-size: 11px; font-weight: 400; color: rgba(255,255,255,0.15); margin-left: 3px; }

/* ─── SCORE BREAKDOWN ─────────────────────── */
.score-bd { margin: 10px auto 8px; width: 90%; text-align: left; }
.bd-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 6px;
  font-size: 12px;
  color: #888;
  letter-spacing: 0.5px;
}
.bd-value { color: #CCCCCC; font-weight: 600; font-variant-numeric: tabular-nums; }
.bd-total { border-top: 1px solid rgba(255,255,255,0.10); margin-top: 2px; padding-top: 5px; font-size: 13px; }
.bd-total .bd-label { color: #AAAAAA; font-weight: 700; }
.bd-total .bd-value { color: #FF44FF; }

/* ─── NEW HIGH SCORE ──────────────────────── */
@keyframes hsGlow {
  0%,100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.hs-badge {
  font-size: 13px; font-weight: 800;
  color: #FFFF00;
  letter-spacing: 2px;
  margin-bottom: 6px;
  animation: hsGlow 0.6s ease-in-out infinite;
  text-align: center;
}

/* ─── LEADERBOARD ─────────────────────────── */
.lb-wrap { margin: 6px auto 0; width: 90%; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 6px; }
.lb-title { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: #555; font-weight: 700; margin-bottom: 4px; text-align: center; }
.lb-entry { display: flex; justify-content: space-between; padding: 1px 6px; font-size: 11px; color: #777; font-variant-numeric: tabular-nums; }
.lb-entry .lb-rank { color: #555; width: 18px; text-align: right; margin-right: 6px; }
.lb-entry .lb-name { color: #999; width: 50px; }
.lb-entry .lb-score { color: #CCCCCC; font-weight: 600; text-align: right; flex: 1; }
.lb-entry.lb-current { background: rgba(255,68,255,0.06); border-radius: 3px; }
.lb-entry.lb-current .lb-score { color: #FF44FF; }

/* ─── NAME ENTRY ──────────────────────────── */
.ne-wrap { margin: 4px auto; text-align: center; }
.ne-label { font-size: 11px; color: #777; letter-spacing: 0.5px; margin-bottom: 4px; }
.ne-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  color: #CCCCCC;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
  width: 60px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 700;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.ne-input:focus { border-color: rgba(255,255,0,0.4); }
.ne-btn {
  display: inline-block;
  margin-top: 4px;
  background: #1A1A1A;
  border: 1px solid rgba(255,255,255,0.10);
  color: #CCCCCC;
  padding: 4px 16px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
}
.ne-btn:hover { background: #222; border-color: rgba(255,255,255,0.20); color: #FFF; }
/* overlay-hint removed per user request */

/* ─── HINT CONTAINER ──────────────────────── */
.hint-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  transition: opacity 0.25s ease;
}
.panel-hint {
  font-size: 9px;
  color: rgba(255,255,255,0.30);
  letter-spacing: 0.4px;
  line-height: 2;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 7px;
  margin-top: 3px;
}
.panel-hint kbd {
  display: inline-block;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 2px;
  padding: 0 5px;
  font: 8px/1.6 'Courier New', monospace;
  color: rgba(255,255,255,0.45);
  vertical-align: middle;
  margin: 0 1px;
}
.hint-toggle {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.12);
  border-radius: 2px;
  cursor: pointer;
  font-size: 7px;
  padding: 1px 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1.2;
  font-family: inherit;
}
.hint-toggle:hover {
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.30);
}
.hint-container.collapsed .hint-text {
  opacity: 0; max-height: 0; overflow: hidden; margin: 0; padding: 0; pointer-events: none;
}
.hint-container.collapsed .panel-hint { border: none; padding: 0; margin: 0; }
.hint-container .hint-text {
  transition: opacity 0.3s ease, max-height 0.3s ease;
  overflow: hidden; max-height: 120px;
}

/* ─── JOYSTICK ICON ───────────────────────── */
.joystick-icon {
  position: relative; width: 16px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.35;
}
.joystick-icon .stick-base {
  position: absolute; bottom: 1px; left: 50%;
  transform: translateX(-50%);
  width: 5px; height: 11px;
  background: linear-gradient(180deg, #555, #222);
  border-radius: 0 0 2px 2px; z-index: 1;
}
.joystick-icon .stick-ball {
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 11px; height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FF6677, #881122);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.4);
  z-index: 2;
  border: 1px solid rgba(255,100,100,0.10);
}
.hint-simple .joystick-icon { opacity: 0.15; }
.hint-simple .panel-hint { font-size: 8px; color: rgba(255,255,255,0.10); }
.hint-simple kbd { color: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.03); background: transparent; }

/* ─── LEVEL-UP TEXT ANIMATION ─────────────── */
@keyframes levelUpTextSEGA {
  0% { transform: translate(-50%,-50%) scale(0.1) rotate(-6deg); opacity: 0; }
  18% { transform: translate(-50%,-50%) scale(1.35) rotate(3deg); opacity: 1; }
  28% { transform: translate(-50%,-50%) scale(0.92) rotate(-1deg); opacity: 1; }
  42% { transform: translate(-50%,-50%) scale(1.08) rotate(1deg); opacity: 1; }
  55% { transform: translate(-50%,-50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.7); opacity: 0; }
}

/* ============================================================
   MOBILE LAYOUT — responsive, touch-friendly
   ============================================================ */
#mobile-controls { display: none; }

@media (max-width: 768px) {
  #side-left, #side-right, .hint-container { display: none !important; }

  #game-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px;
    max-width: 100vw;
    max-height: 100vh;
    justify-content: flex-start;
  }

  #board-wrap {
    max-width: calc(100vw - 16px);
    max-height: calc(50vh - 8px);
  }

  canvas#game {
    width: min(300px, calc(100vw - 16px));
    height: min(600px, calc(100vw * 2 - 32px));
    max-height: calc(50vh - 16px);
  }

  #mobile-hud {
    display: flex !important;
    width: min(300px, calc(100vw - 16px));
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: #0F0F0F;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 4px;
    gap: 4px;
  }
  #mobile-hud .mh-item { text-align: center; flex: 1; min-width: 0; }
  #mobile-hud .mh-label {
    font-size: 8px; color: #555;
    text-transform: uppercase; letter-spacing: 0.5px;
    line-height: 1.2;
  }
  #mobile-hud .mh-value {
    font-size: 13px; font-weight: 700;
    color: #FF44FF;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
  }
  #mobile-hud .mh-item:nth-child(2) .mh-value { color: #00FFFF; }
  #mobile-hud .mh-item:nth-child(3) .mh-value { color: #FFFF00; }
  #mobile-hud .mh-item:nth-child(4) .mh-value { color: #999; font-weight: 600; }

  #mobile-controls {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: min(320px, calc(100vw - 16px));
    margin-top: 2px;
    padding-bottom: env(safe-area-inset-bottom, 8px);
  }

  .mc-dpad-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
  }
  .mc-btn {
    width: 52px; height: 52px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #AAAAAA;
    font-size: 22px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    transition: background 0.08s, transform 0.08s;
  }
  .mc-btn:active, .mc-btn.pressed {
    background: rgba(255,255,255,0.10);
    transform: scale(0.92);
    border-color: rgba(255,255,255,0.20);
  }

  .mc-action-row { display: flex; justify-content: center; gap: 5px; }
  .mc-action-btn {
    width: 60px; height: 42px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #AAAAAA;
    font-size: 10px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    transition: background 0.08s, transform 0.08s;
    letter-spacing: 0.5px;
  }
  .mc-action-btn:active, .mc-action-btn.pressed {
    background: rgba(255,255,255,0.10);
    transform: scale(0.92);
    border-color: rgba(255,255,255,0.20);
  }

  .mc-btn-rotate { color: #CC66FF; }
  .mc-btn-rotate:active, .mc-btn-rotate.pressed { background: rgba(200,100,255,0.08); }
  .mc-btn-drop { color: #FF6666; }
  .mc-btn-drop:active, .mc-btn-drop.pressed { background: rgba(255,100,100,0.08); }
  .mc-btn-hold { color: #66DDAA; }
  .mc-btn-hold:active, .mc-btn-hold.pressed { background: rgba(100,220,170,0.08); }

  .mc-pause-btn {
    position: absolute; top: 4px; right: 4px;
    width: 30px; height: 30px; border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.5);
    color: #666;
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mc-pause-btn:active { background: rgba(255,255,255,0.08); }
  #board-wrap { position: relative; }

  /* Mobile text sizing */
  #overlay h1 { font-size: 26px; }
  .btn { font-size: 13px; padding: 8px 24px; }
  .panel-value { font-size: 22px; }
  .panel-value.small { font-size: 18px; }
  .panel-title { font-size: 9px; }
  .pause-title { font-size: 22px; }
  .pause-btn { min-width: 160px; font-size: 12px; padding: 8px 24px; }
  .st-title { font-size: 14px; }
  .st-row .st-label { font-size: 11px; }
  .st-row .st-key { font-size: 11px; min-width: 40px; }
  #title-story .story-text { font-size: 11px; }
  #title-story .story-title { font-size: 12px; }
  #mobile-hud { display: none; }
  #game-over-neon-wrap .go-title { font-size: 24px; }
  #game-over-neon-wrap .go-score { font-size: 14px; }
  .hs-badge { font-size: 11px; }
  .bd-row { font-size: 11px; }
  /* overlay-hint removed per user request */
  #combo-pop { font-size: 13px; }
  .score-bd { margin: 6px auto; }
  .lb-entry { font-size: 10px; }
}
