/* ==========================================================================
   FISH RAIN — A Stab The Finger Arcade Game
   Visual Theme: Stormy Maritime Slate, Electric Water Blue, Rain Slicker Gold
   ========================================================================== */

:root {
  --bg-dark: #090e17;
  --panel-deep: #111827;
  --panel-card: #1b2436;
  --panel-hover: #243048;
  --border-slate: #334155;
  --accent-yellow: #facc15;
  --accent-blue: #38bdf8;
  --accent-cyan: #22d3ee;
  --accent-green: #4ade80;
  --accent-orange: #fb923c;
  --accent-red: #ef4444;
  --accent-purple: #c084fc;

  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

button,
input,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent-yellow);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   TOP SITE HEADER
   ========================================================================== */

.site-header {
  background: var(--panel-deep);
  border-bottom: 2px solid var(--border-slate);
  padding: 10px 18px;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.site-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: var(--accent-yellow);
  text-transform: uppercase;
}

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

.brand-link:hover {
  text-decoration: underline;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.btn-nav {
  background: var(--panel-card);
  color: var(--text-main);
  border: 1px solid var(--border-slate);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn-nav:hover:not(:disabled) {
  background: var(--panel-hover);
  border-color: var(--accent-blue);
}

.btn-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #facc15 0%, #f59e0b 100%);
  color: #0f172a;
  border: 2px solid #fef08a;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(250, 204, 21, 0.25);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn-tool {
  background: #1e293b;
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
}

.btn-tool:hover {
  background: rgba(56, 189, 248, 0.15);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-danger {
  border-color: var(--accent-red);
  color: #fca5a5;
}

/* ==========================================================================
   MAIN CONTAINER & MENU SCREEN
   ========================================================================== */

.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 18px 40px;
}

.hero-banner {
  background: linear-gradient(135deg, #162238 0%, #0f172a 100%);
  border: 2px solid var(--border-slate);
  border-left: 6px solid var(--accent-yellow);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-text {
  flex: 1 1 520px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-blue);
  margin-bottom: 4px;
}

.hero-text h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  color: var(--text-main);
}

.hero-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hero-cta-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.btn-hero-play {
  font-size: 1.08rem;
  padding: 14px 24px;
  white-space: nowrap;
}

.hero-cta-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.setup-section {
  margin-bottom: 24px;
}

.section-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-heading {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: var(--accent-blue);
}

.section-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-dim);
}

/* Global Leaderboard Auto-Submit Card */
.global-pref-card {
  background: var(--panel-card);
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.global-pref-card-modal {
  margin-bottom: 14px;
}

.global-pref-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pref-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}

.pref-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-yellow);
}

.pref-nickname-group {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.nickname-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pref-field-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.nickname-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pref-nickname-input {
  background: #0f172a;
  color: var(--text-main);
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.92rem;
  font-weight: 700;
  width: 190px;
}

.pref-public-notice {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.pref-feedback-msg {
  margin: 6px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fca5a5;
}

/* Bodies of Water Environment Cards */
.env-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 14px;
}

.env-card {
  background: var(--panel-card);
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.env-card.is-unlocked:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.env-card.is-locked {
  opacity: 0.62;
  background: #131b2b;
}

.env-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.env-level-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.env-mult-pill {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-yellow);
}

.env-card h3 {
  margin: 6px 0 4px;
  font-size: 1.06rem;
}

.env-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.env-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.env-card-actions {
  display: flex;
  gap: 8px;
}

.env-card-actions button {
  width: 100%;
}

/* Control Cards Grid */
.control-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.control-card {
  background: var(--panel-card);
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.control-card.is-selected {
  border-color: var(--accent-yellow);
  background: rgba(250, 204, 21, 0.08);
}

.control-card h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
  color: var(--text-main);
}

.control-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

/* Field Guide Grid */
.field-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.guide-card {
  background: var(--panel-card);
  border: 1px solid var(--border-slate);
  border-left-width: 5px;
  border-radius: var(--radius-md);
  padding: 14px;
}

.guide-card h3 {
  margin: 0 0 6px;
  font-size: 0.96rem;
}

.guide-card p {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.guide-fish { border-left-color: var(--accent-blue); }
.guide-bonus { border-left-color: var(--accent-orange); }
.guide-neutral { border-left-color: var(--text-dim); }
.guide-hazard { border-left-color: var(--accent-red); }

/* ==========================================================================
   SCREEN 2: ACTIVE GAMEPLAY HUD, CANVAS & OVERLAYS
   ========================================================================== */

.game-hud-bar {
  background: var(--panel-deep);
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.hud-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-eyebrow {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.hud-env-title {
  font-size: 1.05rem;
  color: var(--accent-blue);
}

.hud-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hud-score-value {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--accent-yellow);
  line-height: 1.1;
}

.hud-combo-badge {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-green);
}

.hud-block-progress {
  flex: 1 1 220px;
  max-width: 340px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
}

.progress-bar-track {
  height: 10px;
  background: #0f172a;
  border: 1px solid var(--border-slate);
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #4ade80 100%);
  transition: width 0.2s ease;
}

.hud-buffs-row {
  font-size: 0.76rem;
  color: var(--accent-orange);
  font-weight: 700;
}

.hud-lives-icons {
  font-size: 1.15rem;
  letter-spacing: 2px;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Canvas Stage & Overlays */
.canvas-stage-wrapper {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  background: #090d16;
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 560;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stage-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 23, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 95;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay-card {
  background: var(--panel-card);
  border: 2px solid var(--accent-blue);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: auto;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
}

.overlay-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-blue);
  margin-bottom: 8px;
}

.badge-success {
  background: rgba(74, 222, 128, 0.2);
  color: var(--accent-green);
}

.overlay-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: var(--accent-yellow);
}

.overlay-tagline {
  margin: 0 0 14px;
  font-size: 0.94rem;
  color: var(--text-muted);
}

.overlay-challenge-box {
  background: #0f172a;
  border: 1px solid var(--border-slate);
  border-left: 4px solid var(--accent-yellow);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  margin-bottom: 14px;
  font-size: 0.86rem;
}

.overlay-challenge-box p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.overlay-targets-strip {
  font-size: 0.85rem;
  color: var(--accent-green);
  font-weight: 700;
  margin-bottom: 16px;
}

.overlay-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 18px;
  text-align: left;
}

.stat-mini-box {
  background: #0f172a;
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.stat-mini-box span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-dim);
}

.stat-mini-box strong {
  font-size: 1.05rem;
  color: var(--text-main);
}

.overlay-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* On-Screen Touch & Tilt Control Bar */
.touch-controls-bar {
  max-width: 960px;
  margin: 10px auto 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn-touch-steer {
  background: var(--panel-card);
  color: var(--text-main);
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.08s ease;
}

.btn-touch-steer:active,
.btn-touch-steer.is-held {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent-yellow);
  color: var(--accent-yellow);
  transform: scale(0.98);
}

.touch-center-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.touch-mode-pill {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--panel-deep);
  border: 1px solid var(--border-slate);
  padding: 4px 10px;
  border-radius: 999px;
}

.tilt-quick-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ==========================================================================
   SCREEN 3: RESULTS & GLOBAL SUBMISSION
   ========================================================================== */

.results-container {
  max-width: 960px;
  margin: 0 auto;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.result-card {
  background: var(--panel-card);
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.result-card h2,
.result-card h3 {
  margin: 0 0 10px;
  color: var(--accent-yellow);
}

.final-score-banner {
  font-size: 2.3rem;
  font-weight: 900;
  color: var(--accent-yellow);
  margin: 6px 0 12px;
}

.breakdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.breakdown-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 0.9rem;
}

.results-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.global-submit-panel {
  background: var(--panel-card);
  border: 2px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.results-records-strip {
  background: var(--panel-deep);
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ==========================================================================
   MODALS & GLOBAL LEADERBOARD TABLE
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 23, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-dialog {
  background: var(--panel-card);
  border: 2px solid var(--border-slate);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.modal-dialog-wide {
  max-width: 880px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-slate);
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--accent-yellow);
}

.modal-body ul {
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 10px;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--border-slate);
  margin-top: 16px;
}

/* Settings Modal Controls */
.settings-control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.settings-radio-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #0f172a;
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
}

.settings-radio-card input {
  margin-top: 4px;
  accent-color: var(--accent-yellow);
}

.settings-radio-card p {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.tilt-calibration-box {
  background: #0f172a;
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-md);
  padding: 14px;
}

.tilt-calibration-box h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--accent-blue);
}

.tilt-status-text {
  margin: 0 0 12px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.tilt-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

.tilt-slider-row input[type="range"] {
  flex: 1;
  max-width: 240px;
  accent-color: var(--accent-yellow);
}

.tilt-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Global Leaderboard Filters & Table */
.global-scope-note {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.global-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.global-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.global-filters select {
  background: #0f172a;
  color: var(--text-main);
  border: 1px solid var(--border-slate);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.global-status {
  font-size: 0.86rem;
  color: var(--accent-blue);
  margin-bottom: 8px;
}

.global-table-wrap {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.records-table th,
.records-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.records-table th {
  color: var(--text-dim);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.records-table tr.is-player-row {
  background: rgba(250, 204, 21, 0.12);
}

.global-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* In-game screen: hide main site header during active gameplay to maximize vertical view */
body.in-game .site-header,
body:has(#screen-game:not([hidden])) .site-header {
  display: none !important;
}

body.in-game .app-container,
body:has(#screen-game:not([hidden])) .app-container {
  padding-top: 8px;
  padding-bottom: 12px;
}

/* ==========================================================================
   MOBILE & RESPONSIVE ADAPTATIONS
   ========================================================================== */

/* 1. Mobile Portrait & Constrained Viewports: Dialog fills screen and is fully scrollable */
@media (max-width: 900px), (max-height: 650px) {
  .stage-overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    background: rgba(9, 14, 23, 0.92);
    padding: 12px;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .overlay-card {
    max-height: 92vh;
    max-height: 92dvh;
    padding: 14px 16px;
    max-width: 480px;
  }

  .overlay-title {
    font-size: 1.25rem;
    margin-bottom: 6px;
  }

  .overlay-tagline {
    font-size: 0.85rem;
    margin-bottom: 10px;
  }

  .overlay-challenge-box {
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 0.82rem;
  }

  .overlay-targets-strip {
    font-size: 0.8rem;
    margin-bottom: 12px;
  }

  .overlay-actions {
    width: 100%;
  }

  .overlay-actions .btn-primary {
    width: 100%;
    padding: 12px 18px;
    font-size: 1rem;
  }
}

@media (max-width: 680px) {
  .site-title {
    font-size: 1.25rem;
  }
  .hero-banner {
    padding: 14px 16px;
  }
  .game-hud-bar {
    padding: 8px 10px;
    gap: 8px;
  }
  .hud-block-env .hud-env-title {
    font-size: 0.95rem;
  }
  .hud-block-score .hud-score-value {
    font-size: 1.25rem;
  }
  .btn-touch-steer {
    padding: 16px 10px;
    font-size: 0.95rem;
  }
  .overlay-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* 2. Mobile Landscape & Short Viewports: Fits 100% on screen with zero scrolling */
@media (orientation: landscape) and (max-height: 580px), (max-height: 520px) {
  body.in-game {
    overflow: hidden;
  }

  body.in-game .app-container,
  body:has(#screen-game:not([hidden])) .app-container {
    padding: 2px 8px 6px;
    max-width: 100%;
  }

  #screen-game {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    margin: 0 auto;
    overflow: hidden;
  }

  .game-hud-bar {
    width: 100%;
    max-width: 960px;
    padding: 2px 8px;
    margin-bottom: 2px;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }

  .hud-eyebrow,
  .hud-conditions,
  .hud-sub,
  .hud-buffs-row {
    display: none;
  }

  .hud-env-title {
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .hud-score-value {
    font-size: 1.05rem;
    line-height: 1;
  }

  .hud-combo-badge {
    font-size: 0.72rem;
  }

  .hud-block-progress {
    max-width: 130px;
    min-width: 70px;
    flex: 0 1 130px;
  }

  .progress-header strong {
    font-size: 0.72rem;
  }

  .progress-bar-track {
    height: 5px;
    margin: 2px 0 0;
  }

  .hud-lives-icons {
    font-size: 0.95rem;
    letter-spacing: 1px;
  }

  .hud-controls {
    gap: 4px;
    flex-shrink: 0;
  }

  .hud-controls .btn-nav,
  .hud-controls .btn-tool {
    padding: 3px 8px;
    font-size: 0.74rem;
  }

  .canvas-stage-wrapper {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(100vh - 78px);
    max-height: calc(100dvh - 78px);
    aspect-ratio: 960 / 560;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #game-canvas {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 78px);
    max-height: calc(100dvh - 78px);
    object-fit: contain;
    aspect-ratio: 960 / 560;
  }

  .touch-controls-bar {
    width: 100%;
    max-width: 960px;
    margin-top: 2px;
    gap: 8px;
    flex-shrink: 0;
  }

  .btn-touch-steer {
    padding: 7px 14px;
    font-size: 0.85rem;
  }

  .touch-mode-pill {
    padding: 2px 8px;
    font-size: 0.72rem;
  }

  /* Compact overlay card in landscape */
  .overlay-card {
    padding: 10px 14px;
    max-height: 94dvh;
    max-width: 440px;
  }

  .overlay-badge {
    font-size: 0.68rem;
    padding: 2px 8px;
    margin-bottom: 4px;
  }

  .overlay-title {
    font-size: 1.15rem;
    margin-bottom: 4px;
  }

  .overlay-tagline {
    font-size: 0.78rem;
    margin-bottom: 6px;
  }

  .overlay-challenge-box {
    padding: 6px 10px;
    margin-bottom: 6px;
    font-size: 0.78rem;
  }

  .overlay-targets-strip {
    font-size: 0.76rem;
    margin-bottom: 8px;
  }

  .overlay-actions .btn-primary {
    padding: 8px 16px;
    font-size: 0.92rem;
  }
}
