/* ════════════════════════════════════════════════════════════
   GAME MOBILE — Styles for the game page on ≤768px screens
   ════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Prevent all page scroll / pan ── */
  html, body {
    overflow: hidden;
    height: 100%;
    width: 100%;
    position: fixed;
    top: 0; left: 0;
    touch-action: none;
    overscroll-behavior: none;
  }

  /* ── Hide desktop-only elements ── */
  .desktop-only { display: none !important; }
  #header       { display: none !important; }

  /* ── Show mobile-only elements ── */
  .mobile-only  { display: flex !important; }

  /* ── Hide mobile-only elements that are now children (not direct mobile-only wrappers) ── */
  #skills-bar, #game-action-bar { display: flex !important; }

  /* ── Game screen: full-viewport column layout ── */
  #game-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    padding: 8px;
    gap: 6px;
    overflow: hidden;
    background: var(--clr-bg);
    max-width: 100%;
  }

  /* ── Players row: two panels side by side ── */
  #players-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
    width: 100%;
  }

  .player-panel {
    flex: 1;
    min-width: 0;
    width: auto !important;
    min-width: unset !important;
    padding: 8px 10px;
    /* Fixed height so timer show/hide doesn't resize panel */
    min-height: 60px;
    height: 60px;
    overflow: hidden;
    flex-direction: column;
    gap: 4px;
  }

  .panel-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
  }

  .panel-identity {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
  }

  .player-name {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-color-dot {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
  }

  .combo-display {
    padding: 3px 6px;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .combo-label { font-size: 0.6rem; }
  .combo-count { font-size: 1.1rem; }

  .player-pawn-count {
    display: none !important;
  }
  .player-pawn-count span { font-size: 1.1rem; }

  .panel-timer-row {
    /* Fixed height so layout doesn't jump when timer appears/disappears */
    min-height: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .turn-timer {
    height: 6px;
  }

  .turn-timer-text {
    font-size: 0.7rem;
    min-height: 1em; /* prevents layout shift */
  }

  /* ── Board wrapper: takes all remaining space ── */
  #board-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    border: 2px solid var(--clr-border);
    border-radius: 12px;
    background: #080b18;
    position: relative;
  }

  #game-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto !important;
    height: auto !important;
    display: block;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0;
    background: transparent;
    transform: scale(1.25);
  }

  /* Skill mode bar — appears above canvas, inside board-wrapper */
  #skill-mode-bar {
    display: none !important;
  }

  .skill-mode-title { font-size: 0.72rem; }
  .skill-btn {
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  /* ── Mobile two-column bottom bar ── */
  #mobile-bottom-bar {
    display: grid !important;
    grid-template-columns: 3fr 7fr;
    gap: 8px;
    flex-shrink: 0;
    width: 100%;
    height: 56px;
    min-height: 56px;
    margin-bottom: 50px;
  }

  /* ── Skills bar (left column) ── */
  #skills-bar {
    flex-direction: column;
    background: var(--clr-panel);
    border: 1px solid var(--clr-border);
    border-radius: 10px;
    padding: 6px 10px;
    overflow: hidden;
    box-sizing: border-box;
    height: 100%;
  }

  .skills-bar-header {
    display: none !important;
  }

  .skills-label {
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    white-space: nowrap;
  }

  /* ── Skill chips: mobile = icon only, big ── */
  #skills-bar .skill-chip {
    padding: 2px 4px;
    border-radius: 6px;
    font-size: 1.5rem;
    line-height: 1;
    border: 2px solid transparent;
    background: var(--clr-bg);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
  }

  #skills-bar .skill-chip:active {
    border-color: var(--clr-accent);
    transform: scale(1.12);
  }

  #skills-bar .skill-chip.active-skill {
    border-color: var(--clr-accent);
    transform: scale(1.15);
    background: rgba(245, 158, 11, 0.25);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
    position: relative;
    z-index: 10;
  }

  #skills-bar .skill-chip .skill-name { display: none; }
  #skills-bar .skill-chip .skill-icon { font-size: 1.5rem; }

  #skills-bar .skill-slots {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    height: 100%;
    gap: 6px;
    overflow-x: auto;
    padding: 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  #skills-bar .skill-slots::-webkit-scrollbar { display: none; }

  /* ── Action bar (right column: turns panel) ── */
  #game-action-bar {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: var(--clr-panel);
    border: 1px solid var(--clr-border);
    border-radius: 10px;
    padding: 6px 10px;
    box-sizing: border-box;
    height: 100%;
    gap: 6px;
  }

  #turn-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    flex: 1;
  }

  #turn-info .turn-indicator {
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
  }

  #turn-info .move-count {
    font-size: 0.7rem;
    color: var(--clr-text-dim);
    white-space: nowrap;
  }

  .action-buttons-mobile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
  }

  #btn-use-skill {
    display: none !important;
  }

  .action-buttons-mobile .action-btn {
    padding: 0;
    width: 44px;
    height: 44px;
    font-weight: 700;
    border-radius: 8px;
    text-align: center;
    line-height: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    gap: 4px;
  }

  .action-buttons-mobile .action-btn .btn-icon {
    font-size: 1.1rem;
  }

  .action-buttons-mobile .action-btn .btn-text {
    font-size: 0.5rem;
    letter-spacing: 0.5px;
  }

  /* ── Player panel active glow ── */
  .player-panel.active {
    border-color: var(--clr-accent) !important;
    box-shadow: 0 0 12px rgba(108,99,255,0.4) !important;
  }
  .player-panel.player2.active {
    border-color: var(--clr-accent2) !important;
    box-shadow: 0 0 12px rgba(255,107,53,0.4) !important;
  }

  /* ── Result Modal Overrides ── */
  .modal-card {
    padding: 24px 16px;
    width: 95%;
  }

  .result-stats {
    flex-wrap: wrap;
    gap: 12px;
  }

  .stat-box {
    flex: 1 1 calc(50% - 12px);
    min-width: unset;
    padding: 10px 8px;
  }

  .stat-val {
    font-size: 1.2rem;
  }

  .result-emoji {
    font-size: 4rem;
  }

  /* ── Toast Notification Overrides ── */
  #toast {
    top: 12px;
    right: 12px;
    bottom: auto;
    left: auto;
    transform: none;
    max-width: 45%;
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  /* ── Mobile Skill Popup ── */
  #mobile-skill-popup {
    position: fixed;
    bottom: 120px; /* positioned right above the bottom panels */
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: var(--clr-panel);
    border: 1px solid var(--clr-accent);
    color: var(--clr-yellow);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }

  #mobile-skill-popup.show {
    display: block !important;
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
  }
}

  /* AI Mini Skills on Mobile */
  .ai-mini-skills {
    gap: 3px;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    padding: 0 4px;
    overflow: hidden;
  }
  .ai-mini-skills .skill-chip {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
  .ai-mini-skills .skill-chip .skill-name {
    display: none !important;
  }
  .ai-mini-skills .skill-chip .skill-icon {
    font-size: 0.9rem;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
  }


     / *   E x t r a   m o b i l e   c o n s t r a i n t s   * / 
     . m o d a l - o v e r l a y   { 
         p a d d i n g :   4 0 p x   1 0 p x ; 
         b o x - s i z i n g :   b o r d e r - b o x ; 
         a l i g n - i t e m s :   c e n t e r ; 
         o v e r f l o w - y :   a u t o ; 
     } 
     . m o d a l - c a r d   { 
         w i d t h :   1 0 0 %   ! i m p o r t a n t ; 
         m a x - h e i g h t :   n o n e   ! i m p o r t a n t ; 
         m a r g i n :   a u t o ; 
         o v e r f l o w - y :   v i s i b l e ; 
     } 
  
 