/* ============================================================
   mobile.css — all phone/tablet responsive overrides
   Edit this file to adjust phone layout without affecting
   the desktop display in style.css
   ============================================================ */


/* ── Phone: action confirmation bar ── */
#mobile-confirm-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: rgba(10,8,6,0.97);
  border-top: 1px solid rgba(200,169,110,0.4);
  padding: 10px 12px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#mobile-confirm-bar.visible { display: flex; }
#mobile-confirm-label {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: #e8d5a3;
  letter-spacing: 0.06em;
  flex: 1;
}
#mobile-confirm-verify {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  border-radius: 6px;
  padding: 9px 24px;
  cursor: pointer;
  border: 1px solid;
  background: linear-gradient(135deg, #0d2e0d, #1a5c1a);
  border-color: rgba(60,180,60,0.6);
  color: #6dcc6d;
  flex-shrink: 0;
}

/* ── Phone: brighter text colours for small screen readability ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  :root {
    --sand: #e8d5a3;
    --parchment: #ffffff;
  }
}

/* ── Touch device: disable hover transforms, increase tap targets ── */
  @media (hover: none) and (pointer: coarse) {
    .card.buyable:hover, .hand-card.playable:hover, .tableau-card.useable:hover { transform: none; }
    .btn { min-height: 40px; }
    .faction-btn { min-height: 80px; }
  }


/* ── Tablet / small desktop grid collapse (≤700px) ── */
  @media (max-width: 700px) {
    #display-cards { grid-template-columns: repeat(2, 1fr); }
    #player-section { grid-template-columns: auto 1fr; }
    #ai-section { grid-template-columns: 1fr; }
    #score-panel { grid-template-columns: 1fr; }
    .emperor-panel { order: -1; }
  }


/* ── Sticky header: revert to static on narrow screens ── */
  @media (max-width: 768px) {
    #sticky-header {
      padding: 0 0 8px;
      position: static !important;
      box-shadow: none !important;
      transform: none !important;
      left: auto !important;
      width: auto !important;
    }
    #sticky-header-spacer {
      display: none !important;
    }
  }
  body.is-mobile #sticky-header {
    position: static;
    box-shadow: none;
    transform: none;
    padding: 0 0 8px;
    left: auto;
    width: auto;
  }
  body.is-mobile #sticky-header-spacer {
    display: none;
  }


  /* ── Mobile layout ── */
  @media (max-width: 700px) {
    html { font-size: 13px; }
    #app { padding: 8px 0; padding-bottom: 100px; }
    #score-panel { flex-direction: column; gap: 6px; }
    .player-score { width: 100%; }
    .emperor-panel { order: -1; flex-direction: row; justify-content: center; gap: 12px; padding: 8px 0; }
    .emperor-title { font-size: 0.65rem; }
    .emperor-pts { font-size: 1.4rem; }
    #ai-section, #display-section { padding: 0; margin-bottom: 0; }
    #player-section { margin-bottom: 0; margin-top: 6px; grid-template-columns: auto 1fr; }
    .tableau-cards, #display-cards, #hand-cards { gap: 6px; }
    .card-wrap { width: clamp(80px, 22vw, 120px); }
    #action-bar { flex-wrap: wrap; justify-content: center; }
    #log-panel { height: calc(12 * 1.8em + 2.4em); font-size: 0.72rem; }
    .section-label, .log-label { font-size: 0.7rem; }
    .cant-play-tip { font-size: 0.58rem; }
    #display-cards { grid-template-columns: repeat(2, 1fr); }
    #ai-section { grid-template-columns: 1fr; }
    #score-panel { grid-template-columns: 1fr; }
    .emperor-panel { order: -1; }
    .hand-area, .tableau-area { padding: 8px 0; }
    .hand-card, .tableau-card { width: clamp(60px, 13vw, 100px); }
    .opp-hand-card { width: clamp(60px, 13vw, 100px); }
    .card-name, .card-display-title { display: none; }
    .hand-cards { flex-wrap: nowrap; }
    .tableau-cards { flex-wrap: wrap; }
  }

  @media (max-width: 480px) {
    html { font-size: 12px; }
    #app { padding: 6px 0; padding-bottom: 90px; }
    header { padding: 4px 0; }
    header h1 { font-size: 1.6rem; }
    .btn { font-size: 0.68rem; padding: 6px 10px; }
    .btn-sm { font-size: 0.6rem; padding: 3px 8px; }

    /* Score panel: compact horizontal layout per player */
    #score-panel { gap: 4px; margin-bottom: 4px; }
    .player-score { padding: 8px 0; }
    .player-name { font-size: 0.82rem; margin-bottom: 4px; }
    .score-chip { padding: 2px 5px; font-size: 0.78rem; }
    .resource-row { font-size: 0.82rem; gap: 6px; }
    .emperor-panel { padding: 6px 0; gap: 8px; }
    .emperor-pts { font-size: 1.2rem; }

    /* Cards: fit 3 per row in display, smaller hand/tableau cards */
    #display-cards { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .card-wrap { width: clamp(60px, 28vw, 95px); }
    .hand-card, .tableau-card { width: clamp(55px, 17vw, 88px); padding: 6px; }
    .opp-hand-card { width: clamp(55px, 17vw, 88px); }
    .hand-cards, .tableau-cards { gap: 5px; }
    .hand-area, .tableau-area { padding: 6px 0; }
    .card-name, .card-display-title { display: none; }
    .score-line { font-size: 0.78rem; }

    /* Action row */
    #action-row { gap: 8px; margin-bottom: 2px; min-height: 20px; }
    #pending-action { font-size: 0.82rem; min-height: 0; }
    #action-bar { gap: 6px; }
    #status-bar { font-size: 0.82rem; min-height: 14px; height: auto; }
    #last-log-line { padding-top: 0; padding-bottom: 0; }

    /* Log */
    #log-panel { height: calc(9 * 1.8em + 2.2em); font-size: 0.68rem; padding: 6px 0; }
    .log-entry { font-size: 0.72rem; }
    .section-label, .log-label { font-size: 0.65rem; letter-spacing: 0.1em; }
    .deck-info { font-size: 0.78rem; }

    /* Faction modal compact on small phones */
    #faction-modal .modal { min-height: 260px; padding: 16px 0 10px; }
    .faction-btn { padding: 14px 10px; }
    .faction-btn .faction-name { font-size: 0.95rem; }
    .faction-btn .faction-house { font-size: 0.72rem; }
    .faction-btn .faction-desc { font-size: 0.68rem; }
  }

  /* Prevent text from being too small to read on any phone */
  @media (max-width: 380px) {
    html { font-size: 11px; }
    #display-cards { grid-template-columns: repeat(2, 1fr); }
    .hand-card, .tableau-card { width: clamp(50px, 22vw, 80px); }
    .opp-hand-card { width: clamp(50px, 22vw, 80px); }
  }


/* ── Phone: popup cost badge ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  .mobile-overlay-cost {
    text-align: center;
    background: rgba(61,53,38,0.9);
    border: 1px solid rgba(200,169,110,0.4);
    border-radius: 6px;
    padding: 4px 18px;
    font-size: 1.3rem;
    font-family: 'Cinzel', serif;
    color: var(--sand);
    white-space: nowrap;
  }
  .mobile-overlay-cost.free  { color: #7dbe6a; border-color: rgba(125,190,106,0.4); }
  .mobile-overlay-cost.costly { color: #e74c3c; border-color: rgba(231,76,60,0.4); }
}

/* ── Phone: opponent hand summary text ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  .ai-hand-summary {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: var(--sand);
    letter-spacing: 0.05em;
    padding: 4px 0;
    display: block;
    text-align: center;
  }
}

/* ── Phone: AI hand box — inline label + summary, compact height ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  #ai-section .hand-area {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 3px 8px;
  }
  #ai-section .hand-area .section-label {
    margin-bottom: 0;
    white-space: nowrap;
  }
  #ai-section #ai-hand-cards {
    min-height: 0;
  }
  .ai-hand-summary {
    padding: 0;
  }
}

/* ── Compact score strip: 3-column row on phone (portrait and landscape) ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {

  /* Panel: horizontal 3-column strip */
  #score-panel {
    display: flex;
    flex-direction: row;
    gap: 4px;
    margin-bottom: 2px;
    min-height: 0;
    align-items: stretch;
  }

  /* Player columns: flex, compact padding, no fixed width */
  .player-score {
    flex: 1;
    min-height: 0;
    padding: 4px 5px 3px;
    width: auto;
  }

  /* Hide sigil — too large for compact strip */
  .player-sigil { display: none; }

  /* Name row */
  .player-name {
    font-size: 0.65rem;
    margin-bottom: 2px;
    letter-spacing: 0.03em;
    gap: 3px;
  }
  .you-tag, .ai-tag { font-size: 0.65rem; }

  /* Score chips */
  .score-row {
    gap: 2px;
    margin-bottom: 2px;
    min-height: 0;
    flex-wrap: wrap;
  }
  .score-chip {
    padding: 1px 3px;
    font-size: 0.65rem;
    gap: 2px;
    border-radius: 3px;
  }
  .score-chip .sym { font-size: 0.65rem; }
  .score-chip.total { font-size: 0.6rem; padding: 1px 3px; }
  /* Short names + inline solari in name row */
  .name-full { display: none; }
  .name-short { display: inline; }
  .name-solari {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: 0.65rem;

  }
  .leto .name-solari { margin-right: auto; }
  .baron .name-solari { margin-left: auto; }

  /* Leto: restore right-alignment */
  .player-score.leto { align-items: flex-end; text-align: right; }
  .player-score.leto .player-name { justify-content: flex-end; }
  .player-score.leto .score-row { justify-content: flex-end; }

  /* Resources row hidden — solari moved into name row */
  .resource-row { display: none; }








  /* Blocked indicator */
  .blocked-indicator { font-size: 0.6rem; margin-top: 1px; }
  #blocked-panel { margin-top: 2px; gap: 2px; }
  .blocked-sym { padding: 1px 3px; font-size: 0.6rem; }

  /* Emperor column: narrow, centered */
  .emperor-panel {
    flex: 0 0 auto;
    min-width: 54px;
    padding: 4px 5px 3px;
    order: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1px;
  }
  .emperor-title {
    font-size: 0.52rem;
    margin-bottom: 1px;
    letter-spacing: 0.1em;
  }
  .emperor-pts { font-size: 1rem; }
  .emperor-label { font-size: 0.52rem; }
  .supply-label { font-size: 0.52rem; margin-top: 2px; }
}

/* ── Landscape phone: remove all horizontal padding ── */
@media (orientation: landscape) and (max-width: 900px) {
  #app { padding-left: 0; padding-right: 0; }
  #sticky-header { padding-left: 0; padding-right: 0; }
  .player-score { padding-left: 0; padding-right: 0; }
  .emperor-panel { padding-left: 0; padding-right: 0; }
  .modal { padding-left: 12px; padding-right: 12px; }
  #ai-section { grid-template-columns: 1fr; }
}

/* ── Display card coin overlay: 40% smaller on phone ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  .card-solari-on { font-size: 2.295rem; }
  .tableau-card .card-solari-on { font-size: 1.13rem; }
}

/* ── Phone: replace deck pile visual with text info line ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  .deck-pile-wrapper { display: none; }
  #display-cards {
    grid-template-columns: repeat(4, auto);
    justify-content: center;
  }
  #mobile-deck-info {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    letter-spacing: 0.2em;
    color: rgba(200,169,110,0.5);
    text-transform: uppercase;
    margin-bottom: 4px;
  }
}

/* ── Phone: enlarge hand/tableau card coin overlay by 25% ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  #mobile-card-overlay-coins { font-size: 9.225rem !important; }
}

/* ── Phone: enlarge popup coin overlay by 25% ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  #card-popup-coins { font-size: 15.24rem !important; }
}

/* ── Phone: scrollable header buttons, sticky score panel ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  /* Header: flex row with buttons on sides, title centered */
  header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
    padding: 6px 0;
  }
  header h1 { flex: 1; text-align: center; }

  /* Unfix the buttons — let them flow inside the header flex row */
  #restart-btn, #rules-btn {
    position: static !important;
    font-size: 0.65rem;
    padding: 3px 8px;
    min-height: 0;
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Score panel: stick to top of viewport when header scrolls away */
  #score-panel {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--night);
    padding-top: 3px;
    padding-bottom: 3px;
  }
}

/* ── Phone: hide background image during gameplay ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  body.game-started #bg-layer { display: none; }
  body.game-started::before { display: none; }
}

/* ── Phone: restore horizontal padding on faction select screen ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  #faction-modal .modal { padding-left: 12px; padding-right: 12px; }
}

/* ── Phone: tiny horizontal padding + sound/music button row ── */
@media (max-width: 700px), (orientation: landscape) and (max-width: 900px) {
  #app { padding-left: 4px; padding-right: 4px; }

  #phone-btn-row {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    padding: 6px 0 4px;
  }
  #phone-btn-row #music-btn {
    display: none;
  }
  #phone-btn-row #sound-btn {
    position: static !important;
    font-size: 0.65rem;
    padding: 3px 8px;
    min-height: 0;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
