:root {
  --accent: #7c4dff;
  --accent-soft: #b388ff;
  --space-deep: #0d0221;
  --space-mid: #1a0a2e;
  --hud: #e8e0ff;
  --hud-dim: #9e8ec9;
  --star: rgba(255, 255, 255, 0.85);
  --panel-bg: rgba(18, 8, 40, 0.92);
  --panel-border: #5e35b1;
  --text-main: #f3e5f5;
  --text-muted: #ce93d8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text-main);
  line-height: 1.45;
  position: relative;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, #2d1b4e 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 80% 100%, #1a237e55 0%, transparent 50%),
    linear-gradient(180deg, #0a0018 0%, #12082a 45%, #0d0221 100%);
}

.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, var(--star) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 65%, rgba(255, 255, 255, 0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 30%, rgba(255, 255, 255, 0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 80%, rgba(255, 255, 255, 0.45) 0%, transparent 100%),
    radial-gradient(2px 2px at 50% 50%, rgba(200, 180, 255, 0.35) 0%, transparent 100%);
  background-size: 100% 100%;
  opacity: 0.65;
  pointer-events: none;
}

.app {
  min-height: 100%;
  max-width: 100%;
  padding: clamp(0.65rem, 1.2vw, 1rem) clamp(0.65rem, 1.2vw, 1rem) clamp(0.65rem, 1.2vw, 1rem)
    clamp(1rem, 2.4vw, 2rem);
  display: flex;
  flex-direction: column;
}

.layout-main {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: clamp(0.45rem, 1vw, 1rem);
  flex: 1;
  min-height: min(calc(100vh - 2rem), 1100px);
}

.layout-sidebar {
  flex: 0 0 clamp(320px, 33vw, 460px);
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  overflow-y: auto;
  padding-left: clamp(0.25rem, 0.8vw, 0.65rem);
  padding-right: clamp(0.15rem, 0.5vw, 0.35rem);
}

.layout-game {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
}

.header {
  text-align: left;
}

.header h1 {
  margin: 0;
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: clamp(1.95rem, 3.1vw, 2.65rem);
  font-weight: 700;
  color: var(--text-main);
  text-shadow:
    0 0 20px rgba(179, 136, 255, 0.45),
    2px 2px 0 #311b92;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.hint--rules {
  font-size: clamp(0.82rem, 1.15vw, 0.95rem);
  font-weight: 600;
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: var(--panel-bg);
  border-radius: 14px;
  border: 3px dashed var(--accent-soft);
  line-height: 1.55;
  color: var(--hud-dim);
}

.panel {
  background: var(--panel-bg);
  border: 4px solid var(--panel-border);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  box-shadow:
    0 6px 0 rgba(94, 53, 177, 0.35),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

.panel--controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-soft);
}

select {
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  border: 3px solid var(--accent);
  background: #1a0a2e;
  color: var(--text-main);
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn {
  padding: 0.75rem 1.15rem;
  border-radius: 16px;
  border: 4px solid #4a148c;
  background: #fff;
  color: #311b92;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 4px 0 #311b92;
}

.btn--start-wide {
  width: 100%;
  padding: 1rem 1.35rem;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #311b92;
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #311b92;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: 0 2px 0 #555;
}

.btn--primary {
  background: linear-gradient(180deg, #ffd54f, #ffb300);
  border-color: #f57f17;
  color: #4e342e;
  box-shadow: 0 4px 0 #e65100;
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 6px 0 #e65100;
}

.side-stats {
  padding: 0.75rem 0.65rem;
}

.stats--compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.stat-bubble {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.3;
  padding: 0.55rem 0.45rem;
  background: linear-gradient(180deg, rgba(49, 27, 146, 0.55), rgba(26, 10, 46, 0.9));
  border: 3px solid var(--accent);
  border-radius: 14px;
  color: var(--hud);
  text-align: center;
}

.stat-bubble strong {
  display: inline-block;
  margin-top: 0.2rem;
  color: #ffab91;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  font-weight: 800;
  line-height: 1.1;
}

.ammo-panel {
  margin-top: 0.55rem;
  padding: 0.55rem 0.5rem;
  background: rgba(26, 10, 46, 0.65);
  border: 2px solid var(--accent);
  border-radius: 12px;
}

.ammo-panel__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}

.ammo-panel__label {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent-soft);
}

.ammo-panel__count {
  font-size: 0.9rem;
  color: var(--hud);
  font-weight: 700;
}

.ammo-panel__count strong {
  color: #ffab91;
  font-size: 1.25rem;
}

.ammo-bar {
  height: 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(179, 136, 255, 0.35);
  overflow: hidden;
}

.ammo-bar__inner {
  height: 100%;
  width: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #7c4dff, #b388ff);
  transform-origin: left center;
  transition: width 0.08s linear;
}

.game-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(90vh, 1080px);
}

.canvas-wrap {
  position: relative;
  --sidebar-gutter: clamp(300px, 30vw, 440px);
  --field-max: min(1200px, calc(100vw - var(--sidebar-gutter) - 2.5rem));
  width: min(96vmin, 96vh, var(--field-max));
  height: min(96vmin, 96vh, var(--field-max));
  max-width: 100%;
  max-height: min(96vh, 1200px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  overflow: hidden;
  border: 6px solid var(--panel-border);
  box-shadow:
    0 0 0 4px rgba(179, 136, 255, 0.2),
    0 14px 0 rgba(49, 27, 146, 0.35),
    0 24px 48px rgba(0, 0, 0, 0.45);
  background: #0a0018;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: rgba(10, 0, 24, 0.88);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
  text-align: center;
}

.overlay.hidden {
  display: none;
}

.overlay__text {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(1.35rem, 3vw, 1.95rem);
  font-weight: 600;
  color: var(--text-main);
  max-width: 24ch;
}

.btn--overlay-big {
  padding: 1.15rem 2.5rem;
  font-size: clamp(1.3rem, 2.8vw, 1.65rem);
  min-width: 14rem;
}

kbd {
  display: inline-block;
  padding: 0.15rem 0.42rem;
  margin: 0 0.06rem;
  border-radius: 8px;
  background: linear-gradient(180deg, #2d1b69, #1a0a2e);
  border: 2px solid var(--accent);
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--hud);
  box-shadow: 0 2px 0 var(--panel-border);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .layout-main {
    flex-direction: column;
    min-height: auto;
  }

  .layout-sidebar {
    flex: none;
    max-width: none;
    width: 100%;
    order: 2;
  }

  .layout-game {
    order: 1;
    min-height: auto;
  }

  .game-stage {
    min-height: auto;
  }

  .canvas-wrap {
    width: min(96vw, 96vmin);
    height: min(96vw, 96vmin);
    max-height: 85vh;
  }

  .header {
    text-align: center;
  }
}
