* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}

body {
  background: #111;
  color: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#game-root {
  position: relative;
  width: 740px;
  height: 600px;
  background: #000;
  border: 2px solid #444;
  overflow: hidden;
  margin: 40px auto;
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.hud-item {
  font-size: 14px;
}

/* Game Area */
#game-area {
  position: absolute;
  top: 40px; /* debajo del HUD */
  left: 0;
  width: 100%;
  height: calc(100% - 40px);
  background: #111;
}

html.is-touch-game #game-area {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Paddle */
#paddle {
  position: absolute;
  width: 120px;
  height: 16px;
  background: #00bcd4;
  bottom: 20px;
  left: calc(50% - 60px);
  border-radius: 8px;
}

/* Ball */
#ball,
.ball-extra {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffeb3b;
  border-radius: 50%;
  left: 50%;
  top: 50%;
}

/* Bricks */
.brick {
  position: absolute;
  width: 80px; /* ajustar a tu grid */
  height: 24px;
  background: #e91e63;
  border-radius: 4px;
}

/* Overlays de pausa y game over */
#pause-overlay,
#gameover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.hidden {
  display: none !important;
}

#pause-menu,
#gameover-menu {
  background: #242424;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  padding: 24px 34px;
  border-radius: 8px;
  text-align: center;
}

#pause-menu h2,
#gameover-menu h2 {
  margin-bottom: 12px;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

#nickname-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

#nickname-box label {
  color: #f5f5f5;
  font-weight: 500;
}

#nickname-input {
  width: 12ch;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid #c9d0d3;
  border-radius: 4px;
  background: #f8fafb;
  color: #101010;
  font-weight: 700;
  text-transform: uppercase;
}

#nickname-input::placeholder {
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
}

button {
  margin: 5px;
  min-height: 34px;
  padding: 8px 18px;
  background: #17c6d8;
  border: none;
  border-radius: 4px;
  color: #031316;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.15;
}

button:hover {
  filter: brightness(1.1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.powerup {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

/* green extra life */
.powerup-life {
  background: #4caf50;
}

/* blue big paddle */
.powerup-widen {
  background: #2196f3;
}

/* Power-down: small paddle  (red) */
.powerup-shrink {
  background: #ff002b;
}

/* Multi-ball: orange */
.powerup-multiball {
  background: #ff00aa;
}

/* Slow: purple */
.powerup-slow {
  background: #9c27b0;
}

/* Score x2: golden yellow */
.powerup-scorex2 {
  background: #ffc107;
}

/* === Highscore Table === */
#highscore-table {
  margin-top: 20px;
  text-align: center;
  width: 100%;
}

.highscore-status {
  margin-top: 10px;
  color: #bff8ff;
  font-size: 13px;
}

.highscore-status.error {
  color: #ff9b9b;
}

#highscore-table h3 {
  margin-bottom: 10px;
  font-size: 18px;
  color: #fff;
}

/* Table container */
#highscore-table table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

/* Header cells */
#highscore-table th {
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #00eaff;
  font-weight: bold;
  border-bottom: 1px solid #333;
}

/* Body cells */
#highscore-table td {
  padding: 6px 8px;
  color: #ddd;
  border-bottom: 1px solid #333;
}

/* Remove border for last row */
#highscore-table tr:last-child td {
  border-bottom: none;
}

/* Optional: subtle row hover */
#highscore-table tr:hover td {
  background: rgba(255, 255, 255, 0.07);
}

/* Highlighted row in the leaderboard (last score entered) */
#highscore-table tr.highscore-highlight td {
  background: rgba(0, 234, 255, 0.25);
  font-weight: 600;
}

/* === Mobile: lock page scrolling (no layout changes) === */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden !important; /* no vertical/horizontal scroll */
  overscroll-behavior: none; /* no rubber-band / pull-to-refresh */
}

body {
  position: fixed; /* iOS Safari: prevents body from moving */
  inset: 0;
  touch-action: none; /* block touch panning */
}

/* Optional but recommended: avoid any accidental horizontal overflow */
#game-root {
  max-width: 100%;
}

html.is-mobile-game,
html.is-mobile-game body {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
}

html.is-mobile-game body {
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

html.is-mobile-game #game-root {
  width: min(var(--game-root-width), calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)));
  height: min(var(--game-root-height), calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  margin: 0 auto;
  border: 0;
  max-width: 100vw;
  max-height: 100dvh;
  touch-action: none;
}

html.is-mobile-game #hud {
  height: var(--hud-height);
  gap: 2px;
  justify-content: space-evenly;
  padding: 0 4px;
}

html.is-mobile-game .hud-item {
  flex: 0 1 auto;
  min-width: 0;
  font-size: clamp(9px, 2.45vw, 12px);
  line-height: 1;
  white-space: nowrap;
}

html.is-mobile-game #game-area {
  top: var(--hud-height);
  height: calc(100% - var(--hud-height));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html.is-mobile-game #pause-menu,
html.is-mobile-game #gameover-menu {
  width: min(92vw, 380px);
  max-height: 88%;
  overflow: auto;
  padding: 26px;
}

html.is-mobile-game #gameover-menu h2 {
  margin-bottom: 18px;
  font-size: 34px;
}

html.is-mobile-game #gameover-menu > p:not(.highscore-status) {
  font-size: 24px;
  line-height: 1.25;
}

html.is-mobile-game #gameover-menu button {
  display: block;
  width: 100%;
}

html.is-mobile-game #gameover-menu label,
html.is-mobile-game #gameover-menu input {
  display: block;
  width: auto;
}

html.is-mobile-game #gameover-menu input {
  margin: 14px auto 18px;
  padding: 10px;
}

html.is-mobile-game #gameover-menu #nickname-input {
  display: inline-block;
  width: 12ch;
  min-height: 42px;
  margin: 14px auto 18px;
  padding: 8px 10px;
  font-size: 16px;
  text-align: center;
}

html.is-mobile-game #gameover-menu button {
  min-height: 46px;
  margin: 10px 0 0;
  color: #031316;
  font-size: 16px;
  font-weight: 900;
}
