:root {
  color-scheme: dark;
  --bg: #070a10;
  --panel: rgba(15, 21, 33, 0.9);
  --panel-strong: rgba(21, 29, 45, 0.96);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f7fb;
  --muted: #99a5b9;
  --red: #ff3f55;
  --blue: #3e8cff;
  --green: #2ee59d;
  --yellow: #ffd166;
  --neon: #35f2ff;
  --violet: #b45cff;
  --stone: #d9cfb5;
  --gold: #f4c95d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(53, 242, 255, 0.24), transparent 25rem),
    radial-gradient(circle at 80% 0%, rgba(180, 92, 255, 0.18), transparent 24rem),
    radial-gradient(circle at 50% 90%, rgba(255, 63, 85, 0.18), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100vw, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  gap: 12px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 35% 15%, rgba(62, 140, 255, 0.24), transparent 22rem),
    radial-gradient(circle at 75% 85%, rgba(255, 63, 85, 0.22), transparent 22rem),
    rgba(7, 10, 16, 0.96);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(100%, 380px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel-strong);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
}

.login-card h1 {
  margin: 6px 0 18px;
  font-size: 1.75rem;
  line-height: 1.05;
}

.login-card label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.login-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.login-card input:focus {
  border-color: rgba(46, 229, 157, 0.7);
}

.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #2ee59d, #35b8ff);
  color: #061018;
  cursor: pointer;
  font-weight: 900;
}

.login-card .login-reset-button {
  border: 1px solid rgba(255, 63, 85, 0.45);
  background: rgba(255, 63, 85, 0.12);
  color: #ffd6dc;
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--yellow);
  font-size: 0.86rem;
}

.top-hud,
.profile-bar,
.gps-controls,
.bottom-panel {
  position: relative;
  z-index: 2;
}

.top-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
}

.team-pill,
.match-status {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.26);
}

.team-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.team-pill span,
.match-status span,
.label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.team-pill strong,
.match-status strong,
.target-row strong {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.1;
}

.team-pill.red {
  border-color: rgba(255, 63, 85, 0.5);
}

.team-pill.blue {
  border-color: rgba(62, 140, 255, 0.5);
}

.match-status {
  text-align: center;
  min-width: 118px;
}

.profile-bar {
  display: grid;
  grid-template-columns: 1fr 0.72fr auto auto auto;
  gap: 8px;
  align-items: stretch;
}

.gps-controls {
  display: grid;
  grid-template-columns: 0.7fr 0.8fr auto;
  gap: 8px;
  align-items: stretch;
}

.profile-bar > div,
.gps-controls > div,
.ghost-button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 9px 10px;
}

.profile-bar strong {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.15;
}

.gps-controls strong {
  display: block;
  color: var(--green);
  font-size: 0.95rem;
  line-height: 1.15;
}

.ghost-button {
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.ghost-button.danger {
  border-color: rgba(255, 63, 85, 0.42);
  color: #ff9aa7;
}

.map-stage {
  position: relative;
  overflow: hidden;
  min-height: 380px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 40%, rgba(53, 242, 255, 0.11), transparent 16rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 40%),
    #101826;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 60px rgba(53, 242, 255, 0.08),
    0 28px 60px rgba(0, 0, 0, 0.34),
    0 0 34px rgba(53, 242, 255, 0.12);
}

#battleMap {
  width: 100%;
  height: 100%;
  display: block;
}

.map-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 52%, rgba(4, 6, 11, 0.4)),
    linear-gradient(to bottom, rgba(4, 6, 11, 0.12), transparent 28%, rgba(4, 6, 11, 0.5));
}

.range-label,
.gps-chip,
.map-place {
  position: absolute;
  border: 1px solid var(--line);
  background: rgba(9, 13, 22, 0.74);
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.range-label,
.gps-chip {
  top: 12px;
  border-radius: 999px;
}

.range-label {
  left: 12px;
}

.gps-chip {
  right: 12px;
  color: var(--green);
}

.map-place {
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-color: rgba(244, 201, 93, 0.36);
  border-radius: 8px;
  background: rgba(9, 13, 22, 0.82);
  color: var(--gold);
}

.map-place strong {
  color: var(--text);
  font-size: 0.72rem;
}

.bottom-panel {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.3);
}

.lobby-panel {
  display: grid;
  grid-template-columns: 0.9fr 1.4fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
  border: 1px solid rgba(46, 229, 157, 0.28);
  border-radius: 8px;
  padding: 10px;
  background: rgba(46, 229, 157, 0.06);
}

.lobby-panel[hidden] {
  display: none;
}

.lobby-panel strong {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: 1rem;
}

.roster-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.84rem;
}

.roster-list li::marker {
  color: rgba(255, 255, 255, 0.34);
}

.roster-list .red {
  color: #ff9aa7;
}

.roster-list .blue {
  color: #9bc2ff;
}

.target-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.9fr;
  gap: 10px;
  margin-bottom: 12px;
}

.resource-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.target-row > div,
.resource-row > div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.move-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.move-pad button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

.move-pad button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.fight-button {
  width: 100%;
  min-height: 72px;
  border: 0;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 10%, rgba(255, 255, 255, 0.38), transparent 5rem),
    linear-gradient(135deg, #ff3f55, #b45cff 48%, #35f2ff);
  color: white;
  box-shadow:
    0 18px 34px rgba(255, 63, 85, 0.28),
    0 0 28px rgba(180, 92, 255, 0.3),
    0 0 36px rgba(53, 242, 255, 0.2);
  cursor: pointer;
  transition:
    transform 160ms ease,
    filter 160ms ease,
    opacity 160ms ease;
}

.fight-button:active {
  transform: scale(0.985);
}

.fight-button:disabled {
  cursor: not-allowed;
  filter: saturate(0.42);
  opacity: 0.66;
}

.fight-button span,
.fight-button small {
  display: block;
}

.fight-button span {
  font-size: 1.35rem;
  font-weight: 900;
}

.fight-button small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
}

.combat-timer {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

#timerBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  transition: width 120ms linear;
}

.incoming-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  border: 1px solid rgba(255, 209, 102, 0.72);
  border-radius: 8px;
  padding: 12px;
  background:
    radial-gradient(circle at 12% 30%, rgba(255, 209, 102, 0.18), transparent 9rem),
    rgba(255, 209, 102, 0.1);
  box-shadow: 0 14px 32px rgba(255, 209, 102, 0.12);
}

.incoming-panel[hidden] {
  display: none;
}

.incoming-panel strong {
  display: block;
  color: var(--yellow);
  font-size: 1.05rem;
  line-height: 1.1;
}

.defense-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: linear-gradient(135deg, #35f2a9, #ffd166);
  color: #061018;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(46, 229, 157, 0.24);
}

.settings-shell {
  width: min(100vw, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.settings-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.settings-header h1 {
  margin: 4px 0 0;
  font-size: 2rem;
  line-height: 1;
}

.ghost-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--panel);
  text-decoration: none;
  font-weight: 900;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-strong);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.settings-section h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.settings-section p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.35;
}

.settings-section label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.settings-section input,
.settings-section select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.settings-actions button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--green), var(--neon));
  color: #061018;
  cursor: pointer;
  font-weight: 900;
}

.defense-button:disabled {
  cursor: not-allowed;
  filter: saturate(0.4);
  opacity: 0.62;
}

.incoming-timer {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

#incomingTimerBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--red));
  transition: width 120ms linear;
}

.event-log {
  min-height: 22px;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.is-dead .fight-button {
  background: linear-gradient(135deg, #4d5360, #252a34);
  box-shadow: none;
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .target-row {
    gap: 7px;
  }

  .profile-bar {
    grid-template-columns: 1fr 0.7fr;
  }

  .gps-controls {
    grid-template-columns: 1fr 1fr;
  }

  .ghost-button {
    min-height: 38px;
  }

  .lobby-panel {
    grid-template-columns: 1fr;
  }

  .target-row > div,
  .resource-row > div,
  .team-pill,
  .match-status {
    padding: 9px;
  }
}
