/* Mobile-First Game Styles */

html, body {
  overflow: hidden !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  width: 100vw !important;
  position: fixed;
  top: 0;
  left: 0;
  touch-action: none !important;
  overscroll-behavior: none !important;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-color);
}

@media (min-width: 769px) {
  html, body {
    padding: 15px;
  }
}

#game-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel-bg);
  padding: 8px 6px;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  box-sizing: border-box;
  justify-content: space-between;
}

@media (min-width: 769px) {
  #game-container {
    flex-direction: row;
    gap: 24px;
    padding: 18px 22px;
    border-radius: var(--border-radius-lg);
    width: auto;
    height: auto;
    max-height: 96dvh;
    justify-content: flex-start;
    align-items: center;
  }
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
  flex: 1;
  justify-content: center;
}

@media (min-width: 769px) {
  #game-wrapper {
    width: auto;
    max-height: 100%;
    gap: 10px;
    flex: none;
  }
}

canvas {
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: #222;
  transition: border-color 0.8s ease;
  width: 100%;
  height: auto;
  display: block;
  box-sizing: border-box;
  aspect-ratio: 800 / 750;
  max-height: calc(100dvh - 165px);
  object-fit: contain;
}

@media (min-width: 769px) {
  canvas {
    aspect-ratio: 800 / 750;
    max-height: min(750px, calc(96dvh - 110px));
    width: auto;
    max-width: 100%;
  }
}

#timer-bars-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 28px;
}

.timer-bar-wrapper {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--border-radius-sm);
  height: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  transform-origin: left;
  transition: transform 0.1s linear;
}

.timer-bar-label {
  position: absolute;
  width: 100%;
  text-align: center;
  font-family: var(--font-title);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 2;
}

#sidebar {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--sidebar-bg);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

#sidebar hr,
#sidebar .dev-link-box {
  display: none !important;
}

@media (min-width: 769px) {
  #sidebar {
    width: 220px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
    padding: 20px;
  }
  #sidebar hr {
    display: block !important;
  }
  #sidebar .dev-link-box {
    display: block !important;
  }
}

.panel-box {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 2px;
  border-radius: var(--border-radius-sm);
}

@media (min-width: 769px) {
  .panel-box {
    background: transparent;
    padding: 0;
    gap: 4px;
    text-align: left;
  }
}

.panel-label {
  font-size: clamp(7.5px, 2vw, 9.5px);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 769px) {
  .panel-label {
    font-size: 11px;
    letter-spacing: 1.5px;
    white-space: normal;
  }
}

.panel-value {
  font-family: var(--font-title);
  font-size: clamp(12px, 3.2vw, 16px);
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 769px) {
  .panel-value {
    font-size: 22px;
    white-space: normal;
  }
}

#speedometer { color: var(--neon-blue); }

#biome-name {
  color: var(--neon-green);
  text-transform: uppercase;
  font-size: clamp(10px, 2.8vw, 14px);
  transition: color 0.5s;
}

@media (min-width: 769px) {
  #biome-name {
    font-size: 18px;
  }
}

#score { color: var(--neon-yellow); }
#highscore { color: #ffaa00; }
#coins { color: var(--neon-yellow); }
#shield-counter {
  color: var(--neon-blue);
  letter-spacing: 1px;
}

/* Screens overlays - Mobile First */
.screen {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 18, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  z-index: 100;
  box-sizing: border-box;
  padding: 14px 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  animation: screenFadeIn 0.25s ease;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@media (min-width: 769px) {
  .screen {
    padding: 24px;
    border-radius: inherit;
  }
}

.screen h1 {
  font-size: clamp(20px, 5.5vw, 36px);
  font-weight: 900;
  margin-top: 0;
  margin-bottom: 4px;
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 0 20px rgba(52, 152, 219, 0.3);
  background: linear-gradient(45deg, var(--neon-cyan), var(--neon-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.screen p {
  font-size: clamp(11px, 2.8vw, 13.5px);
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  text-align: center;
  max-width: 95%;
  line-height: 1.4;
}

@media (min-width: 769px) {
  .screen p {
    margin-bottom: 18px;
    max-width: 85%;
    line-height: 1.5;
  }
}

/* Game Over Stats Grid - Mobile First */
.game-over-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 10px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-md);
  padding: 6px 4px;
  text-align: center;
  box-sizing: border-box;
}

@media (min-width: 769px) {
  .stat-box {
    padding: 10px 12px;
  }
}

.stat-box .stat-label {
  font-size: clamp(7.5px, 2vw, 9px);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.stat-box .stat-val {
  font-family: var(--font-title);
  font-size: clamp(13px, 3.2vw, 18px);
  font-weight: 800;
}

.record-banner {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), rgba(255, 170, 0, 0.25), rgba(255, 215, 0, 0.15));
  border: 1px solid #ffaa00;
  border-radius: var(--border-radius-md);
  padding: 5px 8px;
  text-align: center;
  color: #ffd700;
  font-family: var(--font-title);
  font-size: clamp(10px, 2.8vw, 12px);
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 8px;
  box-shadow: 0 0 12px rgba(255, 170, 0, 0.2);
  box-sizing: border-box;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  align-items: stretch;
}

@media (min-width: 600px) {
  .btn-group {
    flex-direction: row;
    gap: 12px;
    max-width: 480px;
  }
}

.screen .btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 12.5px;
  min-height: 44px;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 769px) {
  .screen .btn {
    width: auto;
    padding: 14px 26px;
    font-size: 13.5px;
    min-height: 48px;
  }
}

.hidden {
  display: none !important;
}

/* Mobile Controls Overlay - Ergonomic Thumb Zones */
.mobile-controls {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  box-sizing: border-box;
  gap: 8px;
  min-height: 52px;
}

@media (min-width: 769px) {
  .mobile-controls {
    display: none;
    padding: 8px 0;
  }
  
  @media (pointer: coarse) {
    .mobile-controls {
      display: flex;
    }
  }
}

.mobile-btn {
  background: rgba(20, 20, 30, 0.85);
  border: 2px solid rgba(102, 252, 225, 0.35);
  color: var(--neon-cyan);
  height: clamp(52px, 14vw, 75px);
  border-radius: 14px;
  font-size: clamp(26px, 7vw, 42px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  box-shadow: 0 0 16px rgba(102, 252, 225, 0.2), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: background 0.1s ease, box-shadow 0.1s ease, transform 0.08s ease;
  touch-action: manipulation;
  flex: 1;
  min-height: 48px;
}

.mobile-btn:active {
  transform: scale(0.94);
  background: rgba(102, 252, 225, 0.25);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 22px rgba(102, 252, 225, 0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  color: #fff;
}

.mobile-btn-pause {
  border-color: rgba(52, 152, 219, 0.35);
  color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.1);
  width: clamp(48px, 13vw, 64px);
  height: clamp(48px, 13vw, 64px);
  font-size: clamp(20px, 5.5vw, 28px);
  flex: 0 0 auto;
  border-radius: 12px;
  min-height: 48px;
}

.mobile-btn-pause:active {
  background: rgba(52, 152, 219, 0.25);
  border-color: var(--neon-blue);
  box-shadow: 0 0 18px rgba(52, 152, 219, 0.45);
}

/* Desktop Scale Responsivity */
@media (max-width: 1150px) and (min-width: 769px) {
  #game-container {
    transform: scale(0.88);
    transform-origin: center center;
  }
}

@media (max-width: 950px) and (min-width: 769px) {
  #game-container {
    transform: scale(0.72);
  }
}


