/* ============================================================
   SailorAgent — Mobile Game UI
   All styles scoped to max-width:768px.
   Transforms the PWA into an immersive nautical game experience.
   ============================================================ */

/* ── Mobile Header Bar ── */
@media (max-width: 768px) {

  /* ── MOBILE TOP HEADER ── */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: #110905;
    background-image:
      linear-gradient(to right, rgba(0,0,0,0.7) 0%, transparent 50%, rgba(0,0,0,0.7) 100%),
      repeating-linear-gradient(90deg, #1f1109 0px, #1a0e07 2px, #26160c 8px, #130a05 12px);
    border-bottom: 2px solid #3a2212;
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    z-index: 50;
    position: sticky;
    top: 0;
    min-height: 52px;
  }

  .mobile-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--rank-primary, #d4b96a);
    object-fit: cover;
    box-shadow: 0 0 8px var(--rank-glow, rgba(212, 185, 106, 0.3));
    flex-shrink: 0;
  }

  .mobile-header-profile {
    position: relative;
    flex-shrink: 0;
  }

  .mobile-rank-icon-wrapper {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #110905;
    border: 1px solid var(--rank-primary, #d4b96a);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-rank-icon {
    font-size: 10px;
    line-height: 1;
  }

  .mobile-header-title {
    flex: 1;
    font-family: 'Georgia', serif;
    font-size: 16px;
    font-weight: bold;
    color: #ebd69b;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-header-gold {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(212, 185, 106, 0.3);
    border-radius: 20px;
    padding: 4px 12px 4px 6px;
    flex-shrink: 0;
  }

  .mobile-header-gold img {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
  }

  .mobile-header-gold span {
    font-size: 13px;
    font-weight: 800;
    color: #ffd766;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    font-family: var(--font-body);
  }

  /* ── BOTTOM NAVIGATION — GAME DOCK ── */
  .bottom-nav {
    display: flex !important;
    background:
      linear-gradient(to right, rgba(0,0,0,0.7) 0%, transparent 50%, rgba(0,0,0,0.7) 100%),
      repeating-linear-gradient(90deg, #1f1109 0px, #1a0e07 2px, #26160c 8px, #130a05 12px)
      #110905 !important;
    border-top: 2px solid #3a2212 !important;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.7) !important;
    padding: 6px 4px !important;
    padding-bottom: max(6px, env(safe-area-inset-bottom)) !important;
    backdrop-filter: none !important;
    justify-content: space-around !important;
    z-index: 50;
  }

  /* Brass nails along the top */
  .bottom-nav::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: repeating-linear-gradient(
      90deg,
      transparent 0px, transparent 20px,
      #856d35 20px, #856d35 24px
    );
    opacity: 0.5;
  }

  .bottom-nav .nav-item {
    flex-direction: column !important;
    gap: 3px !important;
    padding: 6px 4px !important;
    text-align: center !important;
    color: #a8945f !important;
    text-decoration: none !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px;
    border-radius: 10px !important;
    transition: all 0.2s ease !important;
    min-width: 56px;
    position: relative;
    background: transparent !important;
    border: none !important;
    border-left: none !important;
    margin-bottom: 0 !important;
    transform: none !important;
    box-shadow: none !important;
  }

  .bottom-nav .nav-item::before,
  .bottom-nav .nav-item::after {
    display: none !important;
  }

  .bottom-nav .nav-icon {
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(212, 185, 106, 0.15);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    margin: 0 auto !important;
    /* Reset inherited */
    background-clip: unset !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
    filter: none !important;
    animation: none !important;
  }

  .bottom-nav .nav-label {
    font-family: 'Georgia', serif;
    color: inherit;
    display: block;
    line-height: 1.2;
  }

  /* Active tab */
  .bottom-nav .nav-item.active {
    color: #ffd766 !important;
    background: transparent !important;
    border-left: none !important;
  }

  .bottom-nav .nav-item.active .nav-icon {
    background: radial-gradient(circle, rgba(255, 215, 102, 0.2) 0%, rgba(212, 185, 106, 0.08) 100%) !important;
    border-color: #d4b96a !important;
    box-shadow: 0 0 12px rgba(255, 215, 102, 0.3), inset 0 0 6px rgba(255, 215, 102, 0.15) !important;
    transform: scale(1.08) translateY(-2px) !important;
  }

  /* Active glow ring */
  .bottom-nav .nav-item.active .nav-icon::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 102, 0.4);
    animation: navGlowPulse 2s ease-in-out infinite;
  }

  @keyframes navGlowPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
  }

  /* Tap effect */
  .bottom-nav .nav-item:active .nav-icon {
    transform: scale(0.92) !important;
    transition-duration: 0.1s !important;
  }

  /* ── CONTENT AREA — full height between header and nav ── */
  .content {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* ── HARBOR PAGE — Mobile Optimized ── */
  .harbor-page {
    padding: 16px !important;
    background-size: cover;
    background-position: center top;
  }

  .harbor-page .tavern-header {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
    position: -webkit-sticky !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background: rgba(20, 26, 38, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    margin: -16px -16px 16px -16px !important;
    padding: 16px !important;
    border-bottom: 1px solid rgba(212, 185, 106, 0.2) !important;
  }

  .harbor-page .tavern-header h1 {
    font-size: 22px !important;
    text-align: center;
  }

  .harbor-page #new-ship-btn {
    width: 100%;
  }

  /* Ship cards: single column, full width */
  .harbor-page .fleet-cards-container {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .ship-card {
    border-radius: 12px !important;
  }

  .ship-card-image-box {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
  }

  .ship-card-img {
    width: 100% !important;
    max-width: none;
  }

  .ship-card-content {
    padding: 12px 16px 16px !important;
  }

  .ship-name {
    font-size: 16px !important;
  }

  .ship-status-badge {
    font-size: 12px !important;
    padding: 4px 10px !important;
  }

  .ship-stats-row {
    font-size: 12px !important;
    margin-bottom: 12px !important;
  }

  /* Action buttons: full width, larger touch targets */
  .ship-actions {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .ship-actions .btn {
    min-height: 44px !important;
    font-size: 14px !important;
    border-radius: 8px !important;
  }

  /* ── CREATE SHIP WIZARD: ONE-PAGE COMPACT LAYOUT ── */
  .create-ship-container {
    position: relative;
    max-width: none !important;
  }

  .create-ship-container > div {
    margin-bottom: 12px !important;
  }

  .create-ship-container > div > label {
    margin-bottom: 4px !important;
    font-size: 13px !important;
  }

  /* Make the active ship preview a tiny horizontal banner */
  .create-ship-container .ship-card {
    flex-direction: row !important;
    height: 90px !important;
    border-radius: 8px !important;
  }

  .create-ship-container .ship-card-image-box {
    width: 90px;
    height: 100%;
    aspect-ratio: 1/1 !important;
    border-bottom: none !important;
    border-right: 2px solid rgba(255, 255, 255, 0.05);
  }

  .create-ship-container .ship-card-img {
    width: 100% !important;
    height: 100% !important;
  }

  .create-ship-container .ship-card-content {
    padding: 8px 12px !important;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
  }

  .create-ship-container .ship-type {
    font-size: 15px !important;
    margin-bottom: 2px;
  }

  .create-ship-container #preview-ship-desc {
    font-size: 11px !important;
    line-height: 1.2;
  }

  /* Compact 3-column mobile grid */
  .ship-type-selector {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    overflow-x: visible !important;
    scroll-snap-type: none !important;
    gap: 8px !important;
    padding: 0 0 4px !important;
  }

  .create-ship-container .ship-type-selector {
    mask-image: none !important;
    -webkit-mask-image: none !important;
  }

  .ship-type-option {
    flex: none !important;
    scroll-snap-align: none !important;
    padding: 8px 4px !important;
    min-height: 80px;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }
  
  .ship-type-option:last-child:nth-child(odd) {
    grid-column: span 3;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 12px;
    min-height: 60px !important;
  }

  .ship-type-option:last-child:nth-child(odd) img {
    margin: 0 !important;
  }

  .ship-type-option:last-child:nth-child(odd) .ship-type-option-name {
    margin-top: 0 !important;
  }

  .ship-type-option img {
    width: 36px !important;
    height: 36px !important;
    object-fit: contain;
  }

  .ship-type-option-name {
    font-size: 11px !important;
    margin-top: 6px !important;
  }

  .ship-type-option-cost {
    font-size: 10px !important;
  }

  #commission-ship-btn {
    padding: 12px !important;
    font-size: 15px !important;
    margin-top: 4px;
  }

  /* ── RECRUITMENT PAGE — Mobile ── */
  .tavern-page {
    padding: 16px !important;
  }
  .tavern-header h1,
  .create-ship-header h1,
  .page-header,
  .set-header,
  .ldg-back-row,
  .ldg-title-row {
    display: none !important;
  }


  /* Roster header: stack title & button vertically */
  .roster-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .roster-header .btn {
    padding: 10px 16px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 0 rgba(0,0,0,0.2) !important;
  }

  /* Fleet roster grid: single column */
  .fleet-cards-container {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .fleet-card {
    padding: 16px !important;
  }

  .fleet-card-name {
    font-size: 17px !important;
  }

  .fleet-card-actions {
    flex-direction: row;
  }

  /* ── Editor header — stack vertically on mobile ── */
  .editor-header {
    gap: 10px !important;
  }

  .editor-controls {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .editor-controls .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .editor-summary {
    max-width: none !important;
  }

  .team-summary-box {
    text-align: center !important;
    padding: 8px 12px !important;
  }

  /* ── 3D Carousel — Mobile Sizing ── */
  .roster-carousel-wrapper {
    perspective: 900px !important;
    padding: 10px 0 !important;
    margin-top: 10px !important;
  }

  .roster-3d-container {
    width: 260px !important;
    height: 500px !important;
  }

  .crew-card-large {
    width: 260px !important;
    height: 500px !important;
  }

  .cc-avatar-box {
    height: 170px !important;
  }

  .crew-card-large .cc-header {
    padding: 10px !important;
    font-size: 15px !important;
  }

  .crew-card-large .cc-body {
    padding: 14px !important;
  }

  .intel-btn {
    padding: 8px 0 !important;
    font-size: 11px !important;
  }

  .stat-row {
    font-size: 13px !important;
  }

  /* Carousel nav buttons: closer to cards */
  .carousel-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
  }

  .carousel-btn.prev { left: 8px !important; }
  .carousel-btn.next { right: 8px !important; }

  /* Editor confirm button */
  .editor-confirm-row {
    margin-top: 20px !important;
    padding-bottom: 16px !important;
  }

  .editor-confirm-btn {
    width: 100% !important;
    padding: 14px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
  }

  /* ── BILLING/ADMIRALTY — Mobile ── */
  .adm-vault {
    flex-direction: column !important;
    text-align: center !important;
    padding: 20px 16px !important;
    gap: 14px !important;
    border-radius: 16px !important;
  }

  .adm-coin-img {
    width: 56px !important;
    height: 56px !important;
  }

  .adm-vault-gold {
    font-size: 30px !important;
  }

  .adm-stats-row {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .adm-stat-card {
    padding: 14px !important;
  }

  .adm-stat-value {
    font-size: 20px !important;
  }

  .adm-topup-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .adm-topup-card {
    padding: 18px 10px 14px !important;
    border-radius: 12px !important;
    min-height: 140px;
    justify-content: center;
  }

  .adm-topup-coin {
    font-size: 32px !important;
  }

  .adm-topup-gold {
    font-size: 18px !important;
  }

  .adm-buy-btn {
    border-radius: 12px !important;
    padding: 14px 24px !important;
    font-size: 16px !important;
    min-height: 52px;
  }

  /* Usage ledger: horizontal scroll on tiny screens */
  .adm-card {
    padding: 18px !important;
    border-radius: 14px !important;
  }

  .adm-ledger {
    font-size: 12px !important;
  }

  .adm-ledger td,
  .adm-ledger th {
    padding: 8px 8px !important;
    white-space: nowrap;
  }

  .adm-parchment {
    padding: 16px 18px !important;
    font-size: 13px !important;
    border-radius: 12px !important;
  }

  /* ── LEDGER PAGE — Mobile ── */
  .ldg-title-icon {
    font-size: 28px !important;
  }

  .ldg-title {
    font-size: 20px !important;
  }

  .ldg-summary-strip {
    flex-direction: column !important;
    gap: 12px !important;
    text-align: center !important;
    padding: 16px !important;
  }

  .ldg-summary-meta {
    align-items: center !important;
    flex-direction: row !important;
    gap: 16px !important;
  }

  .ldg-summary-value {
    font-size: 26px !important;
  }

  .ldg-expense-card {
    padding: 12px 14px !important;
  }

  .ldg-expense-icon {
    font-size: 22px !important;
  }

  .ldg-expense-cost {
    font-size: 16px !important;
  }

  .ldg-cost-bar {
    height: 22px !important;
  }

  .ldg-bar-segment {
    font-size: 11px !important;
  }

  /* ── SETTINGS — Mobile ── */
  .set-header {
    margin-bottom: 20px !important;
  }

  .set-header-title {
    font-size: 22px !important;
  }

  .set-header-icon {
    font-size: 36px !important;
  }

  .set-group {
    border-radius: 14px !important;
  }

  .set-profile-avatar {
    width: 48px !important;
    height: 48px !important;
    font-size: 20px !important;
  }

  .set-item {
    padding: 10px 14px !important;
  }

  /* ── PAGE GENERAL — Mobile ── */
  .page {
    padding: 16px !important;
  }

  .page-title {
    font-size: 20px !important;
  }

  /* ── MODAL — Mobile ── */
  .modal-box {
    margin: 16px !important;
    padding: 24px !important;
    border-radius: 16px !important;
  }

  /* Gold shimmer animation for the mobile header coin */
  @keyframes coinSpin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
  }

  .mobile-header-gold img:active {
    animation: coinSpin 0.6s ease-in-out;
  }
}

/* ── Desktop: hide mobile-only elements ── */
@media (min-width: 769px) {
  .mobile-header {
    display: none !important;
  }
}
