/* style.css — Mobile-first, landscape, full-screen game UI */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Courier New', Courier, monospace;
  touch-action: none;
}

/* ── Three.js renderer canvas ───────────────────────────────────────────────── */
#canvas-wrap {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── HUD canvas overlay (touch input + HUD drawing) ────────────────────────── */
#hud-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
  z-index: 10;
}

/* ── Hit flash ──────────────────────────────────────────────────────────────── */
#damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background: rgba(255, 40, 0, 0.55);
  opacity: 0;
}

#damage-flash.flash-active {
  animation: dmg-flash 0.35s ease-out forwards;
}

@keyframes dmg-flash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Overlay (menu / pause / game-over) ─────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.80);
  transition: opacity 0.2s;
  overflow-y: auto;
  padding: 12px;
}

.overlay-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Ensure no child of a hidden overlay can intercept touch/pointer events */
.overlay-hidden * {
  pointer-events: none !important;
}

.overlay-visible {
  opacity: 1;
  pointer-events: auto;
}

#overlay-title {
  font-size: 28px;
  font-weight: bold;
  color: #e8eaf2;
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 6px;
}

#overlay-sub {
  font-size: 13px;
  color: rgba(180, 200, 230, 0.75);
  text-align: center;
  margin-bottom: 6px;
}

#overlay-score {
  font-size: 14px;
  color: rgba(200, 220, 160, 0.90);
  text-align: center;
  margin-bottom: 16px;
}

#overlay-controls {
  width: 100%;
  max-width: 460px;
  pointer-events: auto;
}

/* ── Mobile menu ────────────────────────────────────────────────────────────── */
.mob-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.mob-menu-title {
  font-size: 22px;
  font-weight: bold;
  color: #d4e0f0;
  letter-spacing: 3px;
  text-align: center;
}

.mob-menu-sub {
  font-size: 11px;
  color: rgba(160, 180, 200, 0.65);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.mob-sect-label {
  font-size: 10px;
  color: rgba(140, 160, 180, 0.70);
  letter-spacing: 2px;
  align-self: flex-start;
  margin-top: 4px;
}

/* Faction row */
.mob-faction-row {
  display: flex;
  gap: 6px;
  width: 100%;
}

.mob-faction-btn {
  flex: 1;
  padding: 10px 4px;
  background: rgba(30, 40, 60, 0.85);
  color: rgba(180, 200, 220, 0.80);
  border: 1px solid rgba(80, 100, 130, 0.50);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
}

.mob-faction-btn.mob-selected {
  background: rgba(40, 80, 130, 0.90);
  color: #c8e0ff;
  border-color: rgba(100, 160, 230, 0.80);
}

/* Difficulty row */
.mob-diff-row {
  display: flex;
  gap: 5px;
  width: 100%;
}

.mob-diff-btn {
  flex: 1;
  padding: 9px 2px;
  background: rgba(30, 40, 55, 0.85);
  color: rgba(180, 190, 200, 0.75);
  border: 1px solid rgba(70, 90, 110, 0.50);
  border-radius: 5px;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
}

.mob-diff-btn.mob-selected {
  background: rgba(80, 55, 20, 0.90);
  color: #ffe0a0;
  border-color: rgba(200, 150, 60, 0.80);
}

/* Mode buttons */
.mob-mode-btns {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 6px;
  margin-top: 6px;
}

.mob-start-btn {
  width: 100%;
  padding: 16px;
  background: rgba(30, 70, 30, 0.90);
  color: #a8ffb0;
  border: 1px solid rgba(80, 200, 80, 0.45);
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
}

.mob-start-btn-alt {
  background: rgba(30, 50, 70, 0.90);
  color: #a0c8ff;
  border-color: rgba(80, 140, 220, 0.45);
}

.mob-back-btn {
  width: 100%;
  padding: 12px;
  background: rgba(40, 30, 30, 0.85);
  color: rgba(200, 180, 160, 0.80);
  border: 1px solid rgba(120, 80, 60, 0.45);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  margin-top: 4px;
}

.mob-mode-desc {
  font-size: 10px;
  color: rgba(140, 160, 180, 0.60);
  text-align: center;
  letter-spacing: 0.5px;
  padding: 0 4px;
}

/* ── LAN lobby ───────────────────────────────────────────────────────────── */

.lan-select {
  width: 100%;
  padding: 9px 10px;
  background: rgba(20, 30, 50, 0.88);
  color: rgba(180, 210, 240, 0.90);
  border: 1px solid rgba(70, 110, 160, 0.55);
  border-radius: 6px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.lan-player-list {
  width: 100%;
  background: rgba(10, 18, 30, 0.75);
  border: 1px solid rgba(60, 90, 130, 0.40);
  border-radius: 6px;
  padding: 6px 8px;
}

.lan-player-row {
  font-size: 12px;
  color: rgba(180, 210, 240, 0.85);
  padding: 3px 0;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Room code entry */

.lan-code-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 4px 0;
}

.lan-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 54px;
  background: rgba(20, 30, 50, 0.88);
  border: 1px solid rgba(70, 110, 160, 0.50);
  border-radius: 6px;
  font-size: 26px;
  font-weight: bold;
  color: rgba(160, 210, 255, 0.90);
}

.lan-digit.active {
  border-color: rgba(100, 180, 255, 0.80);
  background: rgba(30, 60, 90, 0.90);
  color: #c8e8ff;
}

.lan-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.lan-num-btn {
  padding: 13px 6px;
  background: rgba(25, 40, 65, 0.90);
  color: rgba(180, 210, 240, 0.85);
  border: 1px solid rgba(60, 100, 150, 0.50);
  border-radius: 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
}

.lan-num-del {
  color: rgba(220, 150, 130, 0.85);
}

.lan-num-join {
  background: rgba(30, 70, 30, 0.90);
  color: #a8ffb0;
  border-color: rgba(80, 200, 80, 0.40);
  font-size: 14px;
  letter-spacing: 2px;
}

.lan-error {
  font-size: 12px;
  color: #ff8866;
  text-align: center;
  padding: 4px 0;
}

.lan-name-field {
  width: 100%;
  padding: 9px 10px;
  background: rgba(20, 30, 50, 0.88);
  color: rgba(180, 210, 240, 0.90);
  border: 1px solid rgba(70, 110, 160, 0.55);
  border-radius: 6px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  box-sizing: border-box;
}

.lan-ready-active {
  background: rgba(30, 90, 30, 0.95) !important;
  border-color: rgba(80, 220, 80, 0.70) !important;
  color: #aaffb8 !important;
}

/* ── Portrait-mode "rotate device" prompt ────────────────────────────────── */
#rotate-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #060a14;
  color: rgba(180, 210, 240, 0.90);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  font-size: 16px;
  letter-spacing: 1px;
  text-align: center;
  padding: 24px;
  pointer-events: all;
}

#rotate-prompt .rotate-icon {
  font-size: 52px;
  opacity: 0.70;
}

@media (orientation: portrait) {
  #rotate-prompt { display: flex; }
}
