/* ============================================
   BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
    color: #fff;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* ============================================
   UI OVERLAY (In-Game HUD)
   ============================================ */

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 150; /* Above canvas, below screens */
    /* Hide by default to avoid a flash of the platformer HUD on boot.
       Visibility is controlled by UI.showHUD() in JS. */
    display: none;
}


/* Ensure child elements are visible */
#timer-display, #run-info, #room-indicator, #best-run {
    opacity: 1;
    text-shadow: 2px 2px 2px rgba(0,0,0,0.8); /* Ensure visibility against bright backgrounds */
}

#timer-display {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.8), 2px 2px 4px rgba(0,0,0,0.8);
    font-family: 'Courier New', monospace;
}

#timer-display.warning {
    color: #ffaa00;
    text-shadow: 0 0 20px rgba(255, 170, 0, 0.8);
}

#timer-display.danger {
    color: #ff3333;
    text-shadow: 0 0 20px rgba(255, 50, 50, 0.8);
    animation: pulse 0.5s infinite;
}

#timer-display.speedrun {
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.8);
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

#run-info {
    position: absolute;
    top: 30px;
    left: 30px;
    font-size: 18px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#run-info .run-number {
    font-size: 32px;
    font-weight: bold;
    color: #00ffcc;
}

#mode-indicator {
    position: absolute;
    top: 90px;
    left: 30px;
    color: #888;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#room-indicator {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 18px;
    text-align: right;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#room-name {
    font-size: 28px;
    font-weight: bold;
}

#par-info {
    font-size: 14px;
    color: #888;
    margin-top: 5px;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
}

#crosshair::before {
    width: 2px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

#crosshair::after {
    width: 100%;
    height: 2px;
    top: 50%;
    transform: translateY(-50%);
}

#room-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 56px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    text-align: center;
}

#best-run {
    position: absolute;
    bottom: 30px;
    left: 30px;
    color: #888;
    font-size: 16px;
}

#splits-display {
    position: absolute;
    bottom: 80px;
    right: 30px;
    color: #888;
    font-size: 14px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

.split-time { margin: 2px 0; }
.split-time.ahead { color: #00ff88; }
.split-time.behind { color: #ff6666; }

#controls-help {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #666;
    font-size: 14px;
    text-align: center;
}

/* ============================================
   SCREEN OVERLAYS (Menus)
   ============================================ */

.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.92);
    pointer-events: auto;
    z-index: 200;
    
    /* Standardized: center menus in a consistent card */
    justify-content: center;
    padding-top: 0;
}

/* Standardized menu card used by all menus (title/game select/mode select/pause/profile/etc.) */
.menu-card {
    width: min(720px, 92vw);
    padding: 26px 22px 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(10, 12, 18, 0.85);
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* menu-card title sizing must override the base .screen-overlay h1 rule */
.screen-overlay .menu-card h1 {
    font-size: 56px;
    margin: 0 0 12px 0;
}

.menu-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
}

/* Standardized buttons inside menu cards: fit the grid and avoid overflow */
.menu-card .menu-button {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: 14px 18px;
    font-size: 16px;
    transform: none;
}

.menu-card .menu-button:hover,
.menu-card .menu-button.selected {
    transform: none;
}

/* Keep the glow, but avoid scale-induced layout shifts */
.menu-card .menu-button:hover {
    box-shadow: 0 0 26px rgba(0, 255, 204, 0.45);
}

.menu-card .menu-button.secondary:hover,
.menu-card .menu-button.secondary.selected {
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.25);
}

/* Menu hint sits within the card */
.menu-card .input-hint {
    margin-top: 14px;
}

@media (max-width: 520px) {
    .screen-overlay .menu-card h1 { font-size: 42px; }
}

@media (max-width: 420px) {
    .menu-actions { grid-template-columns: 1fr; }
}

/* Titles */
.screen-overlay h1 {
    font-size: 64px;
    margin: 0 0 15px 0; /* Slight gap before subtitle */
    background: linear-gradient(135deg, #00ffcc, #0099ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#gameover-screen h1 {
    background: linear-gradient(135deg, #ff6666, #ff3333);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#victory-screen h1 {
    background: linear-gradient(135deg, #ffcc00, #ff9900);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Subtitles - Kept close to the title */
.screen-subtitle {
    font-size: 20px;
    color: #aaa;
    margin-bottom: 10px; /* Reduced: Buttons handle the large gap now */
    text-align: center;
    min-height: 24px;
    max-width: 600px;
    line-height: 1.4;
}

/* Stats Block */
.stats {
    font-size: 18px;
    margin-bottom: 10px; /* Reduced: Buttons handle the large gap now */
    text-align: center;
    line-height: 1.6;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Button Container - THE FIX */
.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px; /* Space between buttons */
    
    /* This ensures consistent distance from Title/Subtitle/Stats */
    margin-top: 50px; 
    
    width: 100%;
}

.menu-button {
    padding: 15px 40px;
    font-size: 18px;
    background: linear-gradient(135deg, #00ffcc, #0099ff);
    border: none;
    border-radius: 50px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 280px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-button:hover,
.menu-button.selected {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 255, 204, 0.5);
    z-index: 1;
}

/*
  Menu highlight outline:
  - Always visible on hover (mouse users)
  - Visible for "selected" only after keyboard/gamepad navigation begins
    (body.kbd-nav is set by the Input system)
*/
.menu-button:hover {
    outline: 3px solid rgba(255, 255, 255, 0.85);
}

body.kbd-nav .menu-button.selected,
body.kbd-nav .book-btn.selected {
    outline: 3px solid #fff;
}

.menu-button.secondary {
    background: linear-gradient(135deg, #444, #666);
    color: #fff;
}

.menu-button.secondary:hover,
.menu-button.secondary.selected {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Description Box */
.mode-description {
    font-size: 14px;
    color: #888;
    max-width: 450px;
    text-align: center;
    line-height: 1.5;
    margin-top: 25px;
    
    min-height: 48px;       
    display: flex;          
    align-items: flex-start;
    justify-content: center;
}

/* Input Hint */
.input-hint {
    color: #444;
    font-size: 12px;
    margin-top: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Book Indicator (Typing Menu) */
#current-book-indicator {
    color: #00ffcc; 
    font-size: 24px; 
    margin-bottom: 10px; /* Reduced to match subtitle flow */
    font-weight: bold; 
    border-bottom: 1px solid #00ffcc; 
    padding-bottom: 5px;
    letter-spacing: 2px;
}



/* ============================================
   TYPING GAME - POLISHED
   ============================================ */

#typing-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0a0a12 0%, #12121a 100%);
    display: flex;
    flex-direction: column;
    z-index: 150;
}

/* Exit bar - full width, contains X on right */
#typing-exit-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 36px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

#typing-exit-bar:hover {
    background: rgba(255, 100, 100, 0.1);
}

#typing-exit-bar span {
    color: #444;
    font-size: 12px;
}

#typing-exit-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #666;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#typing-exit-button:hover {
    background: rgba(255, 100, 100, 0.3);
    border-color: rgba(255, 100, 100, 0.5);
    color: #ff6666;
}

#typing-header {
    display: grid;
    grid-template-columns: 260px 1fr 260px;
    align-items: center;
    padding: 15px 30px;
    gap: 10px;
}

#typing-run-info {
    font-size: 14px;
    color: #666;
    min-width: 0;
}

#typing-run-number {
    font-size: 24px;
    font-weight: bold;
    color: #00ffcc;
}

#typing-timer {
    font-size: 36px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #fff;
    flex: 1;
    text-align: center;
}

/* Wide-screen verse info sits in the header (right column) */
#typing-verse-info {
    font-size: 14px;
    color: #888;
    text-align: right;
    justify-self: end;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#typing-timer.zen {
    color: #888;
    font-size: 28px;
}

#typing-timer.counting-up { color: #00ff88; }
#typing-timer.warning { color: #ffaa00; }
#typing-timer.danger { color: #ff3333; }

/* Below-header line: (optional) mobile verse info + NEXT guide */
#typing-verse-line {
    padding: 8px 30px 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    max-width: 100%;
}

#typing-verse-info-mobile {
    display: none;
    font-size: 14px;
    color: #888;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
}

#verse-queue {
    font-size: 12px;
    opacity: 0.7;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
}

#typing-progress-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 2px;
}

#typing-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00ffcc, #0099ff);
    transition: width 0.3s;
}

#typing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    /* Allow scrolling when content is taller (e.g., mobile keyboard open). */
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* When the soft keyboard is open, nudge layout upward and reduce wasted space. */
#typing-container.keyboard-open #typing-content {
    justify-content: flex-start;
    padding-top: 15px;
}

#verse-queue {
    margin: 0;
    text-align: right;
    min-height: 0;
    font-size: 11px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.queue-label {
    font-size: 11px;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.queued-verse {
    font-size: 13px;
    color: #444;
    margin: 3px 0;
}

/* Verse display - FIXED: no layout shift */
#verse-display {
    font-size: 20px;
    font-family: 'Georgia', serif;
    line-height: 2;
    max-width: 700px;
    text-align: center;
    margin-bottom: 30px;
    min-height: 120px;
}

/* Words are inline-block with fixed styling to prevent shift */
#verse-display .word {
    display: inline;
    transition: color 0.15s;
    margin: 0 0.2em;
}

#verse-display .word-complete {
    color: #00cc99;
}

#verse-display .word-current {
    color: #fff;
    text-decoration: underline;
    text-decoration-color: #00ffcc;
    text-underline-offset: 4px;
}

#verse-display .word-pending {
    color: #444;
}

#current-word-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
}

#current-word-label {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

#current-word-display {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    font-family: 'Courier New', monospace;
    padding: 8px 16px;
    background: rgba(0, 255, 204, 0.1);
    border: 2px solid rgba(0, 255, 204, 0.3);
    border-radius: 8px;
    min-width: 120px;
    text-align: center;
}

#typing-input-area {
    width: 100%;
    max-width: 350px;
}

#typing-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 22px;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(0, 255, 204, 0.3);
    border-radius: 8px;
    color: #fff;
    outline: none;
    text-align: center;
    transition: all 0.2s;
}

#typing-input:focus {
    border-color: rgba(0, 255, 204, 0.8);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.2);
}

#typing-input.error {
    border-color: #ff3333;
    background: rgba(255, 50, 50, 0.1);
    animation: shake 0.2s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

#typing-input::placeholder {
    color: #333;
    font-size: 13px;
}

#typing-stats {
    display: flex;
    justify-content: center;
    gap: 50px;
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Typing pause overlay */
#typing-pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  z-index: 2000;
}

#typing-pause-overlay .typing-pause-card {
  width: min(520px, 90vw);
  padding: 18px 16px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  background: rgba(10,12,18,0.85);
  box-shadow: 0 12px 50px rgba(0,0,0,0.55);
  overflow: hidden; /* prevent oversized buttons/glow from escaping the frame */
}

#typing-pause-overlay .typing-pause-title {
  letter-spacing: 0.18em;
  font-size: 14px;
  opacity: 0.85;
  text-align: center;
  margin-bottom: 12px;
}

#typing-pause-overlay .typing-pause-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Ensure pause menu buttons fit cleanly inside the card */
#typing-pause-overlay .typing-pause-actions .menu-button {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;            /* override global min-width: 280px */
  padding: 14px 18px;      /* override global padding that was too wide */
  font-size: 16px;         /* keep text from forcing overflow */
  transform: none;         /* don't scale inside the modal */
}

/* Disable the global hover/selected scaling inside the pause modal */
#typing-pause-overlay .typing-pause-actions .menu-button:hover,
#typing-pause-overlay .typing-pause-actions .menu-button.selected {
  transform: none;
  box-shadow: 0 0 22px rgba(0, 255, 204, 0.35);
}

#typing-pause-overlay .typing-pause-actions label.menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 480px) {
  #typing-pause-overlay .typing-pause-card {
    width: min(520px, 94vw);
    padding: 16px 12px 12px;
  }
  #typing-pause-overlay .typing-pause-actions {
    gap: 8px;
  }
}

/* Labels used as buttons should match button layout */
#typing-pause-overlay .typing-pause-actions label.menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 420px) {
  #typing-pause-overlay .typing-pause-actions {
    grid-template-columns: 1fr;
  }
}

#typing-pause-overlay .typing-pause-hint {
  text-align: center;
  margin-top: 10px;
  font-size: 12px;
  opacity: 0.55;
}

#typing-stats span {
    font-size: 15px;
    color: #666;
}

/* ============================================
   MOBILE CONTROLS
   ============================================ */

#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 150;
    /* Hidden by default; JS toggles visibility only during platformer gameplay */
    display: none;
}

.touch-enabled #mobile-controls {
    /* Keep hidden unless explicitly enabled by JS */
    display: none;
}

.touch-enabled #controls-help {
    display: none;
}

#joystick-zone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 150px;
    pointer-events: auto;
}

#joystick-base {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#joystick-stick {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,255,204,0.8) 0%, rgba(0,153,255,0.6) 100%);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.5);
}

#look-zone {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 70%;
    pointer-events: auto;
}

#jump-button {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.1) 100%);
    border: 3px solid rgba(255, 255, 255, 0.5);
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
}

#jump-button.pressed {
    background: radial-gradient(circle, rgba(0,255,204,0.5) 0%, rgba(0,153,255,0.3) 100%);
    transform: scale(0.95);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .screen-overlay h1 { font-size: 36px; }
    #timer-display { font-size: 32px; top: 15px; }
    #run-info { font-size: 14px; top: 15px; left: 15px; }
    #run-info .run-number { font-size: 24px; }
    #room-indicator { top: 15px; right: 15px; font-size: 14px; }
    #room-name { font-size: 20px; }
    #verse-display { font-size: 16px; padding: 0 10px; }
    #current-word-display { font-size: 22px; }
    #typing-input { font-size: 18px; }
    #typing-header {
        padding: 10px 15px;
        grid-template-columns: 140px 1fr 140px;
    }
    #typing-timer { font-size: 28px; }

    /* On narrow screens, move verse info below the header (centered) */
    #typing-verse-info { display: none; }
    #typing-verse-line {
        padding: 8px 15px 10px;
        align-items: center;
        text-align: center;
    }
    #typing-verse-info-mobile { display: block; }
    #verse-queue { text-align: center; }
}

/* Extra-narrow HUD layout to prevent timer/room overlap on mobile */
@media (max-width: 520px) {
    #timer-display { top: 18px; font-size: 34px; }

    /* Move room name/progress to centered stack below the timer */
    #room-indicator {
        top: 70px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        text-align: center;
        width: 90vw;
    }

    /* Spread run + mode away from the center stack */
    #run-info {
        top: 125px;
        left: 15px;
        font-size: 13px;
    }
    #run-info .run-number { font-size: 22px; }

    #mode-indicator {
        top: 125px;
        left: auto;
        right: 15px;
        text-align: right;
    }
}

#typing-timer.zen {
    color: #888;
    font-size: 24px;
    font-weight: normal;
}

#typing-run-info {
    font-size: 14px;
    color: #666;
    min-width: 0;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    width: 90%;
    max-width: 1000px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

/* ============================================
   VERSE CONTEXT
   ============================================ */

.verse-context {
    width: 100%;
    max-width: 700px;
    text-align: center;
    margin-bottom: 15px;
    opacity: 0.5; /* Greyed out look */
    font-family: 'Georgia', serif;
    font-size: 16px;
    color: #888;
    line-height: 1.5;
    pointer-events: none;
    user-select: none;
}

.context-line {
    margin-bottom: 8px;
}

.context-ref {
    color: #00ffcc;
    font-size: 12px;
    font-weight: bold;
    margin-right: 5px;
    vertical-align: super;
}

#verse-context-top {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 10px;
}

#verse-context-bottom {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 10px;
    margin-top: -15px; /* Pull it closer to main verse */
    margin-bottom: 30px;
}

/* ============================================
   MOBILE / SMALL-HEIGHT ADAPTATION (Typing)
   - Auto-hide context when vertical space is tight (all modes)
   - On touch devices, hide context by default for a cleaner, more consistent feel
   ============================================ */

/* Touch devices: keep typing UI focused and avoid awkward keyboard overlap by default. */
body.touch-device #typing-container #verse-context-top,
body.touch-device #typing-container #verse-context-bottom {
    display: none;
}

/* Auto-hide context when the available height is small (applies across all modes). */
@media (max-height: 650px) {
    #typing-container #verse-context-top,
    #typing-container #verse-context-bottom {
        display: none;
    }
    #verse-display {
        font-size: 18px;
        line-height: 1.8;
        margin-bottom: 20px;
    }
}

/* When keyboard is detected, hide context regardless of device type. */
#typing-container.keyboard-open #verse-context-top,
#typing-container.keyboard-open #verse-context-bottom {
    display: none;
}

/* ============================================
   BIBLE BOOK SELECT
   ============================================ */

.book-btn {
    padding: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    text-align: left;
    text-transform: capitalize;
}

.book-btn:hover {
    background: rgba(0, 255, 204, 0.2);
    border-color: #00ffcc;
}

/* NEW: Master Book Button (Entire Bible) */
.master-book-btn {
    grid-column: 1 / -1; /* Spans full width of the grid */
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    padding: 12px;
    background: linear-gradient(90deg, rgba(0, 255, 204, 0.1), rgba(0, 153, 255, 0.1));
    border-color: #00ffcc;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.master-book-btn:hover {
    background: linear-gradient(90deg, rgba(0, 255, 204, 0.3), rgba(0, 153, 255, 0.3));
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.3);
}

.category-header {
    grid-column: 1 / -1;
    color: #00ffcc;
    font-size: 16px;
    margin-top: 15px;
    border-bottom: 1px solid #00ffcc;
}

/* ============================================
   MUTE BUTTON
   ============================================ */

#mute-button {
    position: absolute;
    bottom: 20px;
    left: 20px;

    /* Remove the circle for now—just the icon */
    background: transparent;
    border: none;
    width: auto;
    height: auto;
    padding: 0;

    color: #fff;
    font-size: 22px;
    line-height: 1;
    font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif;

    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.15s ease, transform 0.15s ease;
    user-select: none;
}

#mute-button:hover {
    opacity: 0.85;
    transform: scale(1.03);
}