:root { --safe-bottom: env(safe-area-inset-bottom, 0px); }

html, body {
  overscroll-behavior: none;
}

#game-wrapper {
  height: calc(100vh - var(--header-height, 71px));
  height: calc(100dvh - var(--header-height, 71px));
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; 
  -webkit-user-select: none;
  user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  transition: opacity 0.3s;
  z-index: 500;
}

.wisedocks-container {
  padding: 25px;
  margin: 10px auto;
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 85%;
  margin-bottom: 25px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 15px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.8);
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  width: min(92vw, 640px);
  max-height: min(calc(100dvh - var(--header-height, 71px) - 24px), 88vh);
  overflow: auto;
  padding: 24px 22px;
  border-radius: 18px;
  border: 2px solid rgba(186, 218, 85, 0.35);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 80px rgba(0, 0, 0, 0.55);
}

/* Tighten modals on short or narrow screens */
@media (max-height: 600px), (max-width: 420px) {
  .overlay-content {
    padding: 14px 14px;
    border-radius: 12px;
  }
  #initialsOverlay h2 {
    font-size: 1.4rem;
    margin-bottom: 6px;
  }
  .score-display {
    font-size: 1.3rem;
    margin-bottom: 14px;
  }
  .initials-row {
    margin: 10px 0 8px;
    gap: 8px;
  }
  .initials-row input {
    width: 48px;
    height: 54px;
    font-size: 30px;
  }
  .initials-actions {
    gap: 8px;
    margin-top: 8px;
  }
  .btn {
    padding: 14px 28px;
    font-size: 1.1rem;
    min-width: 140px;
    min-height: 48px;
  }
  .lb-wrap {
    margin-top: 10px;
    gap: 12px;
  }
  .lb-col h3 {
    font-size: 13px;
  }
  .lb-list {
    font-size: 12px;
  }
}

#initialsOverlay h2 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  text-align: center;
}

.title-start {
  color: #00d9ff;
}

.title-gameover {
  color: #ff4d4d;
}

.controls {
  color: white;
  font-size: 1.2rem;
  margin-bottom: 30px;
  padding: 0 20px;
  text-align: center;
}

@media (max-width: 768px) {
  .controls {
    font-size: 1rem;
    margin-bottom: 20px;
  }
}

.score-display {
  color: white;
  font-size: 2rem;
  margin-bottom: 5px;
  display: flex;
  justify-content: center;
}

.btn {
  padding: 20px 50px;
  font-size: 1.5rem;
  font-weight: bold;
  background: #bada55;
  color: #002a0a;
  border: 4px solid #005c1a;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 0 #005c1a;
  transition: all 0.1s;
  min-width: 200px;
  min-height: 60px;
}

@media (max-width: 768px) {
  .btn {
    padding: 18px 40px;
    font-size: 1.3rem;
    min-width: 180px;
    min-height: 56px;
  }
}

.btn:hover {
  box-shadow: 0 4px 0 #005c1a;
  transform: translateY(4px);
}

.btn:active {
  box-shadow: 0 2px 0 #005c1a;
  transform: translateY(6px);
}

.stats {
  position: absolute;
  top: 15px;
  left: 15px;
  transform: none;
  background: none;
  color: white;
  padding: 0;
  border-radius: 12px;
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 1px;
  backdrop-filter: none;
  border: none;
  text-align: left;
  pointer-events: none;
  line-height: 1.5;
}

.stats .game-title-hud {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #bada55;
  opacity: 0.75;
  margin-bottom: 2px;
}

.stats .score-hud {
  font-size: 1.1rem;
  color: #ffffff;
}

@media (max-width: 768px) {
  .stats {
    font-size: 0.95rem;
  }
  .stats .game-title-hud {
    font-size: 0.65rem;
  }
  .stats .score-hud {
    font-size: 0.95rem;
  }
}

.health-bar-container {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 55vw);
  height: 18px;
  pointer-events: none;
}

.health-bar {
  height: 100%;
  box-shadow: 0 0 10px currentColor;
  transition: width 0.3s, background 0.3s;
}

/* ── Game control buttons (mute / pause / fullscreen) ── */
.ctrl-btn {
  position: fixed;
  right: 10px;
  background: rgba(0, 0, 0, 0.5) !important;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  z-index: 950;
  transition: background 0.2s ease, transform 0.15s ease;
  border-radius: 50%;
  border: 2px solid rgba(186, 218, 85, 0.3);
  backdrop-filter: blur(5px);
  color: #bada55;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn:hover {
  background: rgba(186, 218, 85, 0.15) !important;
  transform: scale(1.1);
  border-color: rgba(186, 218, 85, 0.6);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

#muteBtn     { top: 100px; }
#infoBtn     { top: 154px; }
#fullscreenBtn { top: 208px; }

@media (max-width: 768px) {
  .ctrl-btn {
    right: 8px;
    width: 48px;
    height: 48px;
  }
  #muteBtn     { top: 75px; }
  #infoBtn     { top: 133px; }
  #fullscreenBtn { top: 191px; }
}

/* Fullscreen: game wrapper fills the whole viewport, header gone */
#game-wrapper:fullscreen,
#game-wrapper:-webkit-full-screen,
#game-wrapper:-moz-full-screen,
#game-wrapper:-ms-fullscreen {
  height: 100dvh !important;
  height: 100vh !important;
}

.initials-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 10px;
}

.initials-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 18px 0 10px;
}

.initials-row input {
  width: 60px;
  height: 70px;
  font-size: 40px;
  text-align: center;
  border-radius: 12px;
  border: 2px solid #bada55;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  outline: none;
  text-transform: uppercase;
}

.initials-row input:focus {
  box-shadow: 0 0 0 3px rgba(186, 218, 85, 0.35);
}

.initials-msg {
  text-align: center;
  margin-bottom: 14px;
  opacity: 0.9;
}

.lb-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
  width: 100%;
  max-width: 100%;
}

@media (max-width: 600px) {
  .lb-wrap {
    grid-template-columns: 1fr;
  }
}

.lb-col h3 {
  margin: 0 0 8px;
  font-size: 16px;
  opacity: 0.9;
}

.lb-list {
  margin: 0;
  padding-left: 22px;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}

.lb-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;

  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lb-list .lb-name {
  opacity: 0.95;
}

.lb-list .lb-score {
  opacity: 0.85;
}

.lb-empty {
  opacity: 0.65;
  padding: 6px 0;
}

.lb-title {
  margin-top: 10px;
}

.lb-sub {
  opacity: 0.9;
  margin-top: -6px;
}

.lb-wrap-page {
  margin-top: 14px;
  max-width: 720px;
}