/* =========================================================
   The 5:00 PM Friday Escape (සිකුරාදා නිදහස)
   Responsive Mobile Web Styles & Enhanced UI/UX
   ========================================================= */

:root {
  --primary-orange: #ff7a18;
  --sunset-coral: #af002d;
  --lotus-pink: #ff3388;
  --tech-cyan: #00f2fe;
  --emerald-green: #2ecc71;
  --danger-red: #e74c3c;
  --gold-amber: #ffd166;
  --dark-bg: #0d131a;
  --card-bg: rgba(18, 25, 38, 0.92);
  --glass-border: rgba(255, 255, 255, 0.18);
  --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: var(--dark-bg);
  font-family: var(--font-family);
  color: #fff;
  touch-action: none;
}

#game-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  width: var(--app-width, 100vw);
  height: 100%;
  height: -webkit-fill-available;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #1b2636 0%, #0d131a 100%);
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container canvas {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  border-radius: 4px;
}

/* =========================================================
   HUD OVERLAY (TOP BAR)
   ========================================================= */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

.hud-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(13, 19, 26, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 5px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  white-space: nowrap;
}

#clock-pill {
  min-width: 135px;
}

#clock-display {
  display: inline-block;
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  font-weight: 800;
  color: #2ecc71;
  text-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
  letter-spacing: 0.5px;
  white-space: nowrap;
  transform-origin: center center;
}

#clock-display.urgent {
  color: #ff3838;
  animation: pulse-urgent 0.5s infinite alternate;
  text-shadow: 0 0 15px rgba(255, 56, 56, 0.9);
}

@keyframes pulse-urgent {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* Progress Tracker Bar */
.hud-progress-container {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(13, 19, 26, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: auto;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #64748b;
  transition: color 0.3s;
}

.progress-step .step-num {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

.progress-step.active {
  color: #ffd166;
}

.progress-step.active .step-num {
  background: #ffd166;
  color: #0d131a;
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.6);
}

.progress-step.completed {
  color: #2ecc71;
}

.progress-step.completed .step-num {
  background: #2ecc71;
  color: #0d131a;
}

.progress-line {
  width: 6px;
  height: 2px;
  background: rgba(255, 255, 255, 0.15);
}

.hud-actions {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--glass-border);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.hud-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.92);
}

/* =========================================================
   CHECKPOINT & NOTIFICATION BANNER
   ========================================================= */
#notification-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(231, 76, 60, 0.95);
  color: #fff;
  padding: 8px 24px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 25;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  letter-spacing: 0.5px;
}

#notification-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Floating Contextual Helper HUD */
#context-helper-hud {
  position: absolute;
  top: 98px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 22;
}

.helper-bubble {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  animation: float-helper 2s infinite ease-in-out;
}

@keyframes float-helper {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* =========================================================
   ON-SCREEN MOBILE TOUCH CONTROLS
   ========================================================= */
#touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 150px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-left: max(16px, env(safe-area-inset-left, 16px));
  padding-right: max(16px, env(safe-area-inset-right, 16px));
  padding-bottom: max(18px, env(safe-area-inset-bottom, 18px));
  pointer-events: none;
  z-index: 20;
}

.touch-group {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  margin-bottom: 2px;
}

.action-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 2px;
}

.touch-btn:active, .touch-btn.active {
  transform: scale(0.90);
  background: rgba(255, 255, 255, 0.35);
}

/* Dynamic Action Button States */
.touch-btn.action-a {
  width: 78px;
  height: 78px;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.4), rgba(41, 128, 185, 0.5));
  border-color: rgba(52, 152, 219, 0.7);
}

/* State: Take Cover (Green) */
.touch-btn.action-a.state-hide {
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.5), rgba(39, 174, 96, 0.6));
  border-color: #2ecc71;
  box-shadow: 0 0 15px rgba(46, 204, 113, 0.6);
}

/* State: Drag Chair (Amber Gold) */
.touch-btn.action-a.state-drag {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.55), rgba(211, 84, 0, 0.65));
  border-color: #ffd166;
  box-shadow: 0 0 20px rgba(255, 209, 102, 0.7);
  animation: pulse-ring 1s infinite alternate;
}

/* State: Vent Steam (Fiery Orange/Red - High Urgency) */
.touch-btn.action-a.state-vent {
  background: linear-gradient(135deg, #ff416c, #ff4b2b);
  border-color: #ffffff;
  box-shadow: 0 0 25px rgba(255, 65, 108, 0.9);
  animation: pulse-ring 0.6s infinite alternate;
}

/* State: Slide Under Cart (Purple) */
.touch-btn.action-a.state-slide {
  background: linear-gradient(135deg, #8e2de2, #4a00e0);
  border-color: #d1b2ff;
  box-shadow: 0 0 18px rgba(142, 45, 226, 0.7);
}

@keyframes pulse-ring {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.touch-btn.action-b {
  width: 78px;
  height: 78px;
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.4), rgba(39, 174, 96, 0.5));
  border-color: rgba(46, 204, 113, 0.7);
}

/* State: Vault Transom (Cyan Electric) */
.touch-btn.action-b.state-vault {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
  border-color: #00f2fe;
  box-shadow: 0 0 22px rgba(0, 242, 254, 0.85);
  animation: pulse-ring 0.8s infinite alternate;
}

/* =========================================================
   GENERIC MODAL WRAPPER (STANDARDIZED FIXED OVERLAY)
   ========================================================= */
.game-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  width: var(--app-width, 100vw) !important;
  height: 100% !important;
  height: 100dvh !important;
  height: var(--app-height, 100dvh) !important;
  background: rgba(10, 14, 20, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: none !important;
  align-items: center;
  justify-content: center;
  z-index: 99999 !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out;
  padding: 10px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.game-modal.show {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-card {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  width: 100%;
  max-height: calc(100dvh - 16px);
  max-height: calc(var(--app-height, 100dvh) - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  color: #fff;
  padding: 24px;
  margin: auto;
}

/* =========================================================
   START / MISSION BRIEFING MODAL
   ========================================================= */
.start-card {
  max-width: 480px;
  border-color: rgba(255, 122, 24, 0.4);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 35px rgba(255, 122, 24, 0.2);
  padding: 18px 16px;
  margin: auto;
}

.start-header-badge {
  display: inline-block;
  background: rgba(255, 122, 24, 0.18);
  border: 1px solid rgba(255, 122, 24, 0.4);
  color: #ff9800;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.start-title {
  font-size: 21px;
  font-weight: 900;
  background: linear-gradient(90deg, #ff7a18, #ff3388, #00f2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.start-sinhala-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffd166;
  margin-bottom: 8px;
}

.start-desc {
  font-size: 11.5px;
  color: #cbd5e1;
  max-width: 440px;
  margin: 0 auto 12px auto;
  line-height: 1.35;
}

.mission-steps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  text-align: left;
}

.mission-step-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mission-step-card .m-icon {
  font-size: 22px;
  line-height: 1;
}

.mission-step-card .m-info strong {
  display: block;
  font-size: 10.5px;
  color: #ffd166;
  margin-bottom: 2px;
}

.mission-step-card .m-info span {
  font-size: 9px;
  color: #94a3b8;
  line-height: 1.15;
  display: block;
}

.controls-pill-row {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 10px;
  color: #94a3b8;
  margin-bottom: 14px;
}

.controls-pill-row code {
  background: rgba(255, 255, 255, 0.15);
  color: #00f2fe;
  padding: 1px 5px;
  border-radius: 4px;
}

.btn-cta-pulse {
  background: linear-gradient(90deg, #ff7a18, #ff3388);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.5px;
  padding: 12px 40px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 122, 24, 0.5);
  transition: transform 0.1s, box-shadow 0.2s;
  animation: pulse-ring 1.5s infinite alternate;
}

.btn-cta-pulse:active {
  transform: scale(0.96);
}

/* =========================================================
   PAUSE / HOW TO PLAY MODAL
   ========================================================= */
.pause-card {
  max-width: 480px;
}

.pause-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffd166;
  margin-bottom: 10px;
}

.pause-summary {
  margin-bottom: 14px;
  font-size: 14px;
  color: #cbd5e1;
}

.pause-hints {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: left;
  margin-bottom: 18px;
}

.pause-hints h3 {
  font-size: 13px;
  color: #00f2fe;
  margin-bottom: 8px;
}

.pause-hints ul {
  padding-left: 18px;
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.5;
}

.pause-hints li {
  margin-bottom: 6px;
}

.pause-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-restart-alt {
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}

/* =========================================================
   COMIC FREEZE-FRAME OVERLAY (ALERT / PENALTY)
   ========================================================= */
/* Comic Freeze Modal */
.comic-card {
  position: relative;
  background: #ffffff;
  color: #111;
  width: 90%;
  max-width: 500px;
  max-height: calc(100dvh - 16px);
  max-height: calc(var(--app-height, 100dvh) - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
  padding: 16px 20px;
  border: 4px solid #111;
  box-shadow: 8px 8px 0px #e74c3c;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: rotate(-1deg) scale(0.92);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  margin: auto;
}

#comic-freeze-modal.show .comic-card {
  transform: rotate(-1deg) scale(1);
}

.comic-body-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.comic-badge {
  background: #e74c3c;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 4px 14px;
  border-radius: 4px;
  text-transform: uppercase;
  border: 2px solid #111;
  margin-bottom: 10px;
}

.comic-boss-art {
  width: 100px;
  height: 100px;
  background: #f1f2f6;
  border: 3px solid #111;
  border-radius: 50%;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  position: relative;
}

.comic-file-icon {
  position: absolute;
  bottom: -2px;
  right: -5px;
  font-size: 32px;
  animation: wobble 1s infinite ease-in-out;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(15deg); }
}

.comic-dialogue {
  font-size: 18px;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 4px;
  font-style: italic;
}

.comic-dialogue-sinhala {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin-bottom: 10px;
}

.comic-tip-box {
  background: #eff6ff;
  border: 2px solid #3b82f6;
  color: #1e3a8a;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  width: 100%;
  text-align: left;
}

.comic-penalty-info {
  background: #fff3cd;
  border: 2px dashed #e67e22;
  color: #d35400;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  width: 100%;
}

.comic-btn {
  background: #2ecc71;
  color: #111;
  font-size: 15px;
  font-weight: 800;
  padding: 10px 28px;
  border-radius: 8px;
  border: 3px solid #111;
  box-shadow: 4px 4px 0px #111;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.comic-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px #111;
}

/* =========================================================
   VICTORY & BRAND REWARD FLOW MODAL
   ========================================================= */
/* Victory Modal Card */
.victory-card {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 122, 24, 0.25);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100dvh - 16px);
  max-height: calc(var(--app-height, 100dvh) - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px;
  text-align: center;
  color: #fff;
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  margin: auto;
}

#victory-modal.show .victory-card {
  transform: translateY(0);
}

.victory-title {
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(90deg, #ff7a18, #ff3388, #00f2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.victory-subtitle {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 16px;
}

.victory-hero-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 14px;
}

.hero-avatar {
  font-size: 46px;
  line-height: 1;
}

.hero-stats {
  text-align: left;
}

.stat-val {
  font-size: 24px;
  font-weight: 800;
  color: #2ecc71;
  font-family: 'Courier New', Courier, monospace;
}

.stat-lbl {
  font-size: 11px;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-badge {
  display: inline-block;
  background: rgba(255, 209, 102, 0.15);
  color: #ffd166;
  border: 1px solid rgba(255, 209, 102, 0.3);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  margin-top: 4px;
}

.voucher-box {
  background: linear-gradient(135deg, rgba(230, 74, 25, 0.15), rgba(255, 152, 0, 0.15));
  border: 2px dashed rgba(255, 122, 24, 0.6);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.voucher-header {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ff9800;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.voucher-details {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.voucher-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.code-badge {
  background: #0d131a;
  color: #2ecc71;
  font-family: 'Courier New', Courier, monospace;
  font-size: 18px;
  font-weight: 900;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid rgba(46, 204, 113, 0.4);
  letter-spacing: 2px;
}

.copy-btn {
  background: var(--tech-cyan);
  color: #0d131a;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.action-row {
  display: flex;
  gap: 10px;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(90deg, #ff7a18, #ff3388);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  padding: 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 122, 24, 0.4);
}

.btn-secondary {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-restart {
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  padding: 6px;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

/* =========================================================
   LANDSCAPE ORIENTATION WARNING (GAME IS PORTRAIT 9:16)
   ========================================================= */
#orientation-overlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  width: var(--app-width, 100vw);
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  background: #0d131a;
  z-index: 100000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

#orientation-overlay.force-show,
@media screen and (orientation: landscape) and (max-height: 600px) {
  #orientation-overlay {
    display: flex !important;
  }
}

.rotate-device-icon {
  font-size: 64px;
  animation: rotate-phone-portrait 2s infinite ease-in-out;
  margin-bottom: 20px;
}

@keyframes rotate-phone-portrait {
  0%, 100% { transform: rotate(90deg); }
  50% { transform: rotate(0deg); }
}

.orientation-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffd166;
  margin-bottom: 8px;
}

.orientation-desc {
  font-size: 14px;
  color: #94a3b8;
  max-width: 320px;
}

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: #2ecc71;
  color: #0d131a;
  font-weight: 800;
  font-size: 13px;
  padding: 10px 22px;
  border-radius: 30px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 80;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   MOBILE LANDSCAPE SHORT HEIGHT OPTIMIZATION (max-height: 520px)
   Guarantees modals, dialogue, and buttons never get cut off!
   ========================================================= */
@media screen and (max-height: 520px) {
  #hud-overlay {
    padding: 3px 12px;
    height: 38px;
  }
  .hud-pill {
    padding: 2px 10px;
  }
  #clock-pill {
    min-width: 130px;
  }
  #clock-display {
    font-size: 14px;
  }
  .hud-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .hud-progress-container {
    padding: 2px 8px;
    gap: 3px;
  }
  .progress-step {
    font-size: 9px;
  }
  .progress-step .step-num {
    width: 14px;
    height: 14px;
    font-size: 8.5px;
  }
  #context-helper-hud {
    top: 38px;
  }
  .helper-bubble {
    font-size: 10px;
    padding: 2px 8px;
  }
  #notification-banner {
    top: 38px;
    padding: 4px 16px;
    font-size: 11px;
  }

  /* Comic Freeze Modal 2-Column Landscape Flow */
  #comic-freeze-modal {
    padding: 6px;
  }
  .comic-card {
    max-width: 540px;
    padding: 8px 16px;
    border-width: 3px;
    box-shadow: 5px 5px 0px #e74c3c;
  }
  .comic-badge {
    font-size: 10px;
    padding: 2px 8px;
    margin-bottom: 4px;
  }
  .comic-body-row {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    text-align: left;
  }
  .comic-avatar-col {
    flex-shrink: 0;
  }
  .comic-info-col {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .comic-boss-art {
    width: 58px;
    height: 58px;
    font-size: 32px;
    margin-bottom: 0;
  }
  .comic-file-icon {
    font-size: 18px;
  }
  .comic-dialogue {
    font-size: 13px;
    margin-bottom: 1px;
  }
  .comic-dialogue-sinhala {
    font-size: 10.5px;
    margin-bottom: 3px;
  }
  .comic-tip-box {
    font-size: 10px;
    padding: 3px 8px;
    margin-bottom: 3px;
  }
  .comic-penalty-info {
    font-size: 9.5px;
    padding: 2px 8px;
    margin-bottom: 6px;
  }
  .comic-btn {
    font-size: 13px;
    padding: 6px 20px;
    border-width: 2px;
    align-self: flex-start;
  }

  /* Start Card Compact Landscape */
  .start-card {
    max-width: 580px;
    padding: 8px 14px;
  }
  .start-header-badge {
    font-size: 9px;
    padding: 2px 6px;
    margin-bottom: 2px;
  }
  .start-title {
    font-size: 17px;
    margin-bottom: 0px;
  }
  .start-sinhala-title {
    font-size: 11px;
    margin-bottom: 4px;
  }
  .start-desc {
    font-size: 10px;
    margin-bottom: 6px;
    line-height: 1.25;
  }
  .mission-steps-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 6px;
  }
  .mission-step-card {
    padding: 4px 6px;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
  }
  .mission-step-card .m-icon {
    font-size: 18px;
  }
  .mission-step-card .m-info strong {
    font-size: 9px;
    margin-bottom: 1px;
  }
  .mission-step-card .m-info span {
    font-size: 8px;
    line-height: 1.1;
    display: block;
  }
  .controls-pill-row {
    padding: 2px 6px;
    font-size: 9px;
    margin-bottom: 6px;
  }
  .btn-cta-pulse {
    font-size: 13px;
    padding: 7px 26px;
  }

  /* Victory Card Compact Landscape */
  .victory-card {
    max-width: 540px;
    padding: 8px 16px;
  }
  .victory-title {
    font-size: 18px;
    margin-bottom: 1px;
  }
  .victory-subtitle {
    font-size: 10.5px;
    margin-bottom: 6px;
  }
  .victory-hero-box {
    padding: 4px 10px;
    margin-bottom: 6px;
  }
  .hero-avatar {
    font-size: 32px;
  }
  .stat-val {
    font-size: 20px;
  }
  .stat-lbl {
    font-size: 9px;
  }
  .stat-badge {
    font-size: 9px;
    padding: 1px 6px;
  }
  .voucher-box {
    padding: 6px 10px;
    margin-bottom: 8px;
  }
  .voucher-header {
    font-size: 9px;
  }
  .voucher-details {
    font-size: 13px;
    margin-bottom: 2px;
  }
  .voucher-code-row {
    margin-top: 4px;
    gap: 8px;
  }
  .code-badge {
    font-size: 14px;
    padding: 3px 10px;
  }
  .copy-btn {
    font-size: 10px;
    padding: 4px 8px;
  }
  .action-row {
    gap: 8px;
  }
  .btn-primary, .btn-secondary {
    font-size: 12px;
    padding: 7px;
  }
  .btn-restart {
    font-size: 10.5px;
    padding: 2px;
  }

  /* Pause Card Compact */
  .pause-card {
    max-width: 440px;
    padding: 10px 16px;
  }
  .pause-title {
    font-size: 16px;
    margin-bottom: 4px;
  }
  .pause-summary {
    font-size: 11px;
    margin-bottom: 6px;
  }
  .pause-hints {
    padding: 6px 10px;
    margin-bottom: 8px;
  }
  .pause-hints h3 {
    font-size: 10.5px;
    margin-bottom: 4px;
  }
  .pause-hints li {
    font-size: 9.5px;
    margin-bottom: 3px;
  }
  .pause-btn-stack {
    gap: 6px;
  }
  .pause-btn-stack .btn-primary,
  .pause-btn-stack .btn-secondary,
  .pause-btn-stack .btn-restart-alt {
    padding: 6px;
    font-size: 11px;
  }

  /* Touch controls size in short landscape */
  #touch-controls {
    height: 86px;
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
    padding-bottom: max(4px, env(safe-area-inset-bottom, 4px));
  }
  .touch-group {
    gap: 8px;
  }
  .touch-btn {
    width: 50px;
    height: 50px;
    font-size: 8.5px;
  }
  .touch-btn svg {
    width: 18px;
    height: 18px;
    margin-bottom: 1px;
  }
  .touch-btn.action-a, .touch-btn.action-b {
    width: 56px;
    height: 56px;
    font-size: 8.5px;
  }
  .action-icon {
    font-size: 14px;
    margin-bottom: 1px;
  }
}

/* Extra short screens (phones with browser search bar visible, height < 360px) */
@media screen and (max-height: 360px) {
  .start-desc {
    display: none;
  }
  .start-sinhala-title {
    display: none;
  }
  .controls-pill-row {
    display: none;
  }
  .start-card {
    padding: 6px 12px;
  }
  .mission-step-card .m-info span {
    display: none;
  }
  .mission-step-card {
    padding: 3px 4px;
  }
  #touch-controls {
    height: 74px;
  }
  .touch-btn {
    width: 44px;
    height: 44px;
    font-size: 8px;
  }
  .touch-btn.action-a, .touch-btn.action-b {
    width: 48px;
    height: 48px;
    font-size: 8px;
  }
}
