:root {
  --bg-gradient: radial-gradient(circle at center, #1e1b4b 0%, #0f172a 100%);
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --color-primary: #eab308;
  --color-primary-glow: rgba(234, 179, 8, 0.5);
  --color-danger: #ef4444;
  --color-danger-glow: rgba(239, 68, 68, 0.5);
  --color-success: #22c55e;
  --color-success-glow: rgba(34, 197, 94, 0.5);
  --color-oxygen: #06b6d4;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-body);
}

#app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100vh;
  padding: 8px 12px;
  max-width: 1024px;
  margin: 0 auto;
}

/* Glass Panels */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.glass-panel-heavy {
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

#game-hud {
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-badge {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 0.92rem;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 0 14px var(--color-primary-glow);
}

/* Bars: HP, Oxygen & Boss */
.bar-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bar-container.hidden {
  display: none !important;
}

.bar-icon {
  font-size: 0.95rem;
}

.bar-track {
  width: 75px;
  height: 9px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  overflow: hidden;
}

.bar-track.boss-track {
  width: 90px;
  height: 10px;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.2s linear;
}

.bar-fill.hp { background: linear-gradient(90deg, #ef4444, #dc2626); }
.bar-fill.o2 { background: linear-gradient(90deg, #38bdf8, #0284c7); }
.bar-fill.boss { background: linear-gradient(90deg, #a855f7, #c084fc); }

.hud-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
}

.stat-label {
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

/* Canvas Wrapper */
#canvas-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 800px;
  max-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: #090d16;
}

#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Overlay Screens */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 100;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-screen.active {
  opacity: 1;
  visibility: visible;
}

.menu-card {
  width: 100%;
  max-width: 480px;
  max-height: 95%;
  overflow-y: auto;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.menu-card.small {
  max-width: 380px;
}

.logo-area .logo-icon {
  font-size: 2.8rem;
  display: block;
  margin-bottom: 2px;
}

.logo-area h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #facc15, #f59e0b, #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.logo-area .subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.guide-box {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 14px;
  padding: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.guide-box h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #f1f5f9;
}

.guide-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 12px;
}

.guide-item .emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.guide-item strong {
  display: block;
  font-size: 0.85rem;
  color: #fff;
}

.guide-item p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.btn-primary {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
  border: none;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: 14px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 8px 24px var(--color-primary-glow);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px var(--color-primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
}

.danger-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 8px 24px var(--color-danger-glow);
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid var(--color-success);
  padding: 5px 14px;
  border-radius: 20px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.88rem;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid var(--color-danger);
  padding: 5px 14px;
  border-radius: 20px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.88rem;
}

.trivia-box {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.trivia-icon {
  font-size: 1.4rem;
}

.trivia-box p {
  font-size: 0.82rem;
  color: #e0f2fe;
  line-height: 1.35;
}

.stats-summary {
  display: flex;
  gap: 20px;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 18px;
  border-radius: 14px;
  width: 100%;
  justify-content: center;
}

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

.summary-item .label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.summary-item .val {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
}

/* Touch Controls Layout */
#mobile-controls {
  width: 100%;
  max-width: 800px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  z-index: 20;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#mobile-controls.menu-active {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.controls-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.dpad-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dpad-center {
  width: 32px;
  height: 32px;
}

.dpad-btn {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 10px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dpad-btn:active {
  background: rgba(234, 179, 8, 0.5);
  transform: scale(0.92);
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-btn {
  padding: 10px 18px;
  border-radius: 12px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.action-btn:active {
  transform: scale(0.94);
}

.jump-btn {
  background: linear-gradient(135deg, #0284c7, #0369a1);
}

.throw-btn {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 680px) {
  #game-hud {
    padding: 0 8px;
    height: 48px;
  }
  .stat-label { display: none; }
  .bar-track { width: 55px; }

  #mobile-controls {
    height: 95px;
    padding: 6px;
  }

  .dpad-btn {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }

  .action-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}
