:root {
  color-scheme: dark;
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #050b13;
  --bg-gradient: radial-gradient(circle at 20% 20%, rgba(61, 217, 214, 0.25), transparent 55%),
    radial-gradient(circle at 80% 0%, rgba(255, 87, 87, 0.1), transparent 50%);
  --panel: rgba(7, 14, 24, 0.9);
  --panel-alt: rgba(9, 18, 30, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5fbff;
  --muted: #98a7ba;
  --accent: #3dd9d6;
  --accent-soft: rgba(61, 217, 214, 0.2);
  --danger: #ff5757;
  --accent-warm: #ffbd59;
  --accent-cool: #42d9ff;
  --focus: #f7f372;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

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

body {
  margin: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg-gradient), var(--bg);
  color: var(--text);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Site Navigation */
.site-nav {
  flex-shrink: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 18, 43, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.65rem 1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  gap: 1rem;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-cool));
  box-shadow: 0 0 14px rgba(255, 189, 89, 0.7);
}

.nav-title {
  color: #fff;
}

.site-nav nav {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 0.55rem 0.9rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
  cursor: pointer;
}

.nav-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn.ghost {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text);
  background: transparent;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn.patreon {
  border: none;
  background: linear-gradient(120deg, #ff4e6a, #ff9557);
  color: #fff8f3;
  box-shadow: 0 20px 35px rgba(255, 115, 123, 0.35);
  position: relative;
  overflow: hidden;
  gap: 0.35rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  transition: transform 150ms ease, box-shadow 150ms ease;
  cursor: pointer;
}

.btn.patreon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 60%);
  opacity: 0;
  transition: opacity 200ms ease;
}

.btn.patreon:hover::after,
.btn.patreon:focus-visible::after {
  opacity: 1;
}

.btn.patreon:hover {
  transform: translateY(-3px) scale(1.02);
}

.nav-patreon {
  box-shadow: 0 14px 26px rgba(255, 115, 123, 0.3);
}

.nav-patreon:hover {
  transform: translateY(-2px);
}

.game-header {
  flex-shrink: 0;
  background: var(--panel);
  border-radius: 16px;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  padding-bottom: 1rem;
}

.xp-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #bf5af2, #3dd9d6);
  box-shadow: 0 0 10px rgba(191, 90, 242, 0.5);
  transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.header-brand {
  display: flex;
  flex-direction: column;
}

.header-brand h1 {
  margin: 0;
  font-size: 1.1rem;
  white-space: nowrap;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: var(--muted);
}

.header-hud {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.hud-weapons {
  display: flex;
  gap: 0.4rem;
}

.weapon-slot {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
}

.weapon-slot.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft);
  transform: scale(1.1);
}

.weapon-slot.empty {
  opacity: 0.3;
}

.slot-key {
  position: absolute;
  top: -6px;
  left: -6px;
  font-size: 0.6rem;
  background: var(--bg);
  color: var(--muted);
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.slot-icon {
  font-size: 1.2rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-item .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.hud-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  font-family: monospace;
  text-shadow: 0 0 10px rgba(61, 217, 214, 0.4);
}

#level-display {
  color: #bf5af2;
  text-shadow: 0 0 10px rgba(191, 90, 242, 0.4);
}

#best-display {
  color: #f1fa8c;
  text-shadow: 0 0 10px rgba(241, 250, 140, 0.4);
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.feedback-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.game-layout {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.canvas-shell {
  position: relative;
  background: var(--panel);
  border-radius: 16px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0a141a;
  border-radius: 10px;
}

.overlay {
  position: absolute;
  inset: 0.5rem;
  border-radius: 12px;
  background: rgba(5, 10, 18, 0.92);
  display: none; /* Changed from flex */
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.overlay.visible {
  display: flex; /* Show as flex when visible */
  opacity: 1;
  pointer-events: auto;
}

.overlay-content {
  width: 100%;
  max-width: 900px;
  max-height: 100%;
  overflow-y: auto;
}

.overlay-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  align-items: center;
}

.overlay-figure {
  margin: 0;
}

.overlay-figure img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}

.overlay-copy {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.overlay-copy h2 {
  margin: 0;
  font-size: 1.5rem;
}

.overlay-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.caption-text {
  font-size: 0.8rem !important;
  font-style: italic;
  opacity: 0.7;
}

.leaderboard {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 0.5rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn.primary {
  background: var(--accent);
  color: #041316;
  box-shadow: 0 10px 25px rgba(61, 217, 214, 0.35);
  align-self: flex-start;
  padding: 0.7rem 1.5rem;
}

.btn.primary:hover,
.btn.primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(61, 217, 214, 0.45);
}

.overlay-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.feedback-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 15, 0.8);
  z-index: 100;
}

.feedback-modal.open {
  display: flex;
}

.feedback-modal .modal-panel {
  background: var(--panel);
  border-radius: 24px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  width: min(420px, calc(100% - 2rem));
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.feedback-modal form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.feedback-modal label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--muted);
}

input,
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

textarea {
  resize: vertical;
}

.feedback-modal button[type="submit"] {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  background: var(--accent);
  color: #041316;
  cursor: pointer;
  align-self: flex-start;
}

.feedback-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.5rem;
}

.upgrade-overlay {
  backdrop-filter: blur(8px);
  background: rgba(5, 10, 18, 0.85);
}

.death-shop {
  background: rgba(0, 0, 0, 0.4);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-top: 1rem;
}

.shop-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.shop-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.2s ease;
  text-align: left;
}

.shop-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.obol-count {
  color: #f1fa8c;
  font-weight: bold;
}

.upgrade-modal {
  max-width: 600px !important;
  background: var(--panel);
  border: 1px solid var(--accent-soft);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: center;
  text-align: center;
}

.upgrade-header h2 {
  font-size: 2.5rem;
  margin: 0.5rem 0;
  color: var(--accent);
}

.next-level-info {
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.upgrade-btn {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 1.5rem !important;
  padding: 1.25rem 2rem !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  text-align: left !important;
}

.upgrade-icon {
  font-size: 2rem;
}

.upgrade-text {
  display: flex;
  flex-direction: column;
}

.upgrade-text strong {
  font-size: 1.1rem;
  color: var(--text);
}

.upgrade-text small {
  color: var(--muted);
}

.rarity-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 0.5rem;
  text-transform: uppercase;
}

.rarity-common .rarity-tag { background: #98a7ba; color: #000; }
.rarity-uncommon .rarity-tag { background: #3dd9d6; color: #000; }
.rarity-rare .rarity-tag { background: #bf5af2; color: #000; }
.rarity-epic .rarity-tag { background: #ff9f1c; color: #000; }
.rarity-legendary .rarity-tag { background: #f1fa8c; color: #000; }

.upgrade-btn.rarity-uncommon { border-color: #3dd9d6 !important; }
.upgrade-btn.rarity-rare { border-color: #bf5af2 !important; }
.upgrade-btn.rarity-epic { border-color: #ff9f1c !important; }
.upgrade-btn.rarity-legendary { border-color: #f1fa8c !important; }

.upgrade-btn.rarity-uncommon:hover { background: rgba(61, 217, 214, 0.1) !important; }
.upgrade-btn.rarity-rare:hover { background: rgba(191, 90, 242, 0.1) !important; }
.upgrade-btn.rarity-epic:hover { background: rgba(255, 159, 28, 0.1) !important; }
.upgrade-btn.rarity-legendary:hover { background: rgba(241, 250, 140, 0.1) !important; }

@media (max-width: 800px) {
  body {
    padding: 0.5rem;
  }

  .game-header {
    padding: 0.5rem 1rem;
    gap: 1rem;
  }

  .overlay-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .overlay-copy {
    text-align: center;
    align-items: center;
  }
  
  .btn.primary {
    align-self: center;
  }
  
  .header-hud {
    gap: 1rem;
  }
  
  .header-brand h1 {
    display: none;
  }
}
