/* ═══════════════════════════════════════════════════════════════════════════
   02-LAYOUT.CSS
   Mystery Temple - Galaxy Edition
   
   Base reset, body styles, and main HUD flexbox layout system.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  UNIVERSAL RESET                                                          ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  HTML & BODY                                                              ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
    touch-action: none;
    overscroll-behavior: none;
}

body {
    font-family: var(--font-title);
    background: radial-gradient(
        circle at 20% 0%,
        #10152b 0%,
        var(--bg-dark) 40%,
        var(--bg-darker) 100%
    );
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  UTILITY CLASSES                                                          ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden;
    pointer-events: none;
}

.no-scroll {
    overflow: hidden !important;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  CUSTOM SCROLLBAR                                                         ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(10, 20, 30, 0.8);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--color-primary-dark), #084);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary-dark) rgba(10, 20, 30, 0.8);
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  TEXT SELECTION                                                           ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

::selection {
    background: var(--color-primary);
    color: var(--bg-dark);
}

::-moz-selection {
    background: var(--color-primary);
    color: var(--bg-dark);
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  GAME CANVAS                                                              ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: fixed;
    inset: 0;
    z-index: var(--z-canvas);
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  MAIN HUD CONTAINER (Flexbox System)                                      ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.game-hud {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    z-index: var(--z-hud);
    padding: var(--hud-padding);
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  HUD TOP BAR                                                              ║
   ║  Layout: [Stats] [Lives+Pause] [Level]                                    ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.hud-top-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  HUD MIDDLE SECTION                                                       ║
   ║  Layout: [Left Panels] [Center/Chase] [Right Panels]                      ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.hud-middle {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex: 1;
    padding: var(--spacing-md) 0;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: flex-start;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
}

.hud-right {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: flex-end;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  HUD BOTTOM                                                               ║
   ║  Layout: [Speed Indicator] [Story Panel]                                  ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.hud-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    padding-bottom: var(--mobile-controls-height);
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  POINTER EVENTS CONTROL                                                   ║
   ║  Allow interaction only on specific elements                              ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.game-hud > * {
    pointer-events: none;
}

.game-hud .stats-panel,
.game-hud .level-panel,
.game-hud .lives-panel,
.game-hud .pause-btn,
.game-hud .gem-counter-panel,
.game-hud .letters-panel,
.game-hud .heart-progress-panel,
.game-hud .active-boosts-panel,
.game-hud .story-panel,
.game-hud .chase-progress,
.game-hud .speed-indicator {
    pointer-events: auto;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  GENERIC OVERLAY LAYOUT                                                   ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-overlay);
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.overlay-content {
    text-align: center;
    padding: var(--spacing-2xl);
    background: linear-gradient(
        135deg,
        rgba(15, 30, 40, 0.98),
        rgba(10, 20, 30, 0.99)
    );
    border-radius: var(--radius-2xl);
    border: 3px solid var(--border-primary);
    max-width: var(--overlay-max-width);
    width: 100%;
    box-shadow: var(--shadow-panel);
    max-height: 90vh;
    overflow-y: auto;
}

.overlay-content.no-scroll {
    overflow: hidden;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  MOBILE CONTROLS LAYOUT                                                   ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: var(--z-controls);
}

.control-group {
    display: flex;
    gap: var(--spacing-md);
    pointer-events: auto;
}

.left-controls {
    justify-content: flex-start;
}

.right-controls {
    justify-content: flex-end;
}


/* ╔═══════════════════════════════════════════════════════════════════════════╗
   ║  FLEX UTILITIES                                                           ║
   ╚═══════════════════════════════════════════════════════════════════════════╝ */

.flex-row {
    display: flex;
    flex-direction: row;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* --- Global horizontal scroll protection (overlays/UI) --- */
html, body {
  overflow-x: hidden !important;
}

.overlay,
.overlay-content,
.morse-code-overlay,
.morse-content,
.hacking-overlay,
.hack-terminal,
.cipher-translation-overlay,
.cipher-translation-container,
.local-decrypter-overlay,
.local-decrypter-content,
.final-morse-list,
.temple-wall-overlay,
.temple-wall-panel,
.glitch-delete-overlay,
.cinematic-credits-overlay {
  overflow-x: hidden !important;
  max-width: 100%;
}

/* long texts should wrap instead of forcing width */
.hack-lines,
.morse-text,
.cipher-morse-text,
.temple-wall-engraving-line.code,
.glitch-file-list {
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}