* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Courier New', Courier, monospace;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

h1 {
  font-size: 1.3rem;
  color: #e94560;
}

/* Game Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  flex-shrink: 0;
  background: #16213e;
  border-bottom: 2px solid #0f3460;
}

.back-link {
  color: #e0e0e0;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 4px 10px;
  background: #0f3460;
  border-radius: 4px;
}

.restart-btn {
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  font-family: 'Courier New', monospace;
}

.restart-btn:hover {
  background: #c73650;
}

/* Game Area */
#game-area-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #4a7dd9;
}

#game-canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

/* HUD */
#hud {
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
  pointer-events: none;
}

#lives-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

#ball-icon {
  width: 20px;
  height: 20px;
}

#lives-text {
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

#score-display {
  display: flex;
  gap: 2px;
}

#score {
  font-size: 1.4rem;
  font-weight: bold;
  color: #f5c542;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.7), 0 0 8px rgba(245, 197, 66, 0.3);
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
}

#level-display {
  font-size: 0.9rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
  background: rgba(0,0,0,0.3);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Controls */
#controls {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 10;
}

#dir-controls {
  display: flex;
  gap: 8px;
}

.ctrl-jump {
  margin-bottom: 0;
}

.ctrl-btn {
  width: 60px;
  height: 50px;
  background: rgba(74, 125, 217, 0.5);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active, .ctrl-btn.active {
  background: rgba(245, 197, 66, 0.5);
  border-color: rgba(255,255,255,0.6);
  transform: scale(0.93);
}

.ctrl-jump {
  width: 70px;
  height: 50px;
  font-size: 1.2rem;
}

/* Overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 46, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.overlay-content {
  text-align: center;
  padding: 30px;
}

.overlay-content h2 {
  font-size: 1.8rem;
  color: #e94560;
  margin-bottom: 12px;
  font-family: 'Courier New', monospace;
}

.overlay-content p {
  font-size: 0.95rem;
  color: #e0e0e0;
  margin-bottom: 18px;
  font-family: 'Courier New', monospace;
}

.hidden {
  display: none;
}

@media (max-width: 480px) {
  .game-header {
    padding: 3px 6px;
  }

  #controls {
    bottom: 8px;
    left: 8px;
    right: 8px;
  }

  .ctrl-btn {
    width: 50px;
    height: 44px;
    font-size: 1.2rem;
  }

  .ctrl-jump {
    width: 60px;
    height: 44px;
    font-size: 1rem;
  }

  #score {
    font-size: 1.1rem;
  }
}
