/* Fonts loaded locally via <link> in HTML */
:root {
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-color: #060911;
  --bg-card: rgba(10, 16, 30, 0.8);
  --primary: #00f3ff;
  --primary-glow: rgba(0, 243, 255, 0.4);
  --emerald: #00e5a3;
  --gold: #ffd700;
  --rose: #ff80bf;
  --violet: #b000ff;
  --text-main: #f0f4fc;
  --text-muted: #8899b8;
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-active: rgba(0, 229, 163, 0.5);
}

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

body {
  font-family: var(--font-body);
  background: radial-gradient(circle at center, #091220 0%, #03060c 100%);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
}

.game-container {
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
}

/* Header & Stats Bar */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 8px 14px;
}

.back-btn {
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.back-btn:hover {
  background: rgba(0, 229, 163, 0.15);
  border-color: var(--emerald);
  transform: translateX(-2px);
}

.stats-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
  font-size: 0.65rem;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--emerald);
}

.stat-badge.highlight .stat-value {
  color: var(--gold);
}

.action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flow-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: linear-gradient(135deg, #00e5a3, #009970);
  color: #030812;
  box-shadow: 0 4px 14px rgba(0, 229, 163, 0.4);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
}

.flow-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 229, 163, 0.6);
}

.flow-btn.flowing {
  background: linear-gradient(135deg, #ff80bf, #ff3366);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(255, 51, 102, 0.4);
}

.flow-btn.flowing:hover {
  box-shadow: 0 6px 20px rgba(255, 51, 102, 0.6);
}

.glass-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.glass-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--emerald);
}

.icon-btn {
  padding: 6px 10px;
  font-size: 0.95rem;
}

.donate-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(255, 183, 0, 0.2), rgba(0, 229, 163, 0.2));
  border-color: rgba(255, 183, 0, 0.4);
  color: #ffd700;
  white-space: nowrap;
}

.donate-btn:hover {
  background: linear-gradient(135deg, rgba(255, 183, 0, 0.35), rgba(0, 229, 163, 0.35));
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

/* Canvas Wrapper */
.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 7 / 6;
  background: #040810;
  border-radius: 20px;
  border: 1px solid var(--border-glass);
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 229, 163, 0.04);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Stage Control Bar (Info + Start/Stop Actions) */
.stage-control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-glass);
  gap: 12px;
}

.stage-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.stage-name-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--emerald);
  font-family: var(--font-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-hint-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stage-play-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reset-btn {
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* Overlay Displays */
.canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 14, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.canvas-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.overlay-card {
  text-align: center;
  padding: 24px;
  max-width: 440px;
  background: rgba(14, 22, 38, 0.92);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
  position: relative;
  z-index: 11;
  pointer-events: auto;
}

#btn-resume-game {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.primary-btn {
  background: linear-gradient(135deg, #00e5a3, #009970);
  color: #030812;
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 229, 163, 0.35);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0, 229, 163, 0.55);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--emerald);
}

.donate-accent-btn {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  color: #090a10;
  border: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.donate-accent-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

/* Footer Hints */
.controls-footer {
  text-align: center;
  padding: 2px 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Mobile Responsive Optimization */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
    justify-content: center;
    padding: 8px 6px 16px;
  }

  .game-container {
    width: 100%;
    max-width: 100%;
    padding: 0;
    gap: 8px;
  }

  .game-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    gap: 8px;
    border-radius: 14px;
  }

  .back-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
    order: 1;
  }

  .action-btns {
    order: 2;
    gap: 6px;
  }

  .action-btns .icon-btn {
    padding: 5px 8px;
    font-size: 0.88rem;
  }

  .action-btns .donate-btn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  .stats-group {
    order: 3;
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 6px;
  }

  .stat-badge {
    flex: 1;
    padding: 4px 6px;
    border-radius: 8px;
    min-width: 0;
  }

  .stat-label {
    font-size: 0.6rem;
    letter-spacing: 0.2px;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .stage-control-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 14px;
  }

  .stage-meta {
    align-items: center;
    text-align: center;
  }

  .stage-name-text {
    font-size: 0.88rem;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
  }

  .stage-hint-text {
    font-size: 0.74rem;
    text-align: center;
    line-height: 1.3;
  }

  .stage-play-actions {
    display: flex;
    width: 100%;
    gap: 8px;
  }

  .flow-btn {
    flex: 2;
    justify-content: center;
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .reset-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 10px;
    font-size: 0.85rem;
  }

  .canvas-wrapper {
    border-radius: 14px;
  }

  .controls-footer {
    font-size: 0.72rem;
    padding: 4px;
    line-height: 1.4;
  }
}

/* Extra Small Screens (iPhone SE, 320px - 360px) */
@media (max-width: 360px) {
  .game-container {
    padding: 4px;
    gap: 6px;
  }
  .game-header {
    padding: 6px 8px;
  }
  .stat-value {
    font-size: 0.85rem;
  }
  .stage-name-text {
    font-size: 0.82rem;
  }
  .flow-btn {
    font-size: 0.82rem;
    padding: 8px 10px;
  }
}
