/* ── matchmaking indicator (top-left in game header) ── */
  #hdrMatchmaking { display:none; }
  #hdrMatchmaking.active { display:flex !important; }
  #hdrMatchFound { display:none; }
  #hdrMatchFound.active { display:flex !important; }
  #hdrMatchIdle { display:flex; }
  #hdrMatchmaking.active ~ #hdrMatchIdle,
  #hdrMatchFound.active ~ #hdrMatchIdle { display:none; }

  .hdr-match-dot {
    width:7px; height:7px; border-radius:50%;
    background:rgba(72,202,228,0.9);
    box-shadow:0 0 6px rgba(72,202,228,0.7);
    animation:hdrDotPulse 1.4s ease-in-out infinite;
    flex-shrink:0;
  }
  @keyframes hdrDotPulse {
    0%,100%{opacity:1;transform:scale(1)}
    50%{opacity:0.4;transform:scale(0.75)}
  }

  /* ── opponent waiting pulse dot (top-right) ── */
  .hdr-opp-pulse {
    width:6px; height:6px; border-radius:50%;
    background:rgba(255,255,255,0.22);
    flex-shrink:0;
    animation:hdrOppPulse 2s ease-in-out infinite;
  }
  @keyframes hdrOppPulse {
    0%,100%{opacity:0.22;transform:scale(1)}
    50%{opacity:0.6;transform:scale(1.35)}
  }

  /* ═══════════════════════════════════════════════
     GAME HEADER — premium redesign
  ═══════════════════════════════════════════════ */

  .game-header {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0.9rem 0 0;
  }

  /* ── Top row ── */
  .ghdr-top-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  /* ── Invite pill ── */
  .ghdr-invite-pill {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 1rem 0.42rem 0.72rem;
    background: linear-gradient(135deg, rgba(255,213,128,0.11) 0%, rgba(255,185,60,0.06) 100%);
    border: 1px solid rgba(255,213,128,0.28);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.22s ease;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
  }
  .ghdr-invite-pill::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,213,128,0.18), transparent);
    opacity: 0;
    transition: opacity 0.22s;
    border-radius: inherit;
  }
  .ghdr-invite-pill:hover::before { opacity: 1; }
  .ghdr-invite-pill:hover {
    border-color: rgba(255,213,128,0.5);
    box-shadow: 0 0 16px rgba(255,185,60,0.15), inset 0 1px 0 rgba(255,240,160,0.12);
    transform: translateY(-1px);
  }
  .ghdr-invite-pill:active { transform: translateY(0); }
  .ghdr-invite-icon {
    display: flex;
    align-items: center;
    color: rgba(255,213,128,0.85);
    flex-shrink: 0;
  }
  .ghdr-invite-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: rgba(255,213,128,0.85);
    white-space: nowrap;
    position: relative;
    z-index: 1;
  }

  /* ── Spacer between invite and rules ── */
  .ghdr-top-row > #hdrMatchmaking,
  .ghdr-top-row > #hdrMatchFound,
  .ghdr-top-row > #hdrMatchIdle,
  .ghdr-top-row > #onlineTurnPill {
    flex: 1;
  }

  /* ── How to Play button ── */
  .ghdr-rules-btn {
    display: flex;
    align-items: center;
    gap: 0.42rem;
    padding: 0.42rem 0.9rem 0.42rem 0.72rem;
    background: linear-gradient(135deg, rgba(72,202,228,0.1) 0%, rgba(27,154,170,0.06) 100%);
    border: 1px solid rgba(72,202,228,0.3);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.22s ease;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
  }
  .ghdr-rules-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(72,202,228,0.18), transparent);
    opacity: 0;
    transition: opacity 0.22s;
    border-radius: inherit;
  }
  .ghdr-rules-btn:hover::before { opacity: 1; }
  .ghdr-rules-btn:hover {
    border-color: rgba(72,202,228,0.55);
    box-shadow: 0 0 18px rgba(72,202,228,0.18), inset 0 1px 0 rgba(140,230,255,0.1);
    transform: translateY(-1px);
  }
  .ghdr-rules-btn:active { transform: translateY(0); }
  .ghdr-rules-icon {
    display: flex;
    align-items: center;
    color: rgba(72,202,228,0.9);
    flex-shrink: 0;
  }
  .ghdr-rules-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: rgba(72,202,228,0.9);
    white-space: nowrap;
    position: relative;
    z-index: 1;
  }

  /* ── Players row ── */
  .ghdr-players-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.9rem;
    margin-bottom: 0.8rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    position: relative;
    overflow: hidden;
  }
  .ghdr-players-row::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
      rgba(255,213,128,0.04) 0%,
      transparent 40%,
      transparent 60%,
      rgba(72,202,228,0.04) 100%);
    pointer-events: none;
  }

  .ghdr-player {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    position: relative;
    z-index: 1;
  }
  .ghdr-player-opp {
    flex-direction: row-reverse;
  }

  .ghdr-player-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .ghdr-dot-me {
    background: rgba(255,213,128,0.9);
    box-shadow: 0 0 6px rgba(255,185,60,0.6);
    animation: dotPulseMe 2.5s ease-in-out infinite;
  }
  @keyframes dotPulseMe {
    0%,100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.8); }
  }
  .ghdr-dot-opp {
    background: rgba(255,255,255,0.4);
    box-shadow: none;
  }
  .ghdr-dot-opp.connected {
    background: rgba(100,240,160,0.9);
    box-shadow: 0 0 6px rgba(80,220,140,0.6);
    opacity: 1 !important;
  }

  .ghdr-player-name {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
  }
  .ghdr-name-me {
    color: rgba(255,213,128,0.95);
    text-shadow: 0 0 12px rgba(255,185,60,0.25);
  }
  .ghdr-name-opp {
    color: rgba(255,255,255,0.8);
    text-align: right;
  }

  /* ── VS separator ── */
  .ghdr-vs {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: rgba(255,255,255,0.2);
    text-transform: uppercase;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    padding: 0 0.3rem;
  }

  /* ── Waiting animation (3 bouncing dots) ── */
  .ghdr-waiting {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-direction: row-reverse;
  }
  .ghdr-waiting-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.22);
    font-style: italic;
  }
  .ghdr-waiting-dots {
    display: flex;
    align-items: center;
    gap: 3px;
  }
  .ghdr-waiting-dots span {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    animation: ghdrBounce 1.4s ease-in-out infinite;
  }
  .ghdr-waiting-dots span:nth-child(1) { animation-delay: 0s; }
  .ghdr-waiting-dots span:nth-child(2) { animation-delay: 0.18s; }
  .ghdr-waiting-dots span:nth-child(3) { animation-delay: 0.36s; }
  @keyframes ghdrBounce {
    0%,80%,100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1.3); opacity: 0.9; }
  }

  /* ── invite panel overlay ── */
  #invitePanel {
    position:fixed; inset:0; z-index:10500;
    display:none; align-items:center; justify-content:center;
    padding:1.5rem;
  }
  #invitePanel.open { display:flex; }
  #invitePanel::before {
    content:''; position:fixed; inset:0;
    background:rgba(0,4,18,0.78);
    backdrop-filter:blur(8px);
    -webkit-backdrop-filter:blur(8px);
    z-index:0;
    animation:inviteBgIn 0.28s ease both;
  }
  @keyframes inviteBgIn { from{opacity:0} to{opacity:1} }
  .invite-box {
    position:relative; z-index:1;
    background:linear-gradient(160deg,rgba(20,12,0,0.97),rgba(10,6,0,0.97));
    border:1.5px solid rgba(255,213,128,0.55);
    border-radius:24px;
    padding:1.6rem 1.5rem 1.8rem;
    width:min(88vw,360px);
    box-shadow:0 0 40px rgba(255,180,40,0.2),0 20px 60px rgba(0,0,0,0.7);
    animation:inviteBoxIn 0.32s cubic-bezier(0.16,1,0.3,1) both;
    display:flex; flex-direction:column; align-items:center; gap:1.1rem;
  }
  @keyframes inviteBoxIn {
    from{opacity:0;transform:translateY(20px) scale(0.96)}
    to{opacity:1;transform:translateY(0) scale(1)}
  }
  .invite-close {
    position:absolute; top:0.8rem; right:0.9rem;
    background:none; border:none;
    color:rgba(255,213,128,0.45); font-size:1.3rem;
    cursor:pointer; line-height:1; padding:0.3rem;
    transition:color 0.2s;
  }
  .invite-close:hover { color:rgba(255,213,128,0.9); }
  .invite-title {
    font-family:'Cormorant Garamond',serif;
    font-size:1.5rem; font-weight:300;
    letter-spacing:0.08em; color:#ffd580;
    text-shadow:0 0 20px rgba(255,180,40,0.4);
    text-align:center;
  }
  .invite-tabs {
    display:flex; gap:0; width:100%;
    background:rgba(255,213,128,0.06);
    border:1px solid rgba(255,213,128,0.2);
    border-radius:12px; overflow:hidden;
  }
  .invite-tab {
    flex:1; padding:0.55rem 0.5rem;
    background:none; border:none; cursor:pointer;
    font-family:'DM Sans',sans-serif; font-size:0.8rem;
    font-weight:500; letter-spacing:0.04em;
    color:rgba(255,213,128,0.5);
    transition:background 0.2s,color 0.2s;
  }
  .invite-tab.active {
    background:rgba(255,213,128,0.14);
    color:rgba(255,213,128,0.95);
  }
  .invite-pane { width:100%; display:none; flex-direction:column; align-items:center; gap:0.9rem; }
  .invite-pane.active { display:flex; }

  /* create pane */
  .invite-room-code {
    font-family:'Cormorant Garamond',serif;
    font-size:2.4rem; font-weight:300; letter-spacing:0.25em;
    color:#ffd580; text-shadow:0 0 20px rgba(255,180,40,0.5);
    text-align:center;
  }
  .invite-qr img { border-radius:10px; border:1.5px solid rgba(255,213,128,0.3); }
  .invite-link-row {
    display:flex; align-items:center; gap:0.5rem;
    background:rgba(255,255,255,0.04);
    border:1px solid rgba(255,255,255,0.08);
    border-radius:10px; padding:0.5rem 0.7rem; width:100%;
  }
  .invite-link-text {
    flex:1; font-size:0.65rem;
    color:rgba(255,255,255,0.4); overflow:hidden;
    text-overflow:ellipsis; white-space:nowrap;
    font-family:'DM Sans',sans-serif;
  }
  .invite-copy-btn {
    background:rgba(255,213,128,0.12);
    border:1px solid rgba(255,213,128,0.35);
    border-radius:8px; padding:0.3rem 0.7rem;
    color:rgba(255,213,128,0.85); font-size:0.72rem;
    cursor:pointer; font-family:'DM Sans',sans-serif;
    white-space:nowrap; transition:background 0.2s;
    flex-shrink:0;
  }
  .invite-copy-btn:hover { background:rgba(255,213,128,0.22); }
  .invite-generating {
    display:flex; gap:0.4rem; align-items:center;
    color:rgba(255,213,128,0.5); font-size:0.8rem;
    font-family:'DM Sans',sans-serif;
  }
  .invite-gen-dot {
    width:5px; height:5px; border-radius:50%; background:#ffd580;
    animation:_goldPulse 1.2s ease-in-out infinite;
  }
  .invite-gen-dot:nth-child(2) { animation-delay:0.4s; }
  .invite-gen-dot:nth-child(3) { animation-delay:0.8s; }

  /* join pane */
  .invite-join-input {
    width:100%; padding:0.9rem 1rem; text-align:center;
    background:rgba(255,213,128,0.06);
    border:1px solid rgba(255,213,128,0.3);
    border-radius:14px; color:#ffd580;
    font-family:'Cormorant Garamond',serif;
    font-size:1.6rem; font-weight:300;
    letter-spacing:0.25em; outline:none;
    transition:border-color 0.2s,background 0.2s;
  }
  .invite-join-input:focus {
    border-color:rgba(255,213,128,0.7);
    background:rgba(255,213,128,0.1);
  }
  .invite-join-input::placeholder {
    color:rgba(255,213,128,0.2); font-size:1rem; letter-spacing:0.1em;
  }
  .invite-join-btn {
    width:100%; padding:0.85rem;
    background:rgba(255,213,128,0.12);
    border:1px solid rgba(255,213,128,0.5);
    border-radius:14px; color:#ffd580;
    font-family:'DM Sans',sans-serif; font-size:0.92rem;
    font-weight:500; cursor:pointer; letter-spacing:0.04em;
    transition:background 0.2s,box-shadow 0.2s;
  }
  .invite-join-btn:hover {
    background:rgba(255,213,128,0.2);
    box-shadow:0 0 18px rgba(255,180,40,0.25);
  }
  .invite-error { color:#ff6b6b; font-size:0.78rem; text-align:center; font-family:'DM Sans',sans-serif; }

  /* match-found toast */
  #matchToast {
    position:fixed; bottom:5rem; left:50%; transform:translateX(-50%);
    background:rgba(0,180,80,0.15);
    border:1px solid rgba(100,240,160,0.5);
    border-radius:50px; padding:0.55rem 1.2rem;
    color:rgba(100,240,160,0.95); font-size:0.82rem;
    font-family:'DM Sans',sans-serif; letter-spacing:0.04em;
    z-index:10400; display:none;
    box-shadow:0 0 20px rgba(0,200,80,0.3);
    animation:toastIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
  }
  @keyframes toastIn {
    from{opacity:0;transform:translateX(-50%) translateY(10px)}
    to{opacity:1;transform:translateX(-50%) translateY(0)}
  }