/* ==========================================================================
   Mete Gol — styling
   Handles: lobby, HUD overlay, mobile virtual controls, safe-area insets,
   fullscreen niceties. Kept dependency-free (no CSS frameworks).
   ========================================================================== */

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

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #0a1f14;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #fff;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  outline: none;
}

/* ---------------------------------- Screens ---------------------------------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 20%, #14432a 0%, #06140c 75%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-y: auto;
}
.hidden { display: none !important; }

.lobby-card {
  width: min(520px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  background: rgba(10, 30, 18, 0.85);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 28px 26px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}
.lobby-card h1 {
  margin: 0 0 2px; font-size: 2.6rem; letter-spacing: 2px;
  font-weight: 800; text-shadow: 0 3px 0 rgba(0,0,0,0.35);
}
.lobby-card h1 .accent { color: #ffcf3f; }
.tagline { margin: 0 0 20px; opacity: 0.75; font-size: 0.95rem; }

.lobby-panel { display: flex; flex-direction: column; gap: 10px; }

.big-btn {
  padding: 14px 16px; font-size: 1.05rem; font-weight: 700;
  border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #2fbf6a, #1e9750);
  color: #04170b; box-shadow: 0 4px 0 #146138, 0 8px 14px rgba(0,0,0,0.3);
  transition: transform .08s ease;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #146138; }

.ghost-btn {
  padding: 11px 14px; font-size: 0.95rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.25); border-radius: 10px;
  background: rgba(255,255,255,0.06); color: #fff; cursor: pointer;
}
.ghost-btn:active { background: rgba(255,255,255,0.15); }

.text-input, .code-box {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.35); color: #fff; font-size: 0.95rem; font-family: inherit;
}
.code-box { min-height: 64px; resize: vertical; font-family: monospace; font-size: 0.72rem; word-break: break-all; }
.hint { font-size: 0.82rem; opacity: 0.75; margin: 4px 0; text-align: left; }

#host-slots { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.slot-row {
  display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.05);
  border-radius: 10px; padding: 8px; text-align: left;
}
.slot-row .slot-label { min-width: 62px; font-weight: 700; font-size: 0.85rem; }
.slot-row .slot-status { font-size: 0.78rem; opacity: 0.8; flex: 1; }
.slot-row button {
  padding: 6px 10px; font-size: 0.78rem; border-radius: 8px; border: none;
  background: #2fbf6a; color: #04170b; font-weight: 700; cursor: pointer;
}
.slot-row textarea {
  width: 100%; margin-top: 6px; font-family: monospace; font-size: 0.68rem;
  min-height: 46px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.35); color: #fff;
}

.howto-cols { display: flex; gap: 18px; text-align: left; margin-bottom: 10px; flex-wrap: wrap; }
.howto-cols > div { flex: 1; min-width: 180px; }
.howto-cols h3 { margin: 0 0 6px; font-size: 0.95rem; }
.howto-cols p { margin: 0; font-size: 0.82rem; line-height: 1.5; opacity: 0.85; }

/* ---------------------------------- HUD ---------------------------------- */
#hud {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + 12px)
           calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 12px);
}

#hud-top {
  position: absolute; top: env(safe-area-inset-top); left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 14px;
  padding-top: 10px;
}
#score-box {
  background: rgba(0,0,0,0.45); border-radius: 12px; padding: 6px 16px;
  display: flex; flex-direction: column; align-items: center; min-width: 110px;
  border: 1px solid rgba(255,255,255,0.15);
}
#score-value { font-size: 1.2rem; font-weight: 800; }
#match-clock { font-size: 0.72rem; opacity: 0.75; }
#role-badge {
  background: rgba(0,0,0,0.45); border: 1px solid rgba(255,207,63,0.5);
  color: #ffcf3f; padding: 7px 14px; border-radius: 20px; font-weight: 700; font-size: 0.85rem;
}
#role-badge.is-keeper { border-color: #4fc3ff; color: #4fc3ff; }
#conn-status {
  background: rgba(0,0,0,0.45); border-radius: 10px; padding: 6px 10px; font-size: 0.72rem; opacity: 0.85;
}

#hud-bottom-left {
  position: absolute; left: calc(env(safe-area-inset-left) + 14px); bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: 220px;
}
.bar-label { font-size: 0.7rem; opacity: 0.8; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 1px; }
.bar-track {
  width: 100%; height: 14px; border-radius: 8px; background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.2); overflow: hidden;
}
.bar-fill {
  height: 100%; width: 100%; background: linear-gradient(90deg, #ffd54f, #2fbf6a);
  transition: width .12s linear;
}
.bar-track.vertical { width: 14px; height: 120px; }
.bar-fill.vertical { width: 100%; height: 0%; position: relative; top: auto; align-self: flex-end; }

#power-meter-wrap {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 130px); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
}
#power-meter-wrap .bar-track.vertical { display: flex; flex-direction: column-reverse; }

#btn-fullscreen, #btn-mute {
  position: absolute; top: calc(env(safe-area-inset-top) + 10px); pointer-events: auto;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.45); color: #fff; font-size: 1.1rem; cursor: pointer;
}
#btn-fullscreen { right: calc(env(safe-area-inset-right) + 12px); }
#btn-mute { right: calc(env(safe-area-inset-right) + 60px); }

#rotate-hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.65); padding: 12px 20px; border-radius: 12px; font-size: 0.95rem;
  pointer-events: none;
}

#goal-banner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%) scale(0.6);
  font-size: 4rem; font-weight: 900; color: #ffcf3f; letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255,207,63,0.8), 0 6px 0 rgba(0,0,0,0.4);
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
}
#goal-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------------------------------- Mobile controls ---------------------------------- */
#mobile-controls {
  position: fixed; inset: 0; z-index: 15; pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom);
}
#joystick-zone {
  position: absolute; left: calc(env(safe-area-inset-left) + 18px); bottom: calc(env(safe-area-inset-bottom) + 18px);
  width: 130px; height: 130px; pointer-events: auto;
}
#joystick-base {
  width: 100%; height: 100%; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.3);
  position: relative;
}
#joystick-knob {
  width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,0.55);
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
#look-zone {
  position: absolute; right: 0; top: 0; bottom: 0; width: 55%;
  pointer-events: auto;
}
/* Floating aim drag-stick: js/controls.js sets #aim-ring's left/top to the
   touch-down point (so it appears wherever your thumb lands, anywhere in
   #look-zone) and slides #aim-dot inside it while dragging. Hidden by
   default; .visible is toggled on touchstart/touchend. */
#aim-ring {
  position: fixed; width: 116px; height: 116px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.28);
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity .12s ease;
  pointer-events: none;
}
#aim-ring.visible { opacity: 1; }
#aim-dot {
  width: 48px; height: 48px; border-radius: 50%; background: rgba(255,207,63,0.65);
  border: 2px solid rgba(255,255,255,0.5);
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
#action-buttons {
  position: absolute; right: calc(env(safe-area-inset-right) + 14px); bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: 190px; height: 190px; pointer-events: none;
}
.action-btn {
  position: absolute; width: 68px; height: 68px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); background: rgba(0,0,0,0.4);
  color: #fff; font-weight: 800; font-size: 0.72rem; pointer-events: auto; cursor: pointer;
}
#btn-kick { right: 0; bottom: 0; background: rgba(47,191,106,0.55); }
#btn-power { right: 78px; bottom: 34px; background: rgba(255,140,50,0.55); }
#btn-boost { right: 0; bottom: 108px; background: rgba(79,195,255,0.4); }
#btn-dive { right: 108px; bottom: 108px; background: rgba(255,255,255,0.2); }

@media (min-width: 900px) {
  #mobile-controls { display: none !important; }
}

/* On touch/narrow layouts the virtual joystick sits bottom-left, which is
   also where the energy bar lives -- lift the energy bar clear of it. */
@media (max-width: 899px) {
  #hud-bottom-left { bottom: calc(env(safe-area-inset-bottom) + 160px); }
}

/* Landscape lock hint only shown on narrow+portrait touch devices */
@media (orientation: portrait) and (max-width: 899px) {
  #rotate-hint.active { display: block; }
}
