:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  --bg-top: #1e2f60;
  --bg-mid: #0a0f24;
  --bg-bottom: #020308;
  --panel-border: rgba(140, 210, 255, 0.22);
  --panel-glow: rgba(120, 200, 240, 0.15);
  --text-primary: #dce8f8;
  --text-secondary: #b8cceb;
  --text-muted: #8ea4c8;
  --accent-a: #14b8be;
  --accent-b: #2e7de8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 15%, rgba(100, 160, 255, 0.18) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 8%, rgba(90, 220, 240, 0.10) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 120%, rgba(70, 75, 160, 0.20) 0%, transparent 50%),
    radial-gradient(ellipse at 40% 60%, rgba(60, 100, 180, 0.06) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bottom) 100%);
  color: var(--text-primary);
}

.layout {
  width: min(1360px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1.25rem;
  align-items: start;
}

.hud-panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(50, 90, 150, 0.28), rgba(30, 24, 70, 0.45)),
    linear-gradient(0deg, rgba(4, 8, 24, 0.35), rgba(4, 8, 24, 0.35));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1rem;
  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 0 0 1px rgba(220, 245, 255, 0.03),
    0 12px 40px rgba(0, 0, 0, 0.35),
    0 0 40px -10px var(--panel-glow);
}

.hud-panel::after {
  content: "";
  position: absolute;
  inset: -40% 8% auto;
  height: 40%;
  background: radial-gradient(ellipse at center, rgba(150, 230, 250, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0.65;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.back-link:hover {
  opacity: 1;
  color: var(--text-primary);
}

.hud-panel h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 1.8vw, 1.9rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #c8e8ff, #8ec8e8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hud-panel p {
  margin: 0 0 0.95rem;
  color: var(--text-secondary);
  line-height: 1.55;
  font-size: 0.96rem;
}

.hud-panel strong {
  color: #eaf4ff;
}

.stats {
  display: grid;
  gap: 0.6rem;
}

.stats div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(160, 210, 245, 0.15);
  border-radius: 10px;
  padding: 0.62rem 0.78rem;
  background: rgba(3, 8, 20, 0.4);
  box-shadow: inset 0 0 28px rgba(90, 180, 240, 0.05);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.stats div:hover {
  border-color: rgba(160, 210, 245, 0.28);
  box-shadow: inset 0 0 28px rgba(90, 180, 240, 0.09);
}

.stats span {
  color: var(--text-muted);
  letter-spacing: 0.02em;
  font-size: 0.92rem;
}

.stats strong {
  color: #deeeff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.mute-btn {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(160, 210, 245, 0.2);
  color: var(--text-secondary);
  background: rgba(3, 8, 20, 0.5);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease;
}

.mute-btn:hover {
  border-color: rgba(160, 210, 245, 0.4);
  color: var(--text-primary);
}

.mute-btn:focus-visible {
  outline: 2px solid rgba(160, 240, 255, 0.8);
  outline-offset: 2px;
}

.restart-btn {
  margin-top: 0.6rem;
  width: 100%;
  padding: 0.72rem;
  border-radius: 10px;
  border: 1px solid rgba(160, 230, 245, 0.35);
  color: #eef8ff;
  background: linear-gradient(120deg, var(--accent-a), var(--accent-b));
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 200ms ease;
}

.restart-btn:hover {
  filter: brightness(1.1);
  box-shadow:
    0 8px 20px rgba(30, 130, 230, 0.3),
    0 0 20px rgba(20, 184, 190, 0.15);
}

.restart-btn:active {
  transform: translateY(1px) scale(0.996);
}

.restart-btn:focus-visible {
  outline: 2px solid rgba(160, 240, 255, 0.8);
  outline-offset: 2px;
}

.symbiosis-action-btn {
  margin-top: 0.6rem;
  width: 100%;
  padding: 1rem 0.65rem;
  border-radius: 12px;
  border: 2px solid rgba(130, 255, 240, 0.35);
  color: #d0fff5;
  background: linear-gradient(120deg, rgba(20, 184, 190, 0.4), rgba(46, 125, 232, 0.3));
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  min-height: 52px;
  transition: transform 150ms ease, filter 150ms ease, box-shadow 200ms ease;
}

.symbiosis-action-btn:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 16px rgba(20, 184, 190, 0.25);
}

.symbiosis-action-btn:active {
  transform: translateY(1px) scale(0.996);
}

.symbiosis-action-btn:focus-visible {
  outline: 2px solid rgba(130, 255, 240, 0.8);
  outline-offset: 2px;
}

.symbiosis-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

.fullscreen-btn {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(160, 210, 245, 0.2);
  color: var(--text-secondary);
  background: rgba(3, 8, 20, 0.5);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease;
}

.fullscreen-btn:hover {
  border-color: rgba(160, 210, 245, 0.4);
  color: var(--text-primary);
}

.fullscreen-btn:focus-visible {
  outline: 2px solid rgba(160, 240, 255, 0.8);
  outline-offset: 2px;
}

.game-canvas {
  width: 100%;
  height: calc(100vh - 2.5rem);
  border-radius: 16px;
  border: 1px solid rgba(120, 200, 240, 0.20);
  box-shadow:
    inset 0 0 30px rgba(90, 190, 240, 0.12),
    inset 0 -20px 80px rgba(80, 100, 220, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.4),
    0 0 50px -15px rgba(100, 200, 255, 0.08);
  background: #040614;
  object-fit: contain;
}

.game-canvas:fullscreen,
.game-canvas:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #000;
  image-rendering: auto;
}

.lang-switcher {
  margin-bottom: 0.5rem;
}

.lang-switcher select {
  background: rgba(3, 8, 20, 0.5);
  border: 1px solid rgba(160, 210, 245, 0.2);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.3s ease, color 0.3s ease;
}

.lang-switcher select:hover {
  border-color: rgba(160, 210, 245, 0.4);
  color: var(--text-primary);
}

.lang-switcher select:focus-visible {
  outline: 2px solid rgba(160, 240, 255, 0.8);
  outline-offset: 2px;
}

.lang-switcher select option {
  background: var(--bg-mid);
  color: var(--text-primary);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .game-canvas {
    width: 100%;
  }
}

/* --- Mobile portrait: fill viewport --- */
@media (max-width: 600px) {
  html, body {
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    margin: 0;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 8px 6px;
    gap: 6px;
    height: 100%;
    grid-template-rows: auto 1fr;
    align-items: stretch;
  }

  .hud-panel {
    padding: 8px 10px;
    border-radius: 12px;
  }

  .hud-panel h1 {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }

  .hud-panel p {
    display: none;
  }

  .back-link {
    font-size: 0.82rem;
    margin-bottom: 2px;
  }

  .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .stats div {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.82rem;
  }

  .stats span {
    font-size: 0.78rem;
  }

  .mute-btn,
  .fullscreen-btn {
    padding: 6px;
    font-size: 0.82rem;
    margin-top: 4px;
  }

  .restart-btn {
    padding: 8px;
    font-size: 0.88rem;
    margin-top: 4px;
  }

  .symbiosis-action-btn {
    padding: 8px;
    font-size: 0.95rem;
    min-height: 44px;
    margin-top: 4px;
  }

  .game-canvas {
    width: 100%;
    height: auto;
    max-height: 100%;
    border-radius: 12px;
    min-height: 0;
  }
}

/* --- Very short phones --- */
@media (max-width: 600px) and (max-height: 620px) {
  .layout {
    padding: 4px 4px;
    gap: 4px;
  }

  .hud-panel {
    padding: 6px 8px;
  }

  .hud-panel h1 {
    font-size: 1rem;
    margin-bottom: 2px;
  }

  .back-link {
    display: none;
  }

  .stats {
    gap: 3px;
  }

  .stats div {
    padding: 3px 6px;
    font-size: 0.78rem;
  }

  .mute-btn,
  .fullscreen-btn {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .restart-btn,
  .mute-btn,
  .symbiosis-action-btn {
    transition: none;
  }
}
