/* =============================================================
   MOBILE & RESPONSIVE DESIGN
   All @media query overrides for phones and tablets,
   mobile navigation, touch improvements, housing system.
   Source: original styles.css lines 12872-18930
   ============================================================= */
/* ============================================================================
   MOBILE & RESPONSIVE DESIGN
   ============================================================================ */

/* Touch optimization class added by mobile-ui.js */
.touch-active {
  opacity: 0.7 !important;
  transform: scale(0.98);
}

/* Mobile body classes for conditional styling */
body.is-mobile .desktop-only {
  display: none !important;
}

body:not(.is-mobile) .mobile-only {
  display: none !important;
}

/* ============================================================================
   TABLETS & SMALL DESKTOPS (1024px and below)
   ========================================================================== */
@media (max-width: 1024px) {
  .menu-container {
    max-width: 90%;
    padding: 30px;
  }

  .menu-options button,
  .primary-action-btn,
  .secondary-action-btn {
    width: 100%;
    max-width: 400px;
  }
}

/* ============================================================================
   TABLETS & PHONES (768px and below)
   ========================================================================== */
@media (max-width: 768px) {
  /* === BASE LAYOUT === */
  body {
    font-size: 15px;
  }

  .screen {
    padding: 10px;
  }

  /* === SPLASH SCREEN === */
  .splash-content {
    max-width: 90%;
    padding: 30px 20px;
  }

  .splash-title {
    font-size: 2.5em;
  }

  .splash-subtitle {
    font-size: 1.1em;
  }

  .splash-button {
    padding: 12px 30px;
    font-size: 1.1em;
  }

  /* === MENU CONTAINER === */
  .menu-container {
    width: 100%;
    max-width: 100%;
    padding: 20px 14px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    overflow-y: auto;
    max-height: 100vh;
  }

  .menu-container h1 {
    font-size: 2.2em;
    margin-bottom: 25px;
  }

  .menu-options button,
  .primary-action-btn,
  .secondary-action-btn {
    width: 100%;
    max-width: none;
    padding: 15px;
    font-size: 1.1em;
    touch-action: manipulation;
  }

  /* Explore World CTA â€” full-width, dominant on mobile */
  .explore-btn {
    width: 100% !important;
    max-width: none !important;
    padding: 20px 15px !important;
    font-size: 1.2em !important;
    letter-spacing: 2.5px !important;
    touch-action: manipulation;
  }

  .menu-hero-cta {
    margin: 12px 0 20px !important;
    padding: 16px 0 8px !important;
    border-top: 2px solid rgba(74,222,128,0.35) !important;
    border-bottom: 2px solid rgba(74,222,128,0.25) !important;
  }

  .menu-hero-cta::before {
    font-size: 0.65em !important;
    letter-spacing: 2.5px !important;
    margin-bottom: 12px !important;
  }

  .menu-secondary-options {
    flex-direction: column;
    gap: 8px;
  }

  .menu-secondary-options button {
    width: 100%;
  }

  /* === FORM ELEMENTS === */
  .form-group {
    margin-bottom: 15px;
  }

  input[type="text"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    padding: 12px;
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 44px;
  }

  /* === ACTIVE CHARACTER PANEL === */
  .active-character-panel {
    padding: 15px;
  }

  .active-char-content {
    flex-direction: row;
    align-items: center;
  }

  .active-char-portrait {
    width: 60px;
    height: 60px;
  }

  /* === CHARACTER CREATION === */
  .creation-container {
    width: 100%;
    max-width: 95%;
    padding: 20px 15px;
  }

  .creation-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* === CHARACTER SELECTION === */
  .character-list {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .character-card {
    padding: 15px;
  }

  /* === GAME CONTAINER === */
  .game-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 10px;
    padding: 5px;
  }

  .party-column {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 5px;
  }

  .character-slot {
    min-width: 150px;
    height: auto;
    min-height: 100px;
    margin-right: 10px;
  }

  /* === COMBAT MODAL === */
  .combat-modal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    padding: 0;
  }

  .combat-container {
    padding: 3px;
    width: 100vw;
    height: 100vh;
    gap: 3px;
    border-radius: 0;
  }

  .combat-header {
    padding: 3px 8px;
    font-size: 0.85em;
  }

  .combat-header h2 {
    font-size: 1.3em;
  }

  /* Mobile Combat: Single Column Layout */
  .combat-three-column-layout {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 30px; /* Space for timeline at top */
  }

  /* Hide side character panels on mobile */
  .combat-left-column,
  .combat-right-column {
    display: none;
  }

  /* Center column takes full width */
  .combat-center-column {
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
  }

  /* Timeline - Make it stick to top */
  .combat-timeline-display {
    top: 5px;
    left: 5px;
    right: 5px;
    max-width: calc(100% - 10px);
    width: calc(100% - 10px);
    transform: none;
    height: auto;
    max-height: 65px;
    padding: 4px 6px;
    font-size: 0.75em;
  }

  .timeline-action {
    min-width: 40px;
    font-size: 0.65em;
    padding: 2px;
    gap: 2px;
  }

  /* Action Phase Title - Smaller and repositioned */
  .action-phase-title {
    font-size: 0.75em;
    padding: 3px 6px;
    top: 25px;
  }

  /* Enemy Battlefield - Compact but enemy-readable */
  .enemy-battlefield {
    min-height: 140px;
    max-height: 170px;
    margin-bottom: 5px;
  }

  .enemy-lines-container,
  .character-lines-container {
    gap: 4px;
    margin-top: 35px; /* Reduced from 80px */
  }

  .enemy-line,
  .character-line {
    gap: 5px;
    padding: 4px;
    min-height: 60px; /* Enough room for enemy sprites */
    background: rgba(0, 0, 0, 0.2);
  }

  .enemy-line::before {
    display: none; /* Hide line labels on mobile */
  }

  /* Hide character portraits on battlefield (we show in action panel below) */
  .character-lines-container {
    display: none;
  }

  /* Enemies - legible size on mobile (was 30px, too small) */
  .enemy-portrait-wrapper {
    width: 55px;
    height: 55px;
  }

  .enemy-portrait {
    width: 55px;
    height: 55px;
    font-size: 0.75em;
  }

  .enemy-name {
    font-size: 0.65em;
    max-width: 60px;
    white-space: normal;
    text-align: center;
    line-height: 1.1;
  }

  .enemy-hp-bar-container {
    width: 55px;
    height: 4px;
  }

  /* Enemy sprites - reasonably sized on mobile */
  .enemy-sprite {
    width: 64px;
    height: 64px;
  }

  /* Bottom Section - Reorganize for mobile */
  .combat-bottom-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: rgba(20, 10, 35, 0.95);
    border: 2px solid rgba(138, 103, 255, 0.5);
    border-radius: 8px;
  }

  /* Show ONE character at a time on mobile */
  .mobile-active-character {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: rgba(61, 36, 99, 0.4);
    border: 2px solid #8a67ff;
    border-radius: 6px;
  }

  .mobile-character-portrait {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
  }

  .mobile-character-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .mobile-character-name {
    font-size: 0.9em;
    font-weight: bold;
    color: #f4e4c1;
  }

  .mobile-character-stats {
    display: flex;
    gap: 8px;
    font-size: 0.8em;
  }

  /* Character action buttons - Compact grid */
  .mobile-character-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 8px;
  }

  .action-btn {
    min-height: 50px;
    padding: 8px;
    font-size: 0.85em;
  }

  /* Combat Global Actions - Horizontal on mobile */
  .combat-global-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
  }

  .bulk-action-btn {
    flex: 1;
    min-width: 80px;
    min-height: 44px;
    font-size: 0.85em;
    padding: 8px 6px;
  }

  .combat-option {
    flex: 0 0 auto;
  }

  #submit-turn-button {
    width: 100%;
    min-height: 50px;
    font-size: 1em;
    font-weight: bold;
  }

  /* Combat Log - Collapsible/Smaller */
  .combat-log-section {
    max-height: 120px;
  }

  .log-header {
    font-size: 0.85em;
    padding: 4px 8px;
  }

  .combat-log {
    max-height: 90px;
    font-size: 0.8em;
  }

  /* Mobile Character Navigation */
  .mobile-combat-character-container {
    background: rgba(20, 10, 35, 0.95);
    border: 2px solid #8a67ff;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
  }

  .mobile-character-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    padding: 6px;
    background: rgba(61, 36, 99, 0.4);
    border-radius: 6px;
  }

  .mobile-char-nav-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.2em;
    background: rgba(138, 103, 255, 0.3);
    border: 2px solid #8a67ff;
    border-radius: 6px;
    color: #f4e4c1;
    cursor: pointer;
    transition: all 0.2s;
  }

  .mobile-char-nav-btn:active {
    background: rgba(138, 103, 255, 0.6);
    transform: scale(0.95);
  }

  .mobile-char-indicator {
    flex: 1;
    text-align: center;
    font-size: 1em;
    font-weight: bold;
    color: #f4e4c1;
  }

  .mobile-character-display {
    min-height: 200px;
  }

  /* Make character cards in mobile display full width */
  .mobile-character-display .character-combat-card {
    width: 100%;
    margin: 0;
  }
  
  /* Mobile turn indicator for non-current characters */
  .mobile-turn-indicator {
    background: rgba(218, 165, 32, 0.2) !important;
    border: 2px solid #daa520 !important;
    border-radius: 8px !important;
    padding: 10px !important;
    margin: 10px 0 !important;
    text-align: center !important;
    color: #daa520 !important;
    font-weight: bold !important;
    font-size: 0.95em !important;
  }

  .combat-main {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .character-actions-panel {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* === MODALS === */
  .modal-content,
  .character-detail-modal .detail-content,
  .inventory-container {
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
    max-height: 95vh;
    padding: 15px;
    border-radius: 8px;
  }

  .modal-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.  5em;
  }

  /* === TOUCH IMPROVEMENTS === */
  button,
  .clickable,
  a {
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(138, 103, 255, 0.3);
  }
}

/* ============================================================================
   PHONES (480px and below)
   ========================================================================== */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  /* === SPLASH & MENU === */
  .splash-content {
    padding: 20px 15px;
  }

  .splash-title {
    font-size: 2em;
    margin-bottom: 8px;
  }

  .splash-subtitle {
    font-size: 1em;
  }

  .splash-button {
    padding: 10px 20px;
    font-size: 1em;
  }

  .menu-container {
    padding: 20px 10px;
  }

  .menu-container h1 {
    font-size: 1.8em;
    margin-bottom: 20px;
  }

  .menu-options button,
  .primary-action-btn,
  .secondary-action-btn {
    padding: 12px;
    font-size: 1em;
  }

  /* === CHARACTER CREATION === */
  .creation-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  /* === CHARACTER SLOTS === */
  .character-slot {
    min-width: 120px;
    min-height: 80px;
    padding: 8px;
    font-size: 0.9em;
  }

  .char-portrait,
  .portrait-container {
    width: 50px;
    height: 50px;
  }

  /* === COMBAT === */
  .combat-modal {
    padding: 5px;
  }

  .character-actions-panel {
    grid-template-columns: 1fr;
  }

  .action-btn {
    font-size: 0.9em;
    min-height: 50px;
  }

  /* === FORMS === */
  .form-group label {
    font-size: 0.95em;
  }

  /* === STAT DISPLAYS === */
  .stat-label {
    font-size: 0.85em;
  }

  .stat-value {
    font-size: 1em;
  }

  /* === DUNGEON VIEW === */
  .controls {
    flex-direction: column;
    gap: 8px;
  }

  .control-row {
    display: flex;
    gap: 5px;
    justify-content: center;
  }

  .control-row button {
    flex: 1;
    min-height: 44px;
    font-size: 0.9em;
    padding: 8px 4px;
  }

  .first-person-preview {
    width: 100%;
  }

  .minimap-container {
    max-width: 100%;
  }

  .minimap-legend {
    font-size: 0.65em;
  }

  .minimap-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .minimap-controls button {
    flex: 1;
    min-width: 80px;
    font-size: 0.85em;
    padding: 8px 4px;
  }

  .message-log {
    position: fixed;
    top: 5px;
    left: 5px;
    right: 5px;
    max-height: 100px;
    max-width: calc(100% - 10px);
    font-size: 0.8em;
    padding: 6px;
    padding-top: 32px;
    z-index: 101;
    background: rgba(10, 5, 20, 0.85);
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  }

  .message-log.hidden {
    max-height: 32px;
    min-height: 32px;
  }

  .message-log.hidden::before {
    font-size: 0.75em;
    top: 6px;
  }

  .message-log-toggle {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }
}

/* ============================================================================
   LANDSCAPE ORIENTATION OPTIMIZATIONS
   ========================================================================== */
@media (max-width: 896px) and (orientation: landscape) {
  /* Optimize for landscape on mobile devices */
  .splash-content,
  .menu-container {
    max-height: 90vh;
    overflow-y: auto;
  }

  .game-container {
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr;
  }

  .party-column {
    flex-direction: column;
    width: 200px;
    height: 100%;
  }

  .character-slot {
    min-width: auto;
    width: 100%;
    margin-right: 0;
    margin-bottom: 8px;
  }

  .combat-modal {
    padding: 8px;
  }

  .combat-main {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================================
   EXISTING MOBILE OPTIMIZATIONS (Keep for compatibility)
   ============================================================================
   Comprehensive mobile-first responsive design for phones and tablets.
   Supports both portrait and landscape orientations.
   Optimizes for single-character control and touch interactions.
   ========================================================================== */

/* ============================================================================
   MOBILE: Small Phones (Portrait) - 320px to 480px
   ========================================================================== */
@media (max-width: 480px) {
  /* Base Layout Adjustments */
  body {
    font-size: 14px;
  }

  /* Game Container - Stack to Single Column */
  .game-container {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    padding: 5px;
    gap: 5px;
  }

  /* Hide party columns by default, show via toggle */
  .party-column {
    display: none;
    width: 100%;
    max-height: 40vh;
    overflow-y: auto;
  }

  .party-column.mobile-visible {
    display: flex;
  }

  /* Character Slots - Horizontal Scrolling */
  .character-slot {
    height: auto;
    min-height: 100px;
    padding: 8px;
    margin-bottom: 5px;
  }

  .char-portrait {
    width: 60px;
    height: 60px;
  }

  .portrait-container {
    width: 60px;
    height: 60px;
  }

  /* Buttons - Touch-Friendly Sizing */
  button, .primary-button, .secondary-action-btn {
    min-height: 44px;
    padding: 10px 15px;
    font-size: 14px;
    touch-action: manipulation;
  }

  /* Splash Screen */
  .splash-title {
    font-size: 2.5em;
  }

  .splash-subtitle {
    font-size: 1em;
  }

  /* Menu Containers */
  .menu-container {
    padding: 15px;
    max-width: 100%;
  }

  .menu-options button {
    width: 100%;
    margin: 5px 0;
  }

  /* Combat Modal - Full Screen on Mobile */
  .combat-modal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    padding: 5px;
  }

  .combat-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 5px;
  }

  .combat-formations {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 5px;
  }

  .formation-line {
    flex-direction: column;
    gap: 5px;
  }

  /* Character Actions Panel - Vertical Stack */
  .character-actions-panel {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    overflow-y: auto;
  }

  .combat-character-action {
    width: 100%;
    min-height: 80px;
    padding: 8px;
  }

  /* Action Buttons - Full Width */
  .action-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .action-btn {
    width: 100%;
    min-height: 44px;
  }

  /* World Map - Stack Vertically */
  .location-image-container {
    height: 200px;
  }

  .location-image {
    max-height: 200px;
    object-fit: cover;
  }

  .location-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .location-actions button {
    width: 100%;
  }

  /* Dungeon View - Optimize for Mobile */
  .view-and-map {
    flex-direction: column;
    position: relative;
  }

  .scene-container {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
  }

  #scene-canvas {
    width: 100%;
    height: 100%;
  }

  /* Hide tactical canvas on mobile, show minimap instead */
  .scene-container.tactical-grid-view {
    display: none;
  }

  /* Minimap - Larger and centered on mobile */
  .minimap-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
  }

  #minimap-canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  /* Message Log - Overlay at top of scene */
  .message-log {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    max-height: 120px;
    max-width: calc(100% - 20px);
    font-size: 0.85em;
    padding: 8px;
    padding-top: 35px;
    z-index: 101;
    background: rgba(10, 5, 20, 0.85);
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
    border-radius: 8px;
  }

  .message-log.hidden {
    max-height: 35px;
    min-height: 35px;
  }

  .message-log.hidden::before {
    font-size: 0.8em;
    top: 7px;
  }

  .message-log p {
    margin: 2px 0;
    line-height: 1.3;
  }

  /* Modals - Full Screen */
  .modal-content, .inventory-container {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    padding: 10px;
  }

  /* Inventory Layout - Single Column */
  .inventory-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Marketplace - Single Column */
  .marketplace-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Character Creation - Stack Forms */
  .creation-container {
    padding: 10px;
  }

  .stat-allocation {
    grid-template-columns: 1fr;
  }

  /* === BACKSTORY QUESTIONNAIRE & ORIGIN PATH - MOBILE === */
  .questionnaire-wrapper {
    padding: 10px;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .questionnaire-content {
    padding: 20px 15px;
    max-height: none;
    overflow: visible;
  }

  .questionnaire-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
  }

  .questionnaire-step {
    font-size: 0.85rem;
  }

  .question-text {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 20px;
    padding: 0 5px;
  }

  .questionnaire-answers {
    gap: 12px;
  }

  .answer-button {
    padding: 15px;
    font-size: 1rem;
    line-height: 1.4;
    min-height: 60px;
    display: flex;
    align-items: center;
    text-align: left;
    touch-action: manipulation;
  }

  .answer-button:active {
    transform: translateX(2px) scale(0.98);
  }

  /* Path Reveal - Mobile Optimized */
  .path-reveal-content {
    padding: 20px 15px;
    max-width: 100%;
    overflow-y: auto;
    max-height: 90vh;
  }

  .path-reveal-title {
    font-size: 1.3rem;
    letter-spacing: 1px;
  }

  .path-name {
    font-size: 1.8rem;
    margin-bottom: 20px;
  }

  .signature-moment {
    padding: 15px 20px;
    margin: 20px 0;
  }

  .signature-quote {
    font-size: 1rem;
    line-height: 1.5;
  }

  .path-description {
    font-size: 1rem;
    margin: 15px 0;
  }

  .emotional-core {
    padding: 12px;
    margin-top: 15px;
  }

  .path-reveal-actions {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .path-reveal-actions button {
    width: 100%;
    padding: 15px;
    font-size: 1.05rem;
    min-height: 48px;
  }

  /* Path Selection Grid - Mobile Optimized */
  .path-selection-content {
    padding: 20px 10px;
    overflow-y: auto !important;
    max-height: 90vh;
    -webkit-overflow-scrolling: touch;
  }

  .path-selection-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
  }

  .path-selection-subtitle {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .path-selection-grid {
    grid-template-columns: 1fr !important;
    gap: 15px;
    margin-bottom: 20px;
  }

  .path-card {
    padding: 20px 15px;
    min-height: 150px;
    touch-action: manipulation;
  }

  .path-card:active {
    transform: translateY(-2px) scale(0.98);
  }

  .path-card-name {
    font-size: 1.2rem;
    margin-bottom: 12px;
  }

  .path-card-description {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 12px;
  }

  .path-card-quote {
    font-size: 0.85rem;
    padding-top: 12px;
  }

  .path-selection-actions {
    padding: 0 10px;
  }

  .path-selection-actions button {
    width: 100%;
    padding: 12px;
    min-height: 44px;
  }

  /* Character Path Display in Creation - Mobile */
  .character-path-info {
    padding: 15px;
    margin-bottom: 20px;
  }

  .path-info-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .path-info-header h3 {
    font-size: 1.1rem;
  }

  .change-path-btn {
    width: 100%;
    text-align: center;
    padding: 10px 15px;
    min-height: 44px;
  }

  .path-name-badge {
    font-size: 1rem;
    padding: 6px 12px;
  }

  .path-info-content .path-description,
  .path-info-content .path-emotional-core {
    font-size: 0.9rem;
  }

  /* === CHARACTER CREATION FORM - MOBILE === */
  .creation-container {
    width: 100%;
    max-width: 100%;
    padding: 15px 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .creation-container h1 {
    font-size: 1.8rem;
    margin-bottom: 20px;
  }

  .creation-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .form-group {
    margin-bottom: 15px;
  }

  .form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 1rem;
    font-weight: bold;
  }

  #char-name,
  #char-race,
  #char-class {
    width: 100% !important;
    padding: 12px;
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 48px;
    border-radius: 6px;
    box-sizing: border-box;
  }

  .stat-display {
    padding: 15px;
    margin: 15px 0;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-item {
    padding: 10px;
    font-size: 0.9rem;
  }

  /* Button group - stack vertically on mobile */
  #character-creation .button-group {
    flex-direction: column;
    gap: 10px;
  }

  #character-creation .button-group button {
    width: 100%;
    flex: none;
    min-height: 48px;
  }

  #character-form button[type="submit"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 15px;
    font-size: 1.1rem;
    min-height: 52px;
    margin-top: 20px;
    box-sizing: border-box;
    flex: none !important;
  }

  /* Quest Trigger Modal - Mobile */
  .quest-trigger-modal .quest-trigger-content {
    max-width: 95vw;
    max-height: 85vh;
    margin: 10px;
    padding: 0;
  }

  .quest-trigger-header h2 {
    font-size: 1.5rem;
  }

  .quest-trigger-body {
    padding: 15px;
    overflow-y: auto;
    max-height: 50vh;
  }

  .quest-trigger-message {
    font-size: 1rem;
    padding: 12px;
  }

  .quest-preview {
    padding: 15px;
  }

  .quest-preview h3 {
    font-size: 1.3rem;
  }

  .quest-trigger-actions {
    flex-direction: column;
    gap: 10px;
    padding: 15px;
  }

  .accept-quest-btn,
  .decline-quest-btn {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    min-height: 48px;
  }

  /* Quest Log - Full Width */
  .quest-list {
    grid-template-columns: 1fr;
  }

  /* Skills Panel - Stack */
  .skills-container {
    grid-template-columns: 1fr;
  }

  /* NPC Dialogue - Full Screen */
  .dialogue-container {
    width: 100vw;
    max-width: 100vw;
    padding: 10px;
  }

  .dialogue-choices {
    flex-direction: column;
  }

  .dialogue-choice {
    width: 100%;
    margin: 5px 0;
  }
}

/* ============================================================================
   MOBILE: Medium Phones & Small Tablets (Portrait) - 481px to 768px
   ========================================================================== */
@media (min-width: 481px) and (max-width: 768px) {
  /* Game Container - More Space for Content */
  .game-container {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    padding: 8px;
    gap: 8px;
  }

  /* Party Columns - Collapsible */
  .party-column {
    display: none;
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
  }

  .party-column.mobile-visible {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .character-slot {
    flex: 1;
    min-width: 150px;
    height: auto;
    padding: 10px;
  }

  .char-portrait, .portrait-container {
    width: 70px;
    height: 70px;
  }

  /* Combat Modal - More Space */
  .combat-modal {
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
    max-height: 95vh;
    padding: 10px;
  }

  .character-actions-panel {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* World Map */
  .location-image-container {
    height: 250px;
  }

  .location-image {
    max-height: 250px;
  }

  /* Dungeon View */
  #scene-canvas {
    width: 100%;
    height: 250px;
  }

  #minimap-canvas {
    width: 100%;
    height: 180px;
  }

  /* Inventory - Can Show Side-by-Side */
  .inventory-layout {
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }
}

/* ============================================================================
   MOBILE: Landscape Orientation
   ========================================================================== */
@media (max-width: 896px) and (orientation: landscape) {
  /* Optimize for Horizontal Space */
  .game-container {
    display: grid;
    grid-template-columns: 150px 1fr;
    grid-template-rows: 1fr;
    padding: 5px;
    gap: 5px;
  }

  /* Show Left Party Column Only */
  .party-column.left-party {
    display: flex;
    width: 150px;
  }

  .party-column.right-party {
    display: none;
  }

  .character-slot {
    height: auto;
    min-height: 80px;
    padding: 5px;
    margin-bottom: 5px;
  }

  .char-portrait, .portrait-container {
    width: 50px;
    height: 50px;
  }

  /* Combat Modal - Use Horizontal Space */
  .combat-modal {
    width: 98vw;
    height: 95vh;
    max-width: 98vw;
    max-height: 95vh;
  }

  .combat-main {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
  }

  .character-actions-panel {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  /* Dungeon View - Side by Side in Landscape */
  .view-and-map {
    flex-direction: row;
    gap: 8px;
  }

  /* Show scene canvas in landscape */
  .scene-container.tactical-grid-view {
    display: flex;
    flex: 1;
  }

  #scene-canvas {
    width: 100%;
    height: 100%;
  }

  .minimap-container {
    width: 200px;
    flex-shrink: 0;
  }

  #minimap-canvas {
    width: 100%;
    height: auto;
  }

  /* Message Log - Top overlay in landscape */
  .message-log {
    position: fixed;
    top: 5px;
    left: 5px;
    right: 5px;
    max-height: 80px;
    max-width: calc(100% - 10px);
    font-size: 0.8em;
    padding-top: 32px;
    z-index: 101;
    background: rgba(10, 5, 20, 0.85);
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  }

  .message-log.hidden {
    max-height: 32px;
    min-height: 32px;
  }

  .message-log.hidden::before {
    font-size: 0.7em;
    top: 6px;
  }
}

/* ============================================================================
   TABLET: iPad & Small Tablets (Portrait) - 769px to 1024px
   ========================================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .game-container {
    grid-template-columns: 180px 1fr 180px;
    padding: 10px;
    gap: 10px;
  }

  .character-slot {
    height: 250px;
    padding: 8px;
  }

  .char-portrait, .portrait-container {
    width: 75px;
    height: 75px;
  }

  /* Combat - Slightly Smaller */
  .combat-modal {
    width: 95vw;
    height: 95vh;
    max-width: 95vw;
    max-height: 95vh;
  }

  .character-actions-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Inventory - Keep Two Column */
  .inventory-layout {
    grid-template-columns: 350px 1fr;
  }
}

/* ============================================================================
   MOBILE-SPECIFIC COMPONENTS
   ========================================================================== */

/* Mobile Party Toggle Button */
.mobile-party-toggle {
  display: none;
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 1000;
  background: linear-gradient(135deg, #8a67ff, #6a47df);
  border: 2px solid #d4af37;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 24px;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(138, 103, 255, 0.5);
  transition: all 0.3s;
  touch-action: manipulation;
}

.mobile-party-toggle:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(138, 103, 255, 0.5);
}

@media (max-width: 768px) {
  .mobile-party-toggle {
    display: block;
  }
}

/* Mobile Character Switcher */
.mobile-character-switcher {
  display: none;
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(20, 10, 35, 0.95);
  border: 2px solid #d4af37;
  border-radius: 10px;
  padding: 10px;
  max-width: 90vw;
  overflow-x: auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.mobile-character-switcher.active {
  display: flex;
}

.mobile-char-tab {
  min-width: 60px;
  height: 60px;
  margin: 0 5px;
  border: 2px solid #8a67ff;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
}

.mobile-char-tab.selected {
  border-color: #d4af37;
  background: rgba(138, 103, 255, 0.3);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.mobile-char-tab img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  image-rendering: pixelated;
}

@media (max-width: 768px) {
  .mobile-character-switcher {
    display: flex;
  }
}

/* Mobile Action Panel - Unified for Current Character */
.mobile-unified-actions {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 5, 20, 0.98);
  border-top: 2px solid #d4af37;
  padding: 10px;
  z-index: 999;
  max-height: 40vh;
  overflow-y: auto;
}

.mobile-unified-actions.active {
  display: block;
}

.mobile-action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mobile-action-btn {
  padding: 12px;
  background: linear-gradient(135deg, rgba(138, 103, 255, 0.3), rgba(106, 71, 223, 0.3));
  border: 2px solid #8a67ff;
  border-radius: 8px;
  color: #e8d4a0;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
}

.mobile-action-btn:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, rgba(138, 103, 255, 0.5), rgba(106, 71, 223, 0.5));
}

.mobile-action-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mobile-action-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

@media (max-width: 768px) {
  .mobile-unified-actions {
    display: block;
  }
}

/* Touch Optimization - Prevent Accidental Zooming */
@media (max-width: 768px) {
  button, a, .clickable {
    -webkit-tap-highlight-color: rgba(138, 103, 255, 0.3);
    -webkit-touch-callout: none;
    user-select: none;
  }

  /* Prevent Pull-to-Refresh on Game Screens */
  .screen {
    overscroll-behavior: contain;
  }

  /* Larger Touch Targets for Small Elements */
  .close-btn, .modal-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============================================================================
   MOBILE NAVIGATION IMPROVEMENTS
   ========================================================================== */

/* Mobile Menu - Hamburger Style */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1001;
  background: rgba(138, 103, 255, 0.9);
  border: 2px solid #d4af37;
  border-radius: 8px;
  width: 50px;
  height: 50px;
  font-size: 24px;
  color: white;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
}

/* Mobile Navigation Drawer */
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: -300px;
  width: 280px;
  height: 100vh;
  background: rgba(10, 5, 20, 0.98);
  border-right: 2px solid #d4af37;
  z-index: 1002;
  padding: 70px 15px 15px;
  overflow-y: auto;
  transition: left 0.3s ease;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
}

.mobile-nav-drawer.open {
  left: 0;
}

@media (max-width: 768px) {
  .mobile-nav-drawer {
    display: block;
  }
}

.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1001;
}

.mobile-nav-overlay.active {
  display: block;
}

.mobile-nav-item {
  width: 100%;
  padding: 15px;
  margin: 5px 0;
  background: rgba(138, 103, 255, 0.2);
  border: 1px solid #8a67ff;
  border-radius: 8px;
  color: #e8d4a0;
  text-align: left;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-nav-item:active {
  background: rgba(138, 103, 255, 0.4);
}

/* ============================================================================
   ACCESSIBILITY & PERFORMANCE
   ========================================================================== */

@media (max-width: 768px) {
  /* Reduce Animation Complexity on Mobile */
  .particle, .effect-particle {
    will-change: transform;
    animation-duration: 0.8s; /* Shorter animations */
  }

  /* Simplify Shadows for Performance */
  .character-slot:hover,
  button:hover,
  .modal-content {
    box-shadow: 0 2px 8px rgba(138, 103, 255, 0.3);
  }

  /* Optimize Canvas Rendering */
  canvas {
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
  }
}

/* ============================================================================
   LANDSCAPE-SPECIFIC OPTIMIZATIONS
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
  /* Very Short Landscape Screens */
  .modal-content, .combat-modal {
    max-height: 98vh;
    padding: 5px;
  }

  .character-slot {
    min-height: 60px;
    padding: 4px;
  }

  .char-portrait, .portrait-container {
    width: 40px;
    height: 40px;
  }

  button, .primary-button {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 36px;
  }

  .combat-character-action {
    min-height: 60px;
    padding: 5px;
  }
}

/* ============================================================================
   PRINT STYLES (Keep Clean for Character Sheets, etc.)
   ========================================================================== */

@media print {
  .mobile-party-toggle,
  .mobile-character-switcher,
  .mobile-unified-actions,
  .mobile-menu-toggle,
  .mobile-nav-drawer,
  .mobile-nav-overlay,
  button,
  .controls {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .screen {
    display: block !important;
    width: 100%;
    height: auto;
  }
}

/* ============================================================================
   ADDITIONAL MOBILE SCREEN OPTIMIZATIONS
   ========================================================================== */

/* Combat Modal Mobile Enhancements */
@media (max-width: 768px) {
  /* Combat Modal - Full Screen */
  .combat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0;
    margin: 0;
    padding: 5px;
    overflow-y: auto;
  }

  /* Combat Battlefield Layout */
  .combat-battlefield {
    flex-direction: column;
    gap: 10px;
  }

  /* Enemy Formation - Stack Vertically */
  .combat-enemy-formation {
    width: 100%;
    min-height: 150px;
  }

  /* Character Formation - Horizontal Scroll */
  .combat-character-formation {
    width: 100%;
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px;
  }

  /* Combat Log - Compact */
  .combat-log-container {
    max-height: 120px;
    font-size: 0.85em;
    padding: 5px;
  }
  
  /* Combat Log Toggle (Mobile Only) */
  .combat-log-toggle {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #8a67ff, #6a47df);
    border: 2px solid #d4af37;
    border-radius: 8px;
    color: #fff;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.3s;
    min-height: 44px;
    touch-action: manipulation;
  }
  
  .combat-log-toggle:active {
    background: linear-gradient(135deg, #7a57ef, #5a37cf);
    transform: scale(0.98);
  }
  
  .combat-log-section.collapsed {
    display: none !important;
  }

  /* CT Timeline - Horizontal on Mobile */
  .ct-timeline {
    width: 100%;
    overflow-x: auto;
    flex-direction: row;
    padding: 5px;
  }

  .ct-actor {
    min-width: 50px;
    height: 60px;
  }

  /* Combat Buttons - Full Width */
  .combat-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
  }

  .combat-controls button {
    width: 100%;
    min-height: 44px;
  }

  /* Turn Timer - Top Right */
  .turn-timer {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1001;
    font-size: 1.2em;
  }
}

/* Character Selection Mobile Enhancements */
@media (max-width: 768px) {
  .character-selection-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .character-card {
    width: 100%;
    padding: 15px;
  }

  .character-card-portrait {
    width: 80px;
    height: 80px;
  }
}

/* Marketplace Mobile Enhancements */
@media (max-width: 768px) {
  .marketplace-container {
    padding: 10px;
  }

  .shop-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .shop-tab {
    flex: 1;
    min-width: 100px;
    padding: 10px;
    font-size: 0.9em;
  }

  .shop-items-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .shop-item-card {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 10px;
  }

  .shop-item-portrait {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
  }

  .shop-item-info {
    flex: 1;
  }

  .shop-item-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
}

/* Quest Log Mobile Enhancements */
@media (max-width: 768px) {
  .quest-log-container {
    padding: 10px;
  }

  .quest-tabs {
    flex-direction: column;
    gap: 5px;
  }

  .quest-tab {
    width: 100%;
    text-align: center;
  }

  .quest-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .quest-item {
    width: 100%;
    padding: 15px;
  }

  .quest-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .quest-objectives {
    padding-left: 10px;
  }
}

/* Crafting Mobile Enhancements */
@media (max-width: 768px) {
  .crafting-container {
    padding: 10px;
  }

  .crafting-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  .recipe-list {
    max-height: 200px;
    overflow-y: auto;
  }

  .recipe-item {
    padding: 10px;
    margin: 5px 0;
  }

  .crafting-preview {
    width: 100%;
  }

  .ingredient-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .ingredient-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
  }
}

/* NPC Dialogue Mobile Enhancements â€” Apple-quality bottom sheet */
@media (max-width: 768px) {
  /* Sheet rises from the bottom of the screen */
  .dialogue-modal {
    align-items: flex-end;
    padding: 0;
  }

  /* Auto-height sheet capped at 92svh (svh = small-viewport-height, safe in Safari) */
  .dialogue-content {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    /* Fixed height so the sheet doesn't jump when dialogue text or options change */
    height: min(92svh, 92vh);
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.65);
    padding-top: 0;
  }

  /* Drag handle hint at the top of the sheet */
  .dialogue-content::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    margin: 10px auto 4px;
    flex-shrink: 0;
  }

  /* Compact header â€” portrait + name side by side */
  .dialogue-header {
    flex-shrink: 0;
    padding: 10px 16px;
    gap: 10px;
  }

  .dialogue-portrait {
    width: 52px;
    height: 52px;
    margin-right: 10px;
  }

  .dialogue-header h2 {
    font-size: 1.1em;
  }

  .npc-title {
    font-size: 0.8em;
  }

  /* NPC text is scrollable but capped â€” options always have room below */
  .dialogue-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 35svh;
    max-height: 35vh; /* fallback */
    min-height: 50px;
    padding: 14px 16px;
  }

  .dialogue-line {
    font-size: 0.95em;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  /* Options are ALWAYS visible â€” never pushed off screen */
  .dialogue-choices,
  .dialogue-options {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    /* Scrollable only if many options â€” rare */
    max-height: 48svh;
    max-height: 48vh; /* fallback */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 2px solid #8a67ff;
  }

  /* Tap targets meet iOS HIG 44 pt minimum */
  .dialogue-choice,
  .dialogue-option {
    width: 100%;
    padding: 13px 14px;
    font-size: 0.93em;
    min-height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    text-align: left;
  }

  /* Shop section gets its own scroll so it doesn't overflow */
  .npc-shop-section {
    flex-shrink: 0;
    max-height: 30svh;
    max-height: 30vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dialogue-rewards {
    flex-direction: column;
    gap: 8px;
  }
}

/* â”€â”€ Premium NPC Presence Section ("Characters Here") â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

/* Legacy selectors kept for non-mobile desktop fallback */
.mobile-character-list {
  margin: 0;
  padding: 0;
}

.mobile-character-items {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* On mobile: world-map-container scrolls */
@media (max-width: 768px) {
  .world-map-container {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* Premium Presence Section */
.mobile-presence-section {
  background: rgba(8, 4, 18, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid rgba(218, 165, 32, 0.25);
  padding: 16px 14px 20px;
}

.mobile-presence-header {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  color: rgba(218, 165, 32, 0.65);
  margin-bottom: 14px;
  text-align: center;
}

.mobile-presence-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Individual NPC / player presence card */
.presence-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  background: rgba(20, 10, 38, 0.72);
  border: 1px solid rgba(138, 103, 255, 0.22);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  transition: background 0.18s, transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.presence-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(218, 165, 32, 0.06), transparent 60%);
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
}

.presence-card.npc {
  cursor: pointer;
  border-color: rgba(218, 165, 32, 0.28);
}

.presence-card.npc:active {
  transform: scale(0.97);
  background: rgba(35, 16, 65, 0.88);
}

.presence-card.npc:active::before {
  opacity: 1;
}

.presence-card.player-char {
  border-color: rgba(74, 174, 255, 0.2);
  cursor: default;
}

/* Portrait wrapper */
.presence-portrait-wrap {
  position: relative;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
}

.presence-portrait {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid rgba(138, 103, 255, 0.5);
  object-fit: contain;
  background: #0a0612;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
  box-shadow: 0 0 10px rgba(0,0,0,0.6), inset 0 0 6px rgba(0,0,0,0.4);
}

.presence-card.npc .presence-portrait {
  border-color: rgba(218, 165, 32, 0.75);
  box-shadow: 0 0 16px rgba(218, 165, 32, 0.32), inset 0 0 6px rgba(0,0,0,0.4);
}

.presence-card.player-char .presence-portrait {
  border-color: rgba(74, 174, 255, 0.55);
  box-shadow: 0 0 10px rgba(74, 174, 255, 0.22);
}

/* Animated "talk" beacon */
.presence-talk-beacon {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #c89020, #daa520);
  border-radius: 50%;
  border: 2px solid rgba(8, 4, 18, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  animation: beacon-pulse 2.2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(218, 165, 32, 0.5);
}

@keyframes beacon-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(218, 165, 32, 0.55), 0 0 8px rgba(218, 165, 32, 0.4); }
  55% { box-shadow: 0 0 0 6px rgba(218, 165, 32, 0), 0 0 14px rgba(218, 165, 32, 0.2); }
}

/* Text info */
.presence-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.presence-name {
  font-size: 0.97em;
  font-weight: 700;
  color: #f4e4c1;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-card.npc .presence-name {
  text-shadow: 0 0 10px rgba(218, 165, 32, 0.28);
}

.presence-title-text {
  font-size: 0.78em;
  color: rgba(201, 168, 112, 0.8);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-hint {
  font-size: 0.7em;
  color: rgba(218, 165, 32, 0.55);
  letter-spacing: 0.5px;
  margin-top: 1px;
}

/* Chevron arrow */
.presence-arrow {
  color: rgba(218, 165, 32, 0.5);
  font-size: 1.1em;
  font-weight: 300;
  flex-shrink: 0;
  line-height: 1;
}

.presence-card.player-char .presence-arrow {
  display: none;
}

/* â”€â”€ "NEW" NPC badge â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.npc-new-badge {
  display: inline-block;
  margin-left: 6px;
  background: #c84b00;
  color: #fff;
  font-size: 0.6em;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 2px 5px;
  border-radius: 4px;
  vertical-align: middle;
  line-height: 1.4;
  animation: new-badge-pulse 2s ease-in-out infinite;
}

@keyframes new-badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.presence-card.npc-unmet {
  border-color: rgba(255, 140, 0, 0.55) !important;
  box-shadow: 0 0 12px rgba(255, 140, 0, 0.22);
}

/* â”€â”€ NPC expander section â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.npc-expander-section {
  margin-bottom: 2px;
}

.npc-expander-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(20, 10, 38, 0.72);
  border: 1px solid rgba(218, 165, 32, 0.28);
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  color: #f4e4c1;
  font-size: 0.95em;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.npc-expander-toggle:active {
  background: rgba(35, 16, 65, 0.88);
}

.npc-expander-icon {
  font-size: 1.1em;
}

.npc-expander-label {
  flex: 1;
}

.npc-count {
  font-weight: 400;
  color: rgba(201, 168, 112, 0.8);
  margin-left: 2px;
}

.npc-expander-arrow {
  font-size: 0.75em;
  color: rgba(218, 165, 32, 0.6);
  transition: transform 0.2s;
}

.npc-expander-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 9px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.npc-expander-collapsed {
  display: none;
}

/* â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
   Recent Activity Strip (dungeon entry log)
   â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.recent-activity-strip {
  background: linear-gradient(135deg, rgba(30, 15, 5, 0.88), rgba(50, 25, 8, 0.88));
  border: 1px solid rgba(180, 100, 20, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  font-size: 0.78em;
  color: #c8a060;
  max-width: 400px;
}
.recent-activity-header {
  font-weight: 700;
  color: #e8b870;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}
.recent-activity-row {
  padding: 2px 0;
  opacity: 0.85;
}
.recent-activity-row::before {
  content: 'â†’ ';
  color: #a06030;
}

/* Dungeon co-presence awareness toast */
.dungeon-encounter-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(20, 8, 40, 0.96), rgba(40, 16, 70, 0.96));
  border: 1px solid rgba(180, 120, 60, 0.7);
  border-radius: 10px;
  padding: 10px 22px;
  color: #e8c870;
  font-size: 0.9em;
  z-index: 2500;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  animation: dungeonToastIn 0.3s ease-out forwards;
  max-width: min(90vw, 400px);
  text-align: center;
}
@keyframes dungeonToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.dungeon-encounter-toast-fade {
  animation: dungeonToastOut 0.6s ease-in forwards;
}
@keyframes dungeonToastOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
   First-Combat Tutorial Tooltip
   â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.combat-tutorial-overlay {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(15, 10, 30, 0.95), rgba(30, 15, 60, 0.95));
  border: 2px solid #7855c0;
  border-radius: 12px;
  padding: 14px 20px;
  color: #d0b8ff;
  font-size: 0.9em;
  text-align: center;
  z-index: 9100;
  max-width: 280px;
  width: max-content;
  box-shadow: 0 4px 24px rgba(100, 50, 200, 0.5);
  pointer-events: none;
  animation: tutorial-fade-in 0.4s ease;
}
.combat-tutorial-overlay .tutorial-title {
  font-weight: 700;
  color: #c0a0ff;
  font-size: 1.05em;
  margin-bottom: 6px;
}
.combat-tutorial-overlay .tutorial-arrow {
  font-size: 1.4em;
  display: block;
  margin-top: 8px;
  animation: tutorial-bounce 0.8s infinite alternate;
}
@keyframes tutorial-fade-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes tutorial-bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(6px); }
}
@keyframes tutorial-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.combat-tutorial-fade-out {
  animation: tutorial-fade-out 0.5s ease forwards;
}

/* Skills/Abilities Mobile Enhancements */
@media (max-width: 768px) {
  .skills-modal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    padding: 10px;
  }

  .skill-tree-container {
    overflow-x: auto;
    padding: 10px;
  }

  .skill-node {
    min-width: 80px;
    min-height: 80px;
  }

  .skill-details {
    position: fixed;
    bottom: 70px;
    left: 0;
    right: 0;
    background: rgba(10, 5, 20, 0.98);
    border-top: 2px solid #d4af37;
    padding: 15px;
    max-height: 40vh;
    overflow-y: auto;
    z-index: 1000;
  }

  .spell-list, .ability-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .spell-item, .ability-item {
    padding: 12px;
    width: 100%;
  }
}

/* World Map Mobile Enhancements */
@media (max-width: 768px) {
  .world-map-viewer-container {
    width: 100vw;
    height: 100vh;
    padding: 10px;
  }

  .world-map-image {
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  .world-map-hotspots {
    position: relative;
  }

  .map-hotspot {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.2em;
  }

  .location-navigation {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .location-button {
    width: 100%;
    padding: 12px;
    min-height: 44px;
  }
}

/* Party Management Mobile Enhancements */
@media (max-width: 768px) {
  .party-menu-container {
    padding: 10px;
  }

  .party-members-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .party-member-card {
    width: 100%;
    padding: 15px;
  }

  .party-member-portrait {
    width: 70px;
    height: 70px;
  }

  .party-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .party-actions button {
    width: 100%;
    min-height: 44px;
  }
}

/* Settings Mobile Enhancements */
@media (max-width: 768px) {
  .settings-container {
    padding: 15px;
  }

  .settings-section {
    margin-bottom: 20px;
  }

  .setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .setting-label {
    font-size: 1em;
    font-weight: bold;
  }

  .setting-control {
    width: 100%;
  }

  .slider {
    width: 100%;
  }

  .checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

/* Form Elements Mobile Enhancements */
@media (max-width: 768px) {
  input[type="text"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    width: 100%;
    padding: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
    border-radius: 8px;
  }

  .form-group {
    margin-bottom: 15px;
  }

  .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
  }

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

  .form-actions button {
    width: 100%;
    min-height: 48px;
  }
}

/* Loading Screens Mobile */
@media (max-width: 768px) {
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 5, 20, 0.95);
    z-index: 10000;
  }

  .loading-spinner {
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
  }

  .loading-text {
    font-size: 1.2em;
    color: #d4af37;
  }
}

/* Notification/Toast Messages Mobile */
@media (max-width: 768px) {
  .notification {
    position: fixed;
    bottom: 80px; /* Above mobile actions panel */
    left: 10px;
    right: 10px;
    padding: 15px;
    background: rgba(138, 103, 255, 0.95);
    border: 2px solid #d4af37;
    border-radius: 8px;
    color: white;
    font-size: 1em;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .notification.error {
    background: rgba(220, 53, 69, 0.95);
  }

  .notification.success {
    background: rgba(76, 175, 80, 0.95);
  }

  .notification.warning {
    background: rgba(255, 165, 0, 0.95);
  }
}

/* Mobile-Specific Animations - Keep Simple for Performance */
@media (max-width: 768px) {
  @keyframes mobileSlideIn {
    from {
      transform: translateX(-100%);
    }
    to {
      transform: translateX(0);
    }
  }

  @keyframes mobileSlideOut {
    from {
      transform: translateX(0);
    }
    to {
      transform: translateX(-100%);
    }
  }

  @keyframes mobileFadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  .mobile-slide-in {
    animation: mobileSlideIn 0.3s ease-out;
  }

  .mobile-slide-out {
    animation: mobileSlideOut 0.3s ease-in;
  }

  .mobile-fade-in {
    animation: mobileFadeIn 0.3s ease-out;
  }
}
/* ============================================================================
   MOBILE: Dungeon Swipe Navigation
   ============================================================================ */

/* Swipe direction indicator - appears briefly after each swipe */
/* â”€â”€ Rotate-device overlay for maps â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.rotate-device-prompt {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(10, 5, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.rotate-device-content {
  text-align: center;
  color: #f4e4c1;
  max-width: 320px;
}

.rotate-device-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  display: block;
  animation: rotate-hint 2s ease-in-out infinite;
  transform-origin: center;
}

@keyframes rotate-hint {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(90deg); }
  50%  { transform: rotate(90deg); }
  75%  { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

.rotate-device-title {
  font-size: 1.4rem;
  color: #daa520;
  margin: 0 0 12px;
}

.rotate-device-message {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #c9a870;
  margin: 0 0 24px;
}

.rotate-device-continue {
  background: transparent;
  border: 2px solid #8a67ff;
  border-radius: 8px;
  color: #8a67ff;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 20px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s, color 0.2s;
}

.rotate-device-continue:hover,
.rotate-device-continue:active {
  background: rgba(138, 103, 255, 0.15);
  color: #c9a870;
}

#mobile-swipe-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(138, 103, 255, 0.85);
  color: #fff;
  font-size: 1.4rem;
  font-weight: bold;
  padding: 14px 24px;
  border-radius: 12px;
  border: 2px solid #b49aff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9999;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

#mobile-swipe-indicator.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* First-time swipe hint overlay */
.mobile-nav-hint {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 18, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.35s ease;
}

.mobile-nav-hint.fading {
  opacity: 0;
}

.mobile-nav-hint-inner {
  background: rgba(20, 10, 35, 0.96);
  border: 2px solid #8a67ff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 320px;
  width: 90vw;
  text-align: left;
}

.mobile-nav-hint-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  color: #d4c4ff;
  font-size: 1rem;
}

.mobile-nav-hint-row .hint-arrow {
  font-size: 1.6rem;
  min-width: 36px;
  text-align: center;
  color: #b49aff;
}

.hint-dismiss {
  margin-top: 18px;
  text-align: center;
  font-size: 0.8rem;
  color: #8a67ff;
  opacity: 0.8;
}

/* â”€â”€ Portrait mobile nav bar â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

/* Sticky bottom navigation bar injected by mobile-ui.js on portrait phones */
.mobile-nav-bar {
  display: none; /* hidden on desktop; mobile-ui.js shows it via .is-mobile body class */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 600;
  background: rgba(10, 5, 20, 0.96);
  border-top: 2px solid #3d2463;
  padding: 6px 8px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.is-mobile .mobile-nav-bar {
  display: block;
}

.mobile-nav-bar-inner {
  display: grid;
  grid-template-columns: repeat(2, 1fr) auto repeat(2, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 5px;
  max-width: 480px;
  margin: 0 auto;
}

.mobile-nav-btn {
  min-height: 48px;
  padding: 8px 4px;
  border: 1px solid #5a3a8a;
  background: rgba(61, 36, 99, 0.7);
  color: #f4e4c1;
  font-size: 0.85em;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(218,165,32,0.2);
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.15s, border-color 0.15s;
}

.mobile-nav-btn:active {
  background: rgba(138, 103, 255, 0.5);
  border-color: #daa520;
}

.mobile-nav-btn.nav-north { grid-column: 2; grid-row: 1; }
.mobile-nav-btn.nav-west  { grid-column: 1; grid-row: 2; }
.mobile-nav-btn.nav-south { grid-column: 2; grid-row: 2; }
.mobile-nav-btn.nav-east  { grid-column: 4; grid-row: 2; }

/* Rest/Menu/Party in col 3 (auto) and flanks row 1 */
.mobile-nav-btn.nav-look { grid-column: 3; grid-row: 1; }
.mobile-nav-btn.nav-rest { grid-column: 3; grid-row: 2; }
.mobile-nav-btn.nav-ladder { grid-column: 3; grid-row: 2; }
.mobile-nav-btn.nav-party { grid-column: 1; grid-row: 1; }
.mobile-nav-btn.nav-menu { grid-column: 5; grid-row: 1; }
.mobile-nav-btn.nav-look { grid-column: 5; grid-row: 2; }

/* Give directional buttons a slightly highlighted look */
.mobile-nav-btn.nav-north,
.mobile-nav-btn.nav-south,
.mobile-nav-btn.nav-west,
.mobile-nav-btn.nav-east {
  border-color: #7a5ab8;
}

/* When the game screen is active, hide the built-in .controls block (first-person
   preview + nav button rows) â€” replaced by the fixed mobile-nav-bar */
body.is-mobile #game.active .controls {
  display: none;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   TITLES PANEL
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */

.titles-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.titles-panel {
  background: linear-gradient(160deg, #0d0820 0%, #1a0f2e 100%);
  border: 1px solid #8a67ff;
  border-radius: 8px;
  width: min(480px, 94vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(138, 103, 255, 0.25);
}

.titles-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(138, 103, 255, 0.3);
  flex-shrink: 0;
}
.titles-header-icon { font-size: 1.3em; }
.titles-header-label { font-size: 1.1em; font-weight: bold; color: #daa520; flex: 1; }
.titles-progress { font-size: 0.75em; color: #8a8aaa; }
.titles-close-btn {
  background: transparent;
  border: 1px solid #555;
  color: #aaa;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 7px;
  font-size: 0.9em;
}
.titles-close-btn:hover { background: rgba(255,80,80,0.15); color: #ff7070; }

.titles-active-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(218, 165, 32, 0.08);
  border-bottom: 1px solid rgba(218, 165, 32, 0.15);
  flex-shrink: 0;
}
.titles-active-label { font-size: 0.8em; color: #998a60; }
.titles-active-name { font-weight: bold; color: #daa520; flex: 1; font-style: italic; }
.titles-no-title .titles-active-label { color: #666; font-style: italic; }
.titles-clear-btn {
  background: transparent;
  border: 1px solid #666;
  color: #999;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75em;
  padding: 2px 8px;
}
.titles-clear-btn:hover { background: rgba(255,80,80,0.1); color: #ff9090; }

.titles-list {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.titles-empty {
  text-align: center;
  color: #706080;
  padding: 24px 16px;
}
.titles-hint { font-size: 0.8em; margin-top: 8px; color: #504060; }

.title-card {
  background: rgba(15, 8, 30, 0.7);
  border: 1px solid rgba(138, 103, 255, 0.2);
  border-radius: 6px;
  padding: 12px 14px;
  transition: border-color 0.2s;
}
.title-card:hover { border-color: rgba(218, 165, 32, 0.4); }
.title-card-active {
  border-color: rgba(218, 165, 32, 0.6);
  background: rgba(218, 165, 32, 0.06);
}

.title-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.title-name { font-weight: bold; font-size: 1em; font-style: italic; }
.title-rarity { font-size: 0.72em; }
.title-description { font-size: 0.82em; color: #c8b8e0; margin-bottom: 4px; }
.title-flavor { font-size: 0.75em; color: #706080; font-style: italic; margin-bottom: 8px; }
.title-active-indicator { font-size: 0.78em; color: #daa520; }
.title-equip-btn {
  background: rgba(138, 103, 255, 0.2);
  border: 1px solid rgba(138, 103, 255, 0.5);
  color: #c8b8f8;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78em;
  padding: 4px 12px;
  transition: all 0.2s;
}
.title-equip-btn:hover {
  background: rgba(218, 165, 32, 0.2);
  border-color: rgba(218, 165, 32, 0.6);
  color: #ffd700;
}
}

/* Pad the minimap container so the fixed nav bar doesn't overlap the bottom */
body.is-mobile #game.active .minimap-container {
  padding-bottom: calc(116px + env(safe-area-inset-bottom));
}

/* â”€â”€ Party FAB â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.mobile-party-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 601;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3d2463, #5a3a8a);
  border: 2px solid rgba(218, 165, 32, 0.6);
  color: #f4e4c1;
  font-size: 1.3em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55), 0 0 12px rgba(138, 103, 255, 0.3);
  align-items: center;
  justify-content: center;
  transition: transform 0.18s, box-shadow 0.18s;
}

.mobile-party-fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

body.is-mobile.party-fab-visible .mobile-party-fab {
  display: flex;
}

/* â”€â”€ Party Sheet (bottom slide-up) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.mobile-party-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 8000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.mobile-party-sheet-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.mobile-party-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 88vh;
  background: linear-gradient(180deg, #120a22 0%, #0d0719 100%);
  border-top: 1px solid rgba(218, 165, 32, 0.35);
  border-radius: 20px 20px 0 0;
  z-index: 8001;
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.7), 0 -1px 0 rgba(218, 165, 32, 0.2);
}

.mobile-party-sheet.open {
  transform: translateY(0);
}

/* Drag handle */
.party-sheet-handle {
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

/* Sheet header */
.party-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 14px;
  border-bottom: 1px solid rgba(138, 103, 255, 0.18);
  flex-shrink: 0;
}

.party-sheet-title {
  font-size: 0.75em;
  font-weight: 700;
  color: rgba(218, 165, 32, 0.8);
  letter-spacing: 2.5px;
  text-transform: uppercase;
}

.party-sheet-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.5em;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
}

.party-sheet-close:active {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

/* Scrollable body */
.party-sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 44px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* â”€â”€ Party Character Cards â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.party-char-card {
  background: rgba(20, 10, 40, 0.78);
  border: 1px solid rgba(138, 103, 255, 0.25);
  border-left: 4px solid var(--char-color, #8a67ff);
  border-radius: 14px;
  padding: 14px 14px 14px 12px;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.15s, transform 0.14s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.party-char-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, var(--char-color, #8a67ff) 0%, transparent 45%);
  opacity: 0.04;
  pointer-events: none;
}

.party-char-card:active {
  transform: scale(0.975);
  background: rgba(35, 16, 65, 0.9);
}

/* Portrait */
.party-char-portrait-wrap {
  position: relative;
  width: 62px;
  height: 62px;
  flex-shrink: 0;
}

.party-char-portrait {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  border: 2px solid var(--char-color, #8a67ff);
  object-fit: contain;
  background: #0a0612;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5);
}

/* HP status ring around portrait */
.party-char-hp-ring {
  position: absolute;
  inset: -3px;
  border-radius: 13px;
  background: transparent;
  border: 3px solid transparent;
  pointer-events: none;
  transition: border-color 0.4s;
}

/* Info section */
.party-char-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.party-char-name {
  font-size: 1em;
  font-weight: 700;
  color: #f4e4c1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

.party-char-meta {
  font-size: 0.73em;
  color: rgba(201, 168, 112, 0.75);
  text-transform: capitalize;
  margin-bottom: 2px;
}

/* Resource bars */
.party-char-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 3px;
}

.party-char-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.party-char-bar-icon {
  font-size: 0.68em;
  width: 12px;
  flex-shrink: 0;
  line-height: 1;
  text-align: center;
}

.party-char-bar-track {
  flex: 1;
  height: 5px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  overflow: hidden;
}

.party-char-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.party-char-bar-fill.hp {
  background: linear-gradient(90deg, #3ddd6e, #22c35e);
}

.party-char-bar-fill.hp.low {
  background: linear-gradient(90deg, #ffb74d, #f57c00);
}

.party-char-bar-fill.hp.critical {
  background: linear-gradient(90deg, #ef5350, #b71c1c);
}

.party-char-bar-fill.mp {
  background: linear-gradient(90deg, #56b4ff, #1565c0);
}

.party-char-bar-fill.chakra {
  background: linear-gradient(90deg, #ffe066, #f57f17);
}

.party-char-bar-fill.resolve {
  background: linear-gradient(90deg, #ff7043, #bf360c);
}

.party-char-bar-text {
  font-size: 0.63em;
  color: rgba(232, 212, 160, 0.6);
  min-width: 50px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Detail chevron */
.party-char-detail-arrow {
  color: rgba(201, 168, 112, 0.45);
  font-size: 1.2em;
  font-weight: 300;
  flex-shrink: 0;
  line-height: 1;
}

/* Empty party state */
.party-sheet-empty {
  text-align: center;
  color: rgba(201, 168, 112, 0.55);
  font-style: italic;
  padding: 40px 20px;
  font-size: 0.95em;
}

/* Keep old drawer class for compatibility - redirect to sheet */
.mobile-party-drawer {
  display: none;
}

.mobile-party-drawer-overlay {
  display: none;
}

/* â”€â”€ Login screen tabs â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.login-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid #3d2463;
}

.login-tab {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  color: #8a67ff;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: inherit;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.login-tab.active {
  color: #f4e4c1;
  border-bottom-color: #daa520;
}

.login-tab:not(.active):hover {
  color: #c9a870;
  background: rgba(138, 103, 255, 0.1);
}

/* Floating keyboard-dismiss button (iOS login) */
.login-keyboard-dismiss-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9999;
  background: #8a67ff;
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 1em;
  font-weight: bold;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  cursor: pointer;
  touch-action: manipulation;
}

/* Remember-me row */
.remember-me-row {
  margin-top: 4px;
  margin-bottom: 0;
}

.remember-me-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: #c9a870;
  font-size: 0.9em;
  user-select: none;
  -webkit-user-select: none;
}

.remember-me-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #8a67ff;
  flex-shrink: 0;
}

/* Tighten the login form on mobile */
@media (max-width: 480px) {
  .login-tab {
    font-size: 0.95em;
    padding: 11px 4px;
  }
}

/* â”€â”€ Town "More options" toggle button â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.town-more-btn {
  width: 100%;
  padding: 10px;
  background: rgba(138, 103, 255, 0.15);
  border: 1px dashed #8a67ff;
  border-radius: 8px;
  color: #a99de0;
  font-size: 0.95em;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  transition: background 0.2s, color 0.2s;
  min-height: 44px;
}

.town-more-btn:active {
  background: rgba(138, 103, 255, 0.3);
  color: #e8d4a0;
}

/* â”€â”€ Collapsible secondary action group â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.town-secondary-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  max-height: 600px;
  opacity: 1;
}

.town-secondary-actions.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}


/* ===================================================
   HOUSING SYSTEM STYLES
   =================================================== */

/* Toast notification */
.housing-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 9999;
  font-size: 0.95em;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: opacity 0.6s ease;
}
.housing-toast-success { background: #1a4d1a; border: 1px solid #4caf50; color: #c8e6c9; }
.housing-toast-error   { background: #4d1a1a; border: 1px solid #f44336; color: #ffcdd2; }
.housing-toast-info    { background: #1a2e4d; border: 1px solid #2196f3; color: #bbdefb; }
.housing-toast-fade    { opacity: 0; }

/* Modal override for housing */
.housing-modal {
  max-width: 680px;
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #555 #222;
}
.housing-modal h2 { margin-bottom: 4px; }
.housing-modal h3 { margin: 0 0 8px; font-size: 1em; color: #ffd700; border-bottom: 1px solid #333; padding-bottom: 4px; }

/* House / furniture cards */
.housing-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.housing-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: #1c1c1c;
  border: 1px solid #444;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}
.housing-card:hover           { border-color: #ffd700; transform: translateX(3px); }
.housing-card-owned           { opacity: 0.6; cursor: default; }
.housing-card-owned:hover     { border-color: #444; transform: none; }
.housing-card-icon            { font-size: 2.4em; min-width: 44px; text-align: center; }
.housing-card-info            { flex: 1; }
.housing-card-info strong     { font-size: 1.1em; }
.housing-card-size            { margin-left: 8px; font-size: 0.8em; color: #888; }
.housing-card-desc            { margin: 4px 0; color: #bbb; font-size: 0.88em; }
.housing-card-slots           { font-size: 0.82em; color: #aaa; margin-top: 4px; }
.housing-card-price           { font-size: 0.9em; color: #ffd700; font-weight: bold; margin-top: 2px; }
.housing-card-flavor          { font-size: 0.78em; color: #777; display: block; margin-top: 4px; }
.housing-owned-badge          { display: inline-block; background: #2a4d2a; color: #8bc34a; border-radius: 4px; padding: 2px 8px; font-size: 0.8em; margin-top: 6px; }

/* House stats row */
.housing-stats-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85em;
  color: #aaa;
  margin-bottom: 12px;
  background: #1a1a1a;
  border-radius: 6px;
  padding: 8px 12px;
}

/* Sections */
.housing-section { margin-bottom: 16px; }

/* Bed section */
.housing-bed-section {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid #354468;
  border-radius: 8px;
  padding: 12px 16px;
}

/* Furniture list in my-house view */
.housing-furniture-list { display: flex; flex-direction: column; gap: 8px; }
.housing-furniture-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1c1c1c;
  border-radius: 6px;
  padding: 8px 10px;
  flex-wrap: wrap;
}
.housing-furniture-row > span:last-of-type { flex: 1; font-size: 0.83em; color: #888; }

/* Small buttons */
.housing-btn-small {
  padding: 4px 10px;
  font-size: 0.8em;
  border-radius: 4px;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #ccc;
  cursor: pointer;
  transition: background 0.15s;
}
.housing-btn-small:hover   { background: #3a3a3a; }
.housing-btn-remove        { border-color: #8b3a3a; color: #ffaaaa; }
.housing-btn-remove:hover  { background: #3a2020; }

/* Trophies */
.housing-trophy-list { display: flex; flex-wrap: wrap; gap: 6px; }
.housing-trophy {
  background: #2a2a1a;
  border: 1px solid #665533;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.82em;
  color: #ffd700;
}

/* Browse homes list */
.housing-browse-list { display: flex; flex-direction: column; gap: 10px; }
.housing-browse-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px 14px;
}
.housing-browse-icon { font-size: 2em; min-width: 36px; text-align: center; }
.housing-browse-info { flex: 1; }

/* Visit screen */
.housing-visit-items { display: flex; flex-wrap: wrap; gap: 8px; }
.housing-visit-item {
  background: #1c1c1c;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.88em;
}
.housing-visit-bonus {
  background: #1a2a1a;
  border-left: 3px solid #4caf50;
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 0.88em;
  color: #c8e6c9;
}

/* Rested badge (inline in party/character views) */
.housing-rested-badge {
  display: inline-block;
  background: #1a2e4d;
  border: 1px solid #2196f3;
  color: #90caf9;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.78em;
  font-weight: bold;
}

@media (max-width: 600px) {
  .housing-card { flex-direction: column; }
  .housing-card-icon { font-size: 1.8em; min-width: unset; }
  .housing-stats-row { flex-direction: column; gap: 6px; }
  .housing-browse-row { flex-direction: column; align-items: flex-start; }
}

/* ============================================================================
   MOBILE REVAMP: Dungeon Crawl + Combat - iOS App Experience
   Targets phones (<=768px). Desktop layout is unchanged.
   ============================================================================ */

/* -----------------------------------------------------------------------
   DUNGEON: Full-screen tactical grid on mobile
   ----------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Hide legacy first-person preview + keyboard nav buttons */
  .controls {
    display: none !important;
  }

  /* Hide the always-visible minimap panel â€” map is now behind a FAB */
  .minimap-container {
    display: none !important;
  }

  /* Scene canvas fills the game view width */
  .view-and-map {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    flex: 1;
  }

  .scene-container.tactical-grid-view {
    display: flex !important;
    width: 100%;
    flex: 1;
    min-height: 200px;
    align-items: stretch;
  }

  #scene-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    min-height: 200px;
    max-height: 58vh;
    cursor: pointer;
    aspect-ratio: 1;
  }

  /* Message log â€” compact floating strip in dungeon */
  .message-log {
    position: fixed;
    top: 4px;
    left: 4px;
    right: 4px;
    max-height: 72px;
    z-index: 500;
  }
}

/* -----------------------------------------------------------------------
   DUNGEON MAP FAB (floating action button â€” bottom-right of game screen)
   ----------------------------------------------------------------------- */
#dungeon-map-fab {
  display: none;
  position: fixed;
  bottom: 72px;   /* sits above the mobile-nav-bar */
  right: 14px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3d2463, #5a3a8a);
  color: #f4e4c1;
  border: 2px solid #8a67ff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6), 0 0 12px rgba(138,103,255,0.4);
  z-index: 450;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}

#dungeon-map-fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.dungeon-map-fab-visible #dungeon-map-fab {
  display: flex;
}

/* -----------------------------------------------------------------------
   DUNGEON MAP MODAL (full-screen map view with zoom/pan)
   ----------------------------------------------------------------------- */
#dungeon-map-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 15, 0.97);
  z-index: 800;
  flex-direction: column;
  align-items: stretch;
}

#dungeon-map-modal.open {
  display: flex;
}

.dungeon-map-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1a0a2e, #2d1654);
  border-bottom: 2px solid #8a67ff;
  flex-shrink: 0;
}

.dungeon-map-modal-header h3 {
  color: #f4e4c1;
  font-size: 1.1em;
  margin: 0;
  font-family: inherit;
}

.dungeon-map-modal-close {
  width: 36px;
  height: 36px;
  background: rgba(138,103,255,0.2);
  border: 1px solid #8a67ff;
  border-radius: 6px;
  color: #f4e4c1;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.dungeon-map-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 12px;
}

#map-modal-canvas-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#map-modal-canvas {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  transform-origin: center center;
  border: 2px solid #8a67ff;
  border-radius: 4px;
  box-shadow: 0 0 24px rgba(138,103,255,0.4);
}

.dungeon-map-modal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 4px 4px;
  justify-content: center;
  flex-shrink: 0;
}

.dungeon-map-modal-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #aaa;
  font-size: 0.75em;
}

.dungeon-map-modal-hint {
  color: #666;
  font-size: 0.7em;
  text-align: center;
  padding: 4px;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------
   MOBILE COMBAT REVAMP â€” Focus on enemies + active character actions
   ----------------------------------------------------------------------- */
@media (max-width: 768px) {

  /* === Enemy battlefield: taller, more dramatic === */
  .enemy-battlefield {
    min-height: 220px !important;
    max-height: 300px !important;
    padding: 10px 8px 28px !important; /* extra bottom padding for HP bars */
    background: linear-gradient(180deg, rgba(10,3,25,0.98) 0%, rgba(20,5,40,0.95) 100%) !important;
    border-radius: 12px 12px 0 0;
    overflow: visible !important;  /* allow HP/CT bars at bottom:-10px to show */
    position: relative;
  }

  /* Enemy lines container â€” remove excessive top margin */
  .enemy-lines-container {
    margin-top: 16px !important;
    gap: 10px !important;
  }

  /* Enemy lines â€” full width, less crowded */
  .enemy-line {
    width: 90% !important;
    min-height: 70px !important;
    gap: 10px !important;
    padding: 8px 8px 16px !important; /* bottom padding for HP bars */
    overflow: visible !important;
  }

  /* Enemy sprites â€” scaled for mobile */
  .enemy-sprite-container {
    width: 80px !important;
    height: 80px !important;
    padding-bottom: 0 !important;
    overflow: visible !important; /* allow absolutely-positioned HP bar to show */
  }

  .enemy-sprite {
    width: 80px !important;
    height: 80px !important;
    image-rendering: pixelated;
  }

  .enemy-portrait-wrapper {
    width: 70px !important;
    height: 76px !important;
    overflow: visible !important;
  }

  .enemy-portrait {
    width: 70px !important;
    height: 70px !important;
    font-size: 0.85em !important;
  }

  .enemy-name {
    font-size: 0.7em !important;
    max-width: 80px !important;
  }

  /* HP bar â€” reposition to below sprite so it's never clipped */
  .enemy-hp-bar {
    bottom: -14px !important;
    height: 5px !important;
  }

  .enemy-hp-bar-container {
    width: 70px !important;
    height: 5px !important;
  }

  /* CT bar â€” below HP bar */
  .enemy-ct-bar-container {
    bottom: -22px !important;
  }

  /* === Combat header: minimal === */
  .combat-header {
    padding: 4px 10px !important;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .combat-header h2 {
    font-size: 1.1em !important;
  }

  /* CT timeline â€” strip to tiny, always at very top */
  .combat-timeline-display {
    max-height: 48px !important;
    padding: 3px 5px !important;
    font-size: 0.68em !important;
  }

  .timeline-action {
    min-width: 36px !important;
    padding: 1px !important;
    font-size: 0.6em !important;
  }

  /* Action phase title â€” small */
  .action-phase-title {
    font-size: 0.7em !important;
    padding: 2px 8px !important;
    top: 22px !important;
  }

  /* Enemy lines â€” more breathing room, HP bars visible */
  .enemy-lines-container {
    margin-top: 16px !important;
    gap: 10px !important;
  }

  .enemy-line {
    min-height: 80px !important;
    gap: 10px !important;
    padding: 8px 8px 20px !important; /* extra bottom for HP + CT bars */
    overflow: visible !important;
    width: 90% !important;
  }

  /* Character portraits in battle are hidden (shown in action panel below) */
  .character-lines-container {
    display: none !important;
  }

  /* === Mobile character action panel â€” full-width, clean === */
  .mobile-combat-character-container {
    background: linear-gradient(180deg, rgba(10,5,25,0.98), rgba(20,10,40,0.98)) !important;
    border-top: 2px solid #8a67ff !important;
    padding: 8px 10px !important;
    border-radius: 0 0 8px 8px;
  }

  /* Character nav arrows â€” clean pill style */
  .mobile-character-nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 4px 8px !important;
    margin-bottom: 6px !important;
    gap: 10px !important;
  }

  .mobile-char-nav-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(138,103,255,0.2) !important;
    border: 1px solid #8a67ff !important;
    color: #f4e4c1 !important;
    font-size: 1.1em !important;
    touch-action: manipulation !important;
  }

  .mobile-char-indicator {
    color: #daa520 !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em !important;
  }

  /* === Action buttons â€” big, physical, thumb-friendly === */
  .combat-actions-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    padding: 0 !important;
    margin-top: 4px !important;
  }

  /* All direct button children of combat-actions-buttons */
  .combat-actions-buttons > button,
  .combat-actions-buttons > div > button {
    min-height: 62px !important;
    font-size: 0.95em !important;
    font-weight: 700 !important;
    font-family: 'Cinzel', serif !important;
    border-radius: 4px !important;
    letter-spacing: 0.08em !important;
    padding: 8px 6px !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8) !important;
  }

  /* Override row divs inside buttons area */
  .combat-actions-buttons > div {
    display: contents !important;
  }

  /* Attack button â€” scarlet, physical feel */
  [id^="attack-btn-"] {
    background: linear-gradient(180deg, #7a2020 0%, #4a1010 60%, #2a0808 100%) !important;
    border: 1px solid #aa3333 !important;
    border-top: 1px solid #cc4444 !important;
    border-bottom: 3px solid #180404 !important;
    color: #ffd0d0 !important;
    box-shadow: inset 0 1px 0 rgba(255,100,100,0.2), 0 3px 8px rgba(0,0,0,0.6) !important;
  }

  [id^="attack-btn-"]:not(:disabled):active {
    transform: translateY(2px) !important;
    border-bottom-width: 1px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5) !important;
  }

  /* Defend button â€” sapphire blue */
  [id^="defend-btn-"] {
    background: linear-gradient(180deg, #1a2e6e 0%, #0e1e4a 60%, #060e2a 100%) !important;
    border: 1px solid #3355bb !important;
    border-top: 1px solid #4466dd !important;
    border-bottom: 3px solid #020710 !important;
    color: #c0d8ff !important;
    box-shadow: inset 0 1px 0 rgba(80,130,255,0.2), 0 3px 8px rgba(0,0,0,0.6) !important;
  }

  [id^="defend-btn-"]:not(:disabled):active {
    transform: translateY(2px) !important;
    border-bottom-width: 1px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5) !important;
  }

  /* Spell / Ability buttons â€” arcane purple */
  .combat-actions-buttons > button:not([id^="attack-btn-"]):not([id^="defend-btn-"]) {
    background: linear-gradient(180deg, #4a1e82 0%, #2e1054 60%, #180830 100%) !important;
    border: 1px solid #7a4acc !important;
    border-top: 1px solid #9a6aec !important;
    border-bottom: 3px solid #0a0418 !important;
    color: #e8d8ff !important;
    box-shadow: inset 0 1px 0 rgba(150,100,255,0.2), 0 3px 8px rgba(0,0,0,0.6) !important;
  }

  .combat-actions-buttons > button:not([id^="attack-btn-"]):not([id^="defend-btn-"]):not(:disabled):active {
    transform: translateY(2px) !important;
    border-bottom-width: 1px !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5) !important;
  }

  /* Auto-indicator badge */
  .auto-indicator {
    font-size: 0.55em !important;
    padding: 1px 4px !important;
    top: 2px !important;
    right: 2px !important;
    border-radius: 4px !important;
  }

  /* === Global combat action bar (auto-submit, flee, rest etc.) â€” compact === */
  .combat-global-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px 8px 8px !important;
    border-top: 1px solid rgba(138,103,255,0.2) !important;
    margin-top: 10px !important;
  }

  .combat-global-actions .bulk-action-btn {
    flex: 1 1 calc(50% - 4px) !important;
    min-height: 48px !important;
    font-size: 0.8em !important;
    padding: 10px 12px !important;
    white-space: nowrap !important;
    border-radius: 10px !important;
  }

  #submit-turn-button {
    width: 100% !important;
    min-height: 54px !important;
    font-size: 1em !important;
    font-weight: 700 !important;
    margin-top: 8px !important;
    background: linear-gradient(135deg, #2d6a1e, #3d8a2a) !important;
    border: 2px solid #5caa3c !important;
    border-radius: 10px !important;
    letter-spacing: 0.04em !important;
  }

  /* Combat log â€” collapsed toggle button */
  #combat-log-toggle {
    width: 100% !important;
    text-align: left !important;
    padding: 12px 16px !important;
    font-size: 0.85em !important;
    margin-top: 16px !important;
    border-radius: 10px !important;
    background: rgba(138,103,255,0.12) !important;
    border: 1px solid rgba(138,103,255,0.3) !important;
    color: #ccc !important;
    touch-action: manipulation !important;
    letter-spacing: 0.03em !important;
  }

  /* Hide scene info overlay during combat */
  .combat-modal.active + .game-container .scene-info,
  body.in-combat .scene-info {
    display: none !important;
  }
}

/* -----------------------------------------------------------------------
   TILE TAP HINT OVERLAY (appears on first dungeon entry on mobile)
   ----------------------------------------------------------------------- */
.tile-tap-hint-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  z-index: 600;
  pointer-events: all;
}

.tile-tap-hint-overlay .hint-card {
  background: linear-gradient(135deg, #1a0a2e, #2d1654);
  border: 2px solid #8a67ff;
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 300px;
  text-align: center;
  color: #f4e4c1;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}

.tile-tap-hint-overlay .hint-card h3 {
  font-size: 1.2em;
  margin-bottom: 12px;
  color: #daa520;
}

.tile-tap-hint-overlay .hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 0.9em;
}

.tile-tap-hint-overlay .hint-icon {
  font-size: 1.4em;
  width: 30px;
  text-align: center;
}

.tile-tap-hint-overlay .hint-dismiss-btn {
  margin-top: 18px;
  padding: 10px 24px;
  background: linear-gradient(135deg, #3d2463, #5a3a8a);
  border: 2px solid #8a67ff;
  border-radius: 8px;
  color: #f4e4c1;
  font-size: 0.9em;
  cursor: pointer;
  touch-action: manipulation;
}

/* Pulse animation for tap targets on dungeon canvas overlay */
@keyframes dungeon-tap-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Walk indicators drawn on a canvas overlay inside scene-container */
#dungeon-walk-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* =============================================================================
   MOBILE COMBAT REDESIGN â€” immersive single-character focus
   Applied when viewport <= 768px (portrait phone)
   ============================================================================= */
@media (max-width: 768px) {

  /* â”€â”€ Combat modal: full-screen immersive overlay â”€â”€â”€ */
  .combat-modal.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .combat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    gap: 0;
    overflow: hidden;
  }

  /* Header bar â€” very slim */
  .combat-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    background: rgba(10,5,20,0.97);
    border-bottom: 1px solid rgba(138,103,255,0.4);
    min-height: 36px;
  }
  .combat-header h2 { font-size: 1em; margin: 0; }
  .turn-indicator { font-size: 0.75em; color: #8a67ff; }

  /* Three-column layout becomes single full-height column */
  .combat-three-column-layout {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 0;
    padding: 0;
  }

  /* Hide side columns entirely â€” all content is in center column */
  .combat-left-column,
  .combat-right-column {
    display: none !important;
  }

  .combat-center-column {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
  }

  /* â”€â”€ Enemy section â€” hero zone â”€â”€â”€ */
  .enemy-battlefield {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    height: auto;
    min-height: 160px;
    background: linear-gradient(180deg, #0a0515 0%, #140a28 60%, #1a0a2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0;
    overflow: visible;
    border-bottom: 2px solid rgba(138,103,255,0.3);
    padding-bottom: 8px;
  }

  /* Action phase title â€” slim, top of battlefield */
  .action-phase-title {
    font-size: 0.75em;
    padding: 2px 8px;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    white-space: nowrap;
  }

  /* Character formation â€” hide from battlefield */
  .character-lines-container { display: none !important; }

  /* Enemy lines â€” centered, large */
  .enemy-lines-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 8px 4px;
  }
  .enemy-line {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 0;
    background: transparent;
    padding: 0;
  }
  .enemy-line::before { display: none; }

  /* Enemy sprites â€” larger and more imposing */
  .enemy-portrait-wrapper {
    width: 88px;
    height: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .enemy-portrait {
    width: 88px;
    height: 88px;
    font-size: 0.85em;
    flex-shrink: 0;
  }
  .enemy-sprite {
    width: 88px;
    height: 88px;
    image-rendering: pixelated;
    flex-shrink: 0;
  }
  .enemy-name {
    font-size: 0.65em;
    max-width: 88px;
    text-align: center;
    white-space: normal;
    line-height: 1.1;
    color: #f4e4c1;
    margin-top: 2px;
  }
  /* Enemy HP bars â€” always visible, taller for readability */
  .enemy-sprite-container,
  .enemy-portrait-wrapper {
    overflow: visible !important;
    position: relative;
  }

  .enemy-hp-bar {
    position: static !important;
    transform: none !important;
    left: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: 8px !important;
    margin-top: 3px !important;
    border-radius: 3px !important;
    display: block !important;
  }

  .enemy-hp-bar-container {
    width: 96px;
    height: 8px;
    margin-top: 3px;
    display: block !important;
  }

  /* â”€â”€ Bottom section â€” action zone, scrollable if needed â”€â”€â”€ */
  .combat-bottom-section {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px 8px 80px; /* bottom pad for FAB/nav bar clearance */
    background: rgba(10, 5, 20, 0.97);
    border-top: 2px solid rgba(138,103,255,0.4);
  }

  /* --- Mobile combat character focus card --- */
  .mobile-combat-character-container {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0 0 6px;
  }

  /* Active character focus area */
  #mobile-character-display .character-combat-card {
    background: linear-gradient(135deg, rgba(61,36,99,0.5), rgba(20,10,35,0.8));
    border: 2px solid #8a67ff;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
  }

  /* Portrait + name row inside the card */
  #mobile-character-display .character-card-portrait {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  #mobile-character-display .char-portrait {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 2px solid #8a67ff;
    flex-shrink: 0;
  }

  #mobile-character-display .character-card-info {
    flex: 1;
  }

  #mobile-character-display .character-card-name {
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 4px;
  }

  /* Resource bars â€” compact */
  #mobile-character-display .resource-bar-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 3px;
  }
  #mobile-character-display .resource-bar {
    flex: 1;
    height: 10px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255,255,255,0.1);
    position: relative;
  }
  #mobile-character-display .resource-label {
    font-size: 0.65em;
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
  }
  #mobile-character-display .resource-icon {
    font-size: 0.8em;
    width: 16px;
    text-align: center;
  }

  /* Action buttons â€” big tappable grid */
  #mobile-character-display .combat-actions-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
  }

  #mobile-character-display .action-btn {
    min-height: 56px;
    font-size: 0.9em;
    font-weight: 600;
    padding: 10px 6px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    border: 2px solid rgba(138,103,255,0.5);
    background: linear-gradient(135deg, rgba(61,36,99,0.6), rgba(90,58,138,0.4));
    color: #f4e4c1;
    transition: background 0.15s, transform 0.1s;
    cursor: pointer;
  }
  #mobile-character-display .action-btn:active {
    transform: scale(0.96);
    background: rgba(138,103,255,0.4);
  }
  #mobile-character-display .action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  /* Character nav (â—€ 1/6 â–¶) */
  .mobile-character-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 4px 8px;
    margin-bottom: 6px;
  }
  .mobile-char-nav-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 1.1em;
  }
  .mobile-char-indicator {
    font-size: 0.85em;
    color: #aaa;
  }

  /* â”€â”€ Combat global actions â€” slimmer, hidden-by-default menu â”€â”€â”€ */
  .combat-global-actions {
    display: none; /* hidden by default; revealed via mobile combat overflow menu */
  }
  .combat-global-actions.mobile-visible {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: rgba(20,10,35,0.9);
    border: 1px solid rgba(138,103,255,0.3);
    border-radius: 8px;
    margin-top: 4px;
  }
  .bulk-action-btn {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
    font-size: 0.85em;
  }
  #submit-turn-button {
    width: 100%;
    min-height: 48px;
    font-size: 1em;
    font-weight: bold;
    display: block;
    margin-top: 4px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2d5a1b, #3d8a27);
    border: 2px solid #5aaa35;
    color: #d4ffb8;
    touch-action: manipulation;
  }

  /* â”€â”€ Mobile combat overflow FAB (â‹®) â”€â”€â”€ */
  #mobile-combat-menu-btn {
    position: fixed;
    top: 40px;
    right: 12px;
    z-index: 3100;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(61,36,99,0.95);
    border: 2px solid #8a67ff;
    color: #f4e4c1;
    font-size: 1.4em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 2px 12px rgba(0,0,0,0.6);
  }

  /* Combat overflow drawer */
  #mobile-combat-overflow-drawer {
    position: fixed;
    top: 86px;
    right: 8px;
    z-index: 3200;
    min-width: 200px;
    background: rgba(15,7,30,0.98);
    border: 2px solid #8a67ff;
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.8);
  }
  #mobile-combat-overflow-drawer.open {
    display: flex;
  }
  #mobile-combat-overflow-drawer button {
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    background: rgba(61,36,99,0.4);
    border: 1px solid rgba(138,103,255,0.3);
    border-radius: 8px;
    color: #f4e4c1;
    font-size: 0.9em;
    font-family: inherit;
    cursor: pointer;
    touch-action: manipulation;
  }
  #mobile-combat-overflow-drawer button:active {
    background: rgba(138,103,255,0.3);
  }

  /* Combat log â€” hide until toggled */
  .combat-log-section {
    display: none !important;
  }
  .combat-log-section.mobile-visible {
    display: block !important;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(10,5,20,0.8);
    border: 1px solid rgba(138,103,255,0.3);
    border-radius: 8px;
    margin-top: 4px;
  }
}

/* =============================================================================
   MOBILE DUNGEON REDESIGN â€” sprite as hero, no minimap, map FAB
   ============================================================================= */
@media (max-width: 768px) {

  /* Hide the minimap panel; use Map FAB instead */
  #minimap-container {
    display: none !important;
  }

  /* Hide old first-person preview + nav buttons (use nav bar and swipe instead) */
  .controls {
    display: none !important;
  }

  /* Make the tactical grid canvas fill the available space */
  .view-and-map {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .scene-container {
    flex: 1 1 auto;
    position: relative;
  }

  /* Ensure tactical grid view is also flex and fills space */
  .scene-container.tactical-grid-view {
    display: flex !important;
    flex: 1 1 auto;
  }

  #scene-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    display: block;
  }

  /* Scene info â€” smalloverlaid chip at bottom-left of canvas */
  .scene-info {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(10,5,20,0.7);
    border: 1px solid rgba(138,103,255,0.3);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.7em;
    color: #aaa;
    pointer-events: none;
    z-index: 5;
  }
}

/* =============================================================================
   TAP-TO-WALK INTRO HINT â€” shown first dungeon entry on mobile
   ============================================================================= */
#dungeon-tap-walk-hint {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 100px;
  background: rgba(0,0,0,0.6);
  pointer-events: all;
  animation: fadeInHint 0.3s ease;
}
@keyframes fadeInHint {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#dungeon-tap-walk-hint.fading {
  animation: fadeOutHint 0.35s ease forwards;
}
@keyframes fadeOutHint {
  to { opacity: 0; }
}
#dungeon-tap-walk-hint .hint-bubble {
  background: linear-gradient(135deg, #1a0a2e, #2d1654);
  border: 2px solid #8a67ff;
  border-radius: 16px;
  padding: 20px 22px;
  max-width: 290px;
  width: 90%;
  text-align: center;
  color: #f4e4c1;
  box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}
#dungeon-tap-walk-hint h3 {
  font-size: 1.05em;
  margin: 0 0 12px;
  color: #daa520;
}
#dungeon-tap-walk-hint .hint-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  text-align: left;
}
#dungeon-tap-walk-hint .hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88em;
}
#dungeon-tap-walk-hint .hint-icon {
  font-size: 1.3em;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
#dungeon-tap-walk-hint .hint-ok-btn {
  padding: 10px 28px;
  background: linear-gradient(135deg, #3d2463, #5a3a8a);
  border: 2px solid #8a67ff;
  border-radius: 8px;
  color: #f4e4c1;
  font-size: 0.9em;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   MOBILE COMBAT REDESIGN â€” Game-quality battle UI
   Inspired by Final Fantasy Tactics / Wizardry visual language
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
@media (max-width: 768px) {

  /* â”€â”€ Portrait strip: all party members, tap to switch â”€â”€ */
  .mobile-party-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 6px;
    background: linear-gradient(180deg, rgba(4,1,12,1) 0%, rgba(10,5,24,0.97) 100%);
    border-bottom: 1px solid rgba(138,103,255,0.2);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .mobile-party-strip::-webkit-scrollbar { display: none; }

  .mobile-party-portrait-wrap {
    position: relative;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    border-radius: 8px;
  }
  .mobile-party-portrait-wrap img {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    border: 2px solid rgba(138,103,255,0.35);
    object-fit: cover;
    display: block;
    transition: border-color 0.2s, box-shadow 0.2s, filter 0.2s;
  }
  .mobile-party-portrait-wrap.is-selected img {
    border-color: #daa520;
    box-shadow: 0 0 8px rgba(218,165,32,0.65);
  }
  .mobile-party-portrait-wrap.active-turn img {
    border-color: #f0c040;
    box-shadow: 0 0 14px rgba(240,192,64,1), 0 0 5px rgba(240,192,64,0.8);
    animation: mobilePortraitPulse 1.3s ease-in-out infinite;
  }
  .mobile-party-portrait-wrap.is-dead img {
    filter: grayscale(1) brightness(0.4);
    border-color: rgba(160,0,0,0.4);
  }
  .mobile-party-portrait-wrap.action-done img {
    filter: brightness(0.65);
    border-color: #4caf50;
  }
  @keyframes mobilePortraitPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(240,192,64,0.75); }
    50%       { box-shadow: 0 0 20px rgba(240,192,64,1), 0 0 8px rgba(255,224,100,0.9); }
  }

  .mobile-portrait-hp-bar {
    position: absolute;
    bottom: 0;
    left: 2px;
    right: 2px;
    height: 3px;
    background: rgba(0,0,0,0.65);
    border-radius: 0 0 4px 4px;
    overflow: hidden;
  }
  .mobile-portrait-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #e53935 0%, #f57c00 45%, #66bb6a 80%);
    transition: width 0.4s ease;
  }

  /* Red damage overlay â€” grows upward from bottom as HP is lost */
  .mobile-portrait-health-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 0, 0, 0.28);
    transition: height 0.35s ease;
    border-radius: 0 0 6px 6px;
    pointer-events: none;
    z-index: 1;
  }

  /* â”€â”€ Character spotlight: portrait + stats side-by-side â”€â”€ */
  .mobile-char-spotlight {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px 8px;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(8,4,18,0) 0%, rgba(12,6,24,0.6) 100%);
  }

  .mobile-char-portrait-frame {
    position: relative;
    flex-shrink: 0;
    width: 76px;
    height: 76px;
    border-radius: 10px;
    overflow: hidden;
  }
  .mobile-char-portrait-lg {
    width: 76px;
    height: 76px;
    border-radius: 8px;
    border: 2px solid rgba(138,103,255,0.5);
    object-fit: cover;
    display: block;
    transition: border-color 0.3s, box-shadow 0.3s;
  }
  .mobile-char-portrait-frame.active-turn .mobile-char-portrait-lg {
    border-color: #f0c040;
    box-shadow: 0 0 16px rgba(240,192,64,0.8);
  }
  .mobile-char-portrait-frame.dead .mobile-char-portrait-lg {
    filter: grayscale(1) brightness(0.38);
    border-color: rgba(180,0,0,0.5);
  }
  .mobile-char-hp-vignette {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: radial-gradient(ellipse at bottom, rgba(200,0,0,0.75) 0%, transparent 65%);
    pointer-events: none;
  }

  .mobile-char-stats {
    flex: 1;
    min-width: 0;
  }
  .mobile-char-name {
    font-family: 'Cinzel', serif;
    font-size: 1.08em;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 0 12px currentColor;
  }
  .mobile-defeated-label {
    font-family: 'Cinzel', serif;
    color: #e53935;
    font-size: 0.82em;
    font-weight: 700;
    letter-spacing: 0.12em;
    margin-top: 6px;
  }

  /* Resource bars */
  .mobile-resource-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
  }
  .mobile-resource-row:last-child { margin-bottom: 0; }
  .mobile-res-icon {
    font-size: 0.82em;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
  }
  .mobile-res-bar {
    flex: 1;
    height: 13px;
    border-radius: 6px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    position: relative;
  }
  .mobile-res-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
    /* Default: HP â€” crimson red */
    background: linear-gradient(90deg, #b71c1c 0%, #e53935 55%, #ef9a9a 100%);
  }
  .mobile-res-fill.mp      { background: linear-gradient(90deg, #1a237e 0%, #1565c0 55%, #42a5f5 100%); }
  .mobile-res-fill.chakra  { background: linear-gradient(90deg, #1b5e20 0%, #388e3c 55%, #66bb6a 100%); }
  .mobile-res-fill.resolve { background: linear-gradient(90deg, #7b1fa2 0%, #ab47bc 55%, #ce93d8 100%); }
  .mobile-res-label {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6em;
    color: rgba(255,255,255,0.92);
    white-space: nowrap;
    font-weight: 600;
    pointer-events: none;
  }

  /* â”€â”€ Turn status banners â”€â”€ */
  .mobile-your-turn-banner {
    background: linear-gradient(90deg,
      rgba(218,165,32,0.08) 0%,
      rgba(240,192,64,0.22) 50%,
      rgba(218,165,32,0.08) 100%);
    border-top: 1px solid rgba(218,165,32,0.45);
    border-bottom: 1px solid rgba(218,165,32,0.45);
    padding: 5px 12px;
    font-family: 'Cinzel', serif;
    font-size: 0.72em;
    font-weight: 700;
    color: #f0c040;
    letter-spacing: 0.12em;
    text-align: center;
    flex-shrink: 0;
  }
  .mobile-waiting-banner {
    padding: 3px 12px;
    font-size: 0.68em;
    color: rgba(160,150,120,0.6);
    text-align: center;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    font-style: italic;
  }

  /* â”€â”€ Command button grid â€” heart of the mobile combat UI â”€â”€ */
  .mobile-cmd-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 10px 12px;
    flex-shrink: 0;
  }

  .mobile-cmd-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 64px;
    border-radius: 12px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Cinzel', serif;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #fff;
    overflow: hidden;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    /* Subtle inner highlight line at top */
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  .mobile-cmd-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
  }
  .mobile-cmd-btn:active:not(:disabled) {
    transform: scale(0.94);
  }
  .mobile-cmd-btn:disabled {
    filter: brightness(0.38) saturate(0.25);
    cursor: not-allowed;
  }

  .cmd-icon  { font-size: 1.5em; line-height: 1; }
  .cmd-label { line-height: 1.1; }

  /* ATTACK â€” Crimson aggression */
  .mobile-cmd-btn.cmd-attack {
    background: linear-gradient(160deg, #6b1515 0%, #b71c1c 45%, #c62828 100%);
    border: 2px solid #ef5350;
    box-shadow: 0 4px 14px rgba(183,28,28,0.55), inset 0 1px 0 rgba(255,255,255,0.12);
    color: #ffebee;
  }
  .mobile-cmd-btn.cmd-attack:active:not(:disabled) {
    box-shadow: 0 1px 5px rgba(183,28,28,0.4), inset 0 3px 6px rgba(0,0,0,0.35);
  }

  /* DEFEND â€” Sapphire protection */
  .mobile-cmd-btn.cmd-defend {
    background: linear-gradient(160deg, #0a2255 0%, #1565c0 45%, #1976d2 100%);
    border: 2px solid #42a5f5;
    box-shadow: 0 4px 14px rgba(21,101,192,0.55), inset 0 1px 0 rgba(255,255,255,0.12);
    color: #e3f2fd;
  }
  .mobile-cmd-btn.cmd-defend:active:not(:disabled) {
    box-shadow: 0 1px 5px rgba(21,101,192,0.4), inset 0 3px 6px rgba(0,0,0,0.35);
  }

  /* CAST SPELL â€” Deep arcane purple */
  .mobile-cmd-btn.cmd-spell {
    background: linear-gradient(160deg, #250845 0%, #6a1b9a 45%, #7b1fa2 100%);
    border: 2px solid #ab47bc;
    box-shadow: 0 4px 14px rgba(106,27,154,0.55), inset 0 1px 0 rgba(255,255,255,0.12);
    color: #f3e5f5;
  }
  .mobile-cmd-btn.cmd-spell:active:not(:disabled) {
    box-shadow: 0 1px 5px rgba(106,27,154,0.4), inset 0 3px 6px rgba(0,0,0,0.35);
  }

  /* USE ABILITY â€” Ember orange technique */
  .mobile-cmd-btn.cmd-ability {
    background: linear-gradient(160deg, #4c1a00 0%, #bf360c 45%, #d84315 100%);
    border: 2px solid #ff7043;
    box-shadow: 0 4px 14px rgba(191,54,12,0.55), inset 0 1px 0 rgba(255,255,255,0.12);
    color: #fbe9e7;
  }
  .mobile-cmd-btn.cmd-ability:active:not(:disabled) {
    box-shadow: 0 1px 5px rgba(191,54,12,0.4), inset 0 3px 6px rgba(0,0,0,0.35);
  }

  /* Generic fallback */
  .mobile-cmd-btn.cmd-generic {
    background: linear-gradient(160deg, #1e0f35 0%, #3d2463 45%, #5a3a8a 100%);
    border: 2px solid #8a67ff;
    box-shadow: 0 4px 14px rgba(61,36,99,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
  }

  /* AUTO badge on attack button */
  .cmd-auto-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.56em;
    font-family: system-ui, sans-serif;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(0,0,0,0.5);
    color: rgba(255,255,255,0.35);
    border: 1px solid rgba(255,255,255,0.12);
    cursor: pointer;
    touch-action: manipulation;
    transition: color 0.2s, background 0.2s;
  }
  .cmd-auto-badge.active {
    background: rgba(240,192,64,0.22);
    color: #f0c040;
    border-color: rgba(240,192,64,0.7);
  }

  /* Waiting state: dim entire grid */
  .mobile-cmd-grid.ct-waiting .mobile-cmd-btn {
    filter: brightness(0.45) saturate(0.3);
    cursor: not-allowed;
  }
  .mobile-cmd-grid.ct-waiting .mobile-cmd-btn:active { transform: none; }

  /* â”€â”€ Panel container â”€â”€ */
  .mobile-combat-panel {
    display: flex;
    flex-direction: column;
    background: rgba(6,3,14,0.99);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(138,103,255,0.3);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.6);
  }
  .mobile-combat-panel.active-turn {
    border-color: rgba(218,165,32,0.65);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.6), 0 0 20px rgba(218,165,32,0.18);
  }

  /* Hide the cloned desktop card if it ever ends up in display */
  #mobile-character-display .character-combat-card {
    display: none !important;
  }

  /* â”€â”€ Battlefield improvements â”€â”€ */
  /* Give the enemy battlefield more height on mobile so enemies look imposing */
  .combat-modal.active .enemy-battlefield {
    min-height: 140px !important;
    max-height: none !important;
  }

  /* Enemy sprite containers â€” scale up so they fill the space */
  .combat-modal.active .enemy-sprite-container {
    width: 90px !important;
    height: 90px !important;
  }
  .combat-modal.active .enemy-sprite-container img,
  .combat-modal.active .enemy-portrait {
    width: 88px !important;
    height: 88px !important;
    object-fit: cover;
  }

  /* Action phase title â€” subtle */
  .combat-modal.active .action-phase-title {
    font-size: 0.7em !important;
    padding: 2px 8px !important;
    top: 28px !important;
  }
}

/* ===== LOCATION BOARD PANEL ===== */
.location-board-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
}
.location-board-panel {
  background: linear-gradient(160deg, #1a1225 0%, #150e1e 100%);
  border: 1px solid #4a3560;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  width: min(520px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #2e1e45;
}
.board-header-title {
  font-size: 1.1em;
  font-weight: bold;
  color: #d8c8f8;
  letter-spacing: 0.03em;
}
.board-close-btn {
  background: none;
  border: none;
  color: #7060a0;
  font-size: 1.3em;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.board-close-btn:hover { color: #c8b8f8; background: rgba(255,255,255,0.06); }
.board-posts-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.board-empty {
  text-align: center;
  color: #5a4870;
  font-style: italic;
  font-size: 0.9em;
  padding: 28px 0;
}
.board-post-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 9px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}
.board-post-type-icon {
  font-size: 1.2em;
  flex-shrink: 0;
  width: 26px;
  text-align: center;
}
.board-post-body { flex: 1; min-width: 0; }
.board-post-who {
  font-size: 0.78em;
  color: #9080b8;
  margin-bottom: 3px;
}
.board-post-text {
  font-size: 0.92em;
  color: #d8c8f8;
  word-break: break-word;
}
.board-post-time {
  font-size: 0.72em;
  color: #5a4870;
  margin-top: 4px;
}
.board-post-delete-btn {
  background: none;
  border: none;
  color: #5a4870;
  font-size: 0.85em;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
  align-self: flex-start;
}
.board-post-delete-btn:hover { color: #e05050; }
.board-composer {
  border-top: 1px solid #2e1e45;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.board-composer-title {
  font-size: 0.82em;
  color: #8070a8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.board-type-select {
  background: #1e1230;
  border: 1px solid #4a3560;
  color: #d8c8f8;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 0.9em;
  width: 100%;
}
.board-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board-field-input {
  background: #1e1230;
  border: 1px solid #4a3560;
  color: #d8c8f8;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 0.88em;
  width: 100%;
  box-sizing: border-box;
}
.board-field-input::placeholder { color: #5a4870; }
.board-field-row { display: flex; gap: 6px; }
.board-field-row .board-field-input { flex: 1; }
.board-submit-btn {
  background: linear-gradient(135deg, #4a2a7a, #6a3aaa);
  border: 1px solid #7a4aba;
  color: #f0e8ff;
  border-radius: 5px;
  padding: 8px 0;
  font-size: 0.92em;
  cursor: pointer;
  font-weight: bold;
  letter-spacing: 0.03em;
  width: 100%;
}
.board-submit-btn:hover { background: linear-gradient(135deg, #5a3a8a, #7a4aba); }
.board-button {
  background: linear-gradient(135deg, #1c1c3a, #2a2a50);
  border: 1px solid #4a4a80;
  color: #b8c4f8;
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.9em;
}
.board-button:hover { background: linear-gradient(135deg, #2a2a50, #3a3a6a); border-color: #6a6ab8; }
.beacon-notification {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: linear-gradient(135deg, #1a1225, #2a1840);
  border: 1px solid #8a6aaa;
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  z-index: 1100;
  max-width: 300px;
  animation: beacon-slide-in 0.3s ease-out;
}
@keyframes beacon-slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.beacon-notification-title {
  font-size: 0.85em;
  color: #a090d0;
  margin-bottom: 6px;
}
.beacon-notification-text {
  font-size: 0.95em;
  color: #d8c8f8;
  margin-bottom: 10px;
}
.beacon-notification-actions { display: flex; gap: 8px; }
.beacon-accept-btn {
  background: linear-gradient(135deg, #2a6a2a, #3a9a3a);
  border: 1px solid #4aaa4a;
  color: #c8f8c8;
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.85em;
  flex: 1;
}
.beacon-accept-btn:hover { background: linear-gradient(135deg, #3a8a3a, #4aaa4a); }
.beacon-dismiss-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #8070a0;
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.85em;
  flex: 1;
}
.beacon-dismiss-btn:hover { color: #d8c8f8; }

/* ===== LOCATION BOARD ï¿½ correct class names (from module) ===== */
/* Overlay hidden by default; shown via .board-visible toggle */
.location-board-overlay { display: none; }
.location-board-overlay.board-visible { display: flex; }

.board-title { font-size: 1.05em; font-weight: bold; color: #d8c8f8; }

.board-actions {
  display: flex; gap: 8px;
  padding: 8px 14px 0;
}
.board-post-btn, .board-beacon-btn {
  background: rgba(138,103,255,0.15);
  border: 1px solid rgba(138,103,255,0.4);
  color: #c8b8f8;
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.88em;
}
.board-post-btn:hover, .board-beacon-btn:hover {
  background: rgba(138,103,255,0.28);
}

.board-post-form {
  padding: 10px 14px 0;
}
.board-form-hidden { display: none !important; }
.board-form-inner {
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.07);
}
.board-form-title {
  margin: 0 0 10px;
  font-size: 0.95em;
  font-weight: bold;
  color: #d8c8f8;
}
.board-form-hint {
  margin: 0 0 10px;
  font-size: 0.82em;
  color: #8070a8;
}
.board-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.board-form-field label {
  font-size: 0.78em;
  color: #8070a8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.board-form-field input,
.board-form-field select {
  background: #1e1230;
  border: 1px solid #4a3560;
  color: #d8c8f8;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 0.88em;
  width: 100%;
  box-sizing: border-box;
}
.board-form-field input::placeholder { color: #5a4870; }
.board-form-btns {
  display: flex; gap: 8px; margin-top: 6px;
}
.board-cancel-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #7060a0;
  border-radius: 5px;
  padding: 7px 0;
  font-size: 0.88em;
  cursor: pointer;
  flex: 1;
}
.board-cancel-btn:hover { color: #d8c8f8; }
.board-submit-btn { flex: 1; }

/* Post cards */
.board-post-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.board-post-type {
  font-size: 0.85em;
  font-weight: bold;
  color: #a090d0;
}
.board-post-summary {
  font-size: 0.92em;
  color: #d8c8f8;
  word-break: break-word;
  margin-bottom: 5px;
}
.board-post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.board-post-author {
  font-size: 0.75em;
  color: #6a5a90;
}
.board-remove-btn {
  background: none;
  border: none;
  color: #5a4870;
  font-size: 0.78em;
  cursor: pointer;
  padding: 0 4px;
}
.board-remove-btn:hover { color: #e05050; }

/* Party Beacon popup */
.party-beacon-popup {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: linear-gradient(135deg, #1a1225, #2a1840);
  border: 1px solid #8a6aaa;
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  z-index: 1100;
  max-width: 300px;
  animation: beacon-slide-in 0.3s ease-out;
}
.beacon-icon { font-size: 1.4em; margin-bottom: 6px; }
.beacon-text { font-size: 0.92em; color: #d8c8f8; margin-bottom: 10px; line-height: 1.4; }
.beacon-actions { display: flex; gap: 8px; }
.beacon-btn {
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.85em;
  border: none;
  flex: 1;
}
.beacon-dismiss {
  background: rgba(255,255,255,0.08);
  color: #8070a0;
}
.beacon-dismiss:hover { color: #d8c8f8; }

/* ===== WEAPON CHOICE SCREEN ===== */
.first-weapon-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 900px;
}

.first-weapon-card {
  background: linear-gradient(160deg, rgba(25,12,48,0.98), rgba(40,20,70,0.92));
  border: 2px solid rgba(138,103,255,0.4);
  border-radius: 14px;
  padding: 22px 18px;
  width: 200px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.first-weapon-card:hover {
  transform: translateY(-6px) scale(1.03);
  border-color: #daa520;
  box-shadow: 0 8px 40px rgba(218,165,32,0.5), 0 0 20px rgba(138,103,255,0.4);
}

.weapon-card-sprite {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 8px rgba(138,103,255,0.5));
}

.weapon-card-name {
  font-size: 1.05em;
  font-weight: bold;
  color: #f4e4c1;
  text-align: center;
}

.weapon-card-damage {
  font-size: 0.82em;
  color: #c8b8e0;
  text-align: center;
}

.weapon-card-flavour {
  font-size: 0.78em;
  color: #8070a8;
  font-style: italic;
  text-align: center;
  line-height: 1.4;
  flex: 1;
}

.weapon-enchant-banner {
  background: linear-gradient(135deg, rgba(90,50,160,0.8), rgba(40,20,80,0.9));
  border: 1px solid rgba(218,165,32,0.4);
  border-radius: 10px;
  padding: 12px 20px;
  text-align: center;
  margin-bottom: 8px;
  max-width: 600px;
  width: 100%;
}
.weapon-enchant-label {
  font-size: 0.75em;
  color: #9a87c0;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 4px;
}
.weapon-enchant-name {
  font-size: 1em;
  font-weight: bold;
  color: #daa520;
  margin-bottom: 2px;
}
.weapon-enchant-desc {
  font-size: 0.8em;
  color: #b0a0d0;
  font-style: italic;
}

@media (max-width: 520px) {
  .first-weapon-cards { gap: 12px; }
  .first-weapon-card  { width: 100%; max-width: 340px; flex-direction: row; padding: 14px; }
  .weapon-card-sprite { width: 56px; height: 56px; }
}

/* ===== WEAPON SWING & PROJECTILE ANIMATIONS ===== */
.weapon-swing-sprite {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  image-rendering: pixelated;
  object-fit: contain;
  /* animation driven by JS requestAnimationFrame */
}

.arrow-projectile {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  font-family: monospace;
  font-weight: bold;
  color: #c8b860;
  text-shadow: 0 0 6px rgba(200,184,96,0.7);
  line-height: 1;
  /* animation driven by JS requestAnimationFrame */
}
