/* Game screen layout — grid, console, action area, hero stats, scrollbars, mobile */

/* Lock the game page to the viewport — no page-level scroll */
html:has(.game-screen), html:has(.game-screen) body { height: 100%; overflow: hidden; }
body:has(.game-screen) .app-nav { display: none; }
body:has(.game-screen)::after { opacity: 0.4; }
.game-screen { -webkit-tap-highlight-color: transparent; }
.game-screen { position: relative; height: calc(100dvh - 2rem); display: flex; flex-direction: column; overflow: hidden; background: var(--theme-bg, #0d0d0d); }

.game-over-banner { background: var(--panel-bg); border: 1px solid var(--border-color); padding: 0.5rem 1rem; text-align: center; font-size: 0.85rem; color: var(--theme-accent); flex-shrink: 0; font-family: 'Lora', Georgia, serif; font-style: italic; }

/* ── Game top bar — floating over content ── */
.game-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  z-index: 10;
  pointer-events: none;
  padding-bottom: 2rem;
}
.game-topbar-home, .game-topbar-menu { pointer-events: auto; }
.game-topbar-home { display: flex; align-items: center; color: var(--theme-accent); transition: color 0.3s; }
.game-topbar-home:hover { color: var(--theme-text); }
.game-topbar-icon { height: 1.8rem; width: auto; }
.game-topbar-menu {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
}
.game-topbar-menu span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--theme-accent);
  transition: background 0.3s;
}
.game-topbar-menu:hover span { background: var(--theme-text); }

/* ── Sidebar game info ── */
.sidebar-game-info {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-game-title {
  font-family: 'Cinzel', 'Palatino Linotype', serif;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--theme-accent);
  margin-bottom: 0.2rem;
}
.sidebar-game-meta {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.sidebar-details-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.sidebar-details-link:hover { color: var(--theme-accent); }

.dev-cheat-toggle { margin-top: 0.3rem; }
.dev-cheat-btn {
  font-family: 'Courier New', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border: 1px solid #555;
  border-radius: 3px;
  background: transparent;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
}
.dev-cheat-btn:hover { border-color: #e8c840; color: #e8c840; }
.dev-cheat-btn.active { border-color: #e8c840; color: #e8c840; background: rgba(232, 200, 64, 0.1); }

/* Grid fills whatever height remains after the banner */
.game-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 320px; gap: 1rem; }
@media (max-width: 768px) { .game-layout { grid-template-columns: 1fr; } }

/* Console panel is a bounded flex column — only turn-log scrolls */
.console-panel { position: relative; display: flex; flex-direction: column; min-height: 0; height: 100%; overflow: hidden; border: 1px solid var(--border-color); background: color-mix(in srgb, var(--theme-bg) 60%, transparent); }
.console-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5rem;
  background: linear-gradient(to bottom, var(--theme-bg) 40%, transparent 100%);
  z-index: 5;
  pointer-events: none;
}
.console-separator { opacity: 0.4; }
.turn-log { flex: 1; min-height: 0; overflow-y: auto; padding: 2.5rem 1rem 1rem; display: flex; flex-direction: column; gap: 1rem; }

/* Action area — stage prompt feel */
.action-area { flex-shrink: 0; border-top: 1px solid var(--border-color); padding: 0.65rem 0.75rem; }
.action-form { display: flex; align-items: center; gap: 0.5rem; }
.action-prompt { font-family: 'Cinzel', serif; font-size: 0.7rem; color: var(--theme-accent); opacity: 0.6; flex-shrink: 0; user-select: none; }
.action-input { flex: 1; background: transparent; color: var(--theme-text); border: none; border-bottom: 1px solid var(--text-dim); padding: 0.4rem 0.25rem; font-family: var(--theme-font); font-size: 1rem; }
.action-input:focus { outline: none; border-bottom-color: var(--theme-accent); }
.action-input:disabled { opacity: 0.4; }

.right-panel { position: relative; display: flex; flex-direction: column; gap: 0.5rem; min-height: 0; overflow-y: auto; font-family: 'Lora', Georgia, serif; }
.right-panel-spacer { height: 3rem; flex-shrink: 0; }
.right-panel::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3rem;
  flex-shrink: 0;
  background: linear-gradient(to top, var(--theme-bg) 20%, transparent 100%);
  pointer-events: none;
  margin-top: -3rem;
}
/* ── Hero stats — primary visual weight ── */
.hero-stat-bar {
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--panel-bg) 80%, var(--theme-accent) 5%);
  padding: 0.85rem 1.1rem;
  font-size: 0.85rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}
.stat-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0.2rem 0; }
.stat-label { font-family: 'Cinzel', serif; font-size: 0.62rem; letter-spacing: 0.18em; color: var(--theme-accent); text-transform: uppercase; opacity: 0.8; }
.stat-value { color: var(--text-bright); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.health-bar-outer { height: 4px; background: var(--border-color); margin-top: 0.5rem; border-radius: 2px; }
.health-bar-inner { height: 4px; background: var(--theme-accent); transition: width 0.3s; border-radius: 2px; }
.momentum-track { display: flex; gap: 3px; margin-top: 0.35rem; }
.momentum-pip { flex: 1; height: 6px; border-radius: 2px; opacity: 0.12; transition: opacity 0.3s, box-shadow 0.3s; }
.momentum-pip.active { opacity: 1; box-shadow: 0 0 6px currentColor; }
.momentum-value { font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: right; }

/* Hide scrollbars but keep scrolling */
.turn-log, .right-panel { scrollbar-width: none; }
.turn-log::-webkit-scrollbar, .right-panel::-webkit-scrollbar { display: none; }

/* Desktop: hamburger hidden, sidebar always visible */
.game-topbar-menu { display: none; }
.mobile-panel-close { display: none; }

@media (max-width: 768px) {
  /* Pin game-screen to viewport — prevents keyboard-induced scroll on iOS */
  body:has(.game-screen) > .container { padding: 0; }
  body:has(.game-screen) .site-footer { display: none; }
  .game-screen { position: fixed; inset: 0; height: 100%; }

  /* Show hamburger on mobile */
  .game-topbar-menu { display: flex; }

  /* Right panel hidden, becomes a full-screen overlay when toggled */
  .right-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--theme-bg);
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    overflow-y: auto;
  }
  .right-panel.mobile-open { display: flex; }

  /* Close bar at top of overlay */
  .mobile-panel-close {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.25rem;
    flex-shrink: 0;
  }
  .mobile-panel-close-label {
    font-family: 'Cinzel', serif;
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--text-muted);
    text-transform: uppercase;
  }
  .mobile-panel-close-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: 'Cinzel', serif;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
  }
}
