/* In-game chat (np-chat.js): button with unread badge in the match bar, panel = popover on desktop, bottom sheet on phones,
   side sheet on landscape phones. Text bubbles reuse .np-mp-bubble on the seat chips. */
.np-chat-slot { display: inline-flex; flex: none; }
.npcht-btn { position: relative; min-width: 40px; padding: 0 10px; }
.npcht-btn.is-off { opacity: .55; }
.npcht-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--hot, #ff5a36); color: #fff;
  font: 800 11px/18px var(--font-body, system-ui); text-align: center; box-shadow: 0 0 0 2px var(--bg-card, #fff); pointer-events: none; }
.npcht-badge[hidden] { display: none; }

/* text bubbles can wrap (up to 120 chars) */
.np-mp-bubble { width: max-content; max-width: min(230px, 62vw); white-space: normal; overflow-wrap: anywhere; line-height: 1.3; text-align: center; }

.npcht-back { position: fixed; inset: 0; z-index: 7400; background: rgba(8, 10, 22, .35); }
.npcht-back[hidden] { display: none; }
.npcht-panel { position: fixed; right: 16px; bottom: 16px; z-index: 7500; width: 340px; max-width: calc(100vw - 32px); height: min(460px, calc(100vh - 32px));
  display: flex; flex-direction: column; background: var(--bg-card, #fff); color: var(--text, #12142a); border: 1px solid var(--border, #e1ded3);
  border-radius: var(--r, 14px); box-shadow: var(--shadow-3, 0 18px 48px rgba(0,0,0,.28)); overflow: hidden; font-family: var(--font-body, system-ui); }
.npcht-panel[hidden] { display: none; }
.npcht-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border, #e1ded3); flex: none; }
.npcht-head b { font-size: 15px; }
.npcht-sp { flex: 1; }
.npcht-ib { appearance: none; display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 8px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-dim, #565a72); font-size: 22px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.npcht-ib:hover, .npcht-ib:focus-visible { background: var(--bg-panel, #eceae2); color: var(--text, #12142a); outline: none; }
.npcht-opts { display: flex; flex-direction: column; padding: 6px 14px; border-bottom: 1px solid var(--border, #e1ded3); background: var(--bg-panel, #eceae2); flex: none; max-height: 45%; overflow: auto; }
.npcht-opts[hidden] { display: none; }
.npcht-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; font-size: 14px; font-weight: 600; cursor: pointer; }
.npcht-opt span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.npcht-opt input { width: 20px; height: 20px; accent-color: var(--accent, #3e7d00); flex: none; }
.npcht-log { flex: 1 1 auto; min-height: 60px; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.npcht-log[hidden] { display: none; }
.npcht-empty { margin: auto 0; text-align: center; font-size: 13px; color: var(--text-muted, #8a8da3); padding: 8px; }
.npcht-msg { position: relative; align-self: flex-start; max-width: 88%; padding: 6px 30px 6px 10px; border-radius: 12px; background: var(--bg-panel, #eceae2);
  font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.npcht-msg[hidden] { display: none; }
.npcht-msg.is-me { align-self: flex-end; background: var(--accent-soft, #eaf8c9); padding-right: 10px; }
.npcht-msg.is-emote .npcht-txt { font-weight: 700; }
.npcht-who { display: block; font-size: 11px; font-weight: 800; color: var(--text-muted, #8a8da3); }
.npcht-rep { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted, #8a8da3);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; opacity: .7; }
.npcht-rep:hover, .npcht-rep:focus-visible { opacity: 1; color: var(--red, #e23d4b); background: var(--bg-card, #fff); outline: none; }
.npcht-reported { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 700; color: var(--text-muted, #8a8da3); }
.npcht-offmsg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; font-size: 14px; color: var(--text-dim, #565a72); }
.npcht-offmsg[hidden], .npcht-bottom[hidden] { display: none; }
.npcht-bottom { flex: none; border-top: 1px solid var(--border, #e1ded3); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.npcht-quick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.npcht-quick::-webkit-scrollbar { display: none; }
.npcht-chip { appearance: none; flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border, #e1ded3); background: var(--bg-panel, #eceae2);
  color: var(--text, #12142a); font: 700 13px/1 var(--font-body, system-ui); cursor: pointer; touch-action: manipulation; white-space: nowrap; }
.npcht-chip:hover, .npcht-chip:focus-visible, .npcht-em:hover, .npcht-em:focus-visible { background: var(--accent-soft, #eaf8c9); outline: none; }
.npcht-emoji { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; max-height: 136px; overflow-y: auto; }
.npcht-emoji[hidden] { display: none; }
.npcht-em { appearance: none; height: 40px; border: 0; border-radius: 10px; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.npcht-form { display: flex; align-items: center; gap: 6px; }
.npcht-in { flex: 1 1 auto; min-width: 0; height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border, #e1ded3); background: var(--bg, #f3f2ec);
  color: var(--text, #12142a); font: 16px/1.2 var(--font-body, system-ui); }
.npcht-in:focus { outline: none; border-color: var(--accent, #3e7d00); box-shadow: 0 0 0 3px var(--accent-soft, #eaf8c9); }
.npcht-in.is-max { border-color: var(--hot, #ff5a36); }
.npcht-in[hidden], .npcht-send[hidden] { display: none; }
.npcht-send { min-height: 40px; flex: none; }
.npcht-guest { font-size: 13px; color: var(--text-dim, #565a72); padding: 2px 4px; }
.npcht-guest a { font-weight: 800; color: var(--accent, #3e7d00); }
.npcht-guest[hidden] { display: none; }
.npcht-err { font-size: 12px; font-weight: 600; color: var(--red, #e23d4b); padding: 0 4px; }
.npcht-err[hidden] { display: none; }

/* phones (portrait): bottom sheet; landscape phones: side sheet, so the board stays visible on the left */
@media (max-width: 640px) {
  .npcht-panel { left: 0; right: 0; bottom: 0; width: auto; max-width: none; height: min(62vh, 470px); border-radius: 18px 18px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0); }
}
@media (max-height: 500px) and (min-width: 641px) {
  .npcht-panel { top: 0; right: 0; bottom: 0; left: auto; width: min(340px, 48vw); height: auto; max-height: none; border-radius: 16px 0 0 16px; border-right: 0; }
  .npcht-bottom { padding: 6px; gap: 4px; }
  .npcht-emoji { max-height: 96px; }
  .npcht-head { padding-top: 4px; padding-bottom: 4px; }
}
/* docked panel (wide screens): first card of the sidebar, beside the board, visible by default during a live match */
.npcht-btn[hidden] { display: none; }
.npcht-panel.is-dock { position: sticky; top: calc(var(--header-h, 64px) + 10px); left: auto; right: auto; bottom: auto; z-index: 5; width: auto; max-width: none;
  height: min(440px, calc(100vh - var(--header-h, 64px) - 40px)); min-height: 280px; border: 1px solid var(--border, #e1ded3); border-radius: var(--r, 14px);
  box-shadow: var(--shadow-1, 0 2px 8px rgba(0,0,0,.08)); animation: none; padding-bottom: 0; flex: none; }
.npcht-panel.is-dock .npcht-head { padding-top: 4px; padding-bottom: 4px; }
.npcht-panel.is-dock .npcht-ib { min-width: 36px; height: 36px; }
@media (min-width: 900px) and (max-width: 960px) {
  body.npcht-docked:not(.np-focus) .game-page { grid-template-columns: minmax(0, 1fr) 280px; }
  body.npcht-docked:not(.np-focus) .game-sidebar { display: flex; }
}

/* compact strip (phones / narrow screens): last 2 messages + openers, last item of the toolbar (above the board, never over it) */
.npcht-strip { order: 99; flex: 1 1 100%; min-width: 0; display: flex; align-items: center; gap: 4px; padding: 3px 3px 3px 10px; border-radius: 12px;
  background: var(--bg-panel, #eceae2); border: 1px solid var(--border, #e1ded3); transition: background-color .3s, border-color .3s; }
.npcht-strip.is-new { background: var(--accent-soft, #eaf8c9); border-color: var(--accent, #3e7d00); }
.npcht-strip-log { appearance: none; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: 36px; padding: 0;
  border: 0; background: transparent; color: var(--text, #12142a); text-align: left; font: 13px/16px var(--font-body, system-ui); cursor: pointer; touch-action: manipulation; }
.npcht-sl { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npcht-sl b { font-weight: 800; color: var(--text-dim, #565a72); }
.npcht-sl.is-me b { color: var(--accent, #3e7d00); }
.npcht-sl.is-empty { color: var(--text-muted, #8a8da3); font-weight: 600; }
.npcht-strip-btns { display: flex; gap: 2px; flex: none; }
.npcht-ib.npcht-strip-b { min-width: 36px; width: 36px; height: 36px; padding: 0; font-size: 20px; }
.npcht-strip-b.is-type { color: var(--accent, #3e7d00); }
.npcht-strip-b.is-min { width: 30px; min-width: 30px; }
/* landscape phones: the toolbar is a slim left column, the strip stacks (messages above, buttons below) */
@media (max-height: 500px) and (max-width: 1000px) and (orientation: landscape) {
  .npcht-strip { flex-direction: column; align-items: stretch; padding: 4px; gap: 2px; flex: none; width: 100%; }
  .npcht-strip-log { font-size: 12px; line-height: 15px; min-height: 32px; padding: 0 2px; }
  .npcht-strip-btns { justify-content: space-between; }
  .npcht-ib.npcht-strip-b { height: 32px; }
  .npcht-strip.is-1 .npcht-sl:not(:last-child) { display: none; }
  .npcht-strip.is-1 .npcht-strip-log { min-height: 18px; }
  body.npcht-tbc .game-toolbar .toolbar-actions { flex-direction: row; flex-wrap: wrap; }
  body.npcht-tbc .game-toolbar .toolbar-actions > .np-music-tb, body.npcht-tbc .game-toolbar .toolbar-actions > .focus-btn { flex: 1 1 0; width: auto; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .npcht-strip { transition: none; } }
@media (prefers-reduced-motion: no-preference) {
  .npcht-panel.is-sheet { animation: npcht-up .18s ease-out; }
  @keyframes npcht-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ---------------------------------------------------------------- "Play with a friend" invite card (NPMatchUI.invite) */
.npi { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.npi-t { font: 800 18px/1.2 var(--font-display, system-ui); letter-spacing: -.01em; }
.npi-sub { margin: 0; font-size: 13px; line-height: 1.35; color: var(--text-dim, #565a72); }
.npi .np-share { gap: 8px !important; }
.npi .np-sh, .npi-copy { flex: 1 1 120px; }
.npi .np-sh-whatsapp { order: -3; flex-basis: 100%; }
.npi .np-sh-messenger { order: -2; }
.npi .np-sh-sms { order: -1; }
.npi-copy { order: 0; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--volt, #d4ff3a); color: var(--volt-ink, #0e1020); font: 700 14px/1 var(--font-body, system-ui); touch-action: manipulation; }
.npi-copy.is-done { background: var(--green, #1f9d55); color: #fff; }
.npi .np-sh-more { order: 1; }
.npi-url { width: 100%; height: 28px; padding: 0 8px; border: 0; border-radius: 8px; background: var(--bg-panel, #eceae2); color: var(--text-muted, #8a8da3);
  font: 12px/28px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; text-overflow: ellipsis; cursor: text; }
.npi-url:focus { outline: 2px solid var(--accent, #3e7d00); color: var(--text, #12142a); }
.npi-wait { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--text-dim, #565a72); }
.npi-av { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; color: #fff; font-size: 14px; font-weight: 800; }
.npi-av.is-empty { background: transparent; color: var(--text-muted, #8a8da3); border: 2px dashed var(--border-strong, #cfcbbd); }
.npi-dots { display: inline-flex; gap: 4px; }
.npi-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted, #8a8da3); animation: npi-dot 1.2s infinite ease-in-out; }
.npi-dots i:nth-child(2) { animation-delay: .2s; } .npi-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes npi-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.npi-wt { flex-basis: 100%; }
.npi .np-mp-row { justify-content: center; }
@media (prefers-reduced-motion: reduce) { .npi-dots i { animation-duration: 3s; } }
@media (max-height: 640px) { .npi { gap: 7px; } .npi .np-sh, .npi-copy { min-height: 40px !important; } }
@media (max-height: 500px) {
  .npi { gap: 5px; }
  .npi-t { font-size: 15px; }
  .npi-sub { display: none; }
  .npi .np-share { gap: 5px !important; }
  .npi .np-sh, .npi-copy { min-height: 34px !important; padding: 0 10px !important; font-size: 13px !important; border-radius: 10px !important; }
  .npi .np-sh-whatsapp { flex-basis: 120px; }
  .npi-url { height: 24px; line-height: 24px; }
  .npi-wt { flex-basis: auto; }
  .npi-av { width: 22px; height: 22px; font-size: 12px; }
  .npi .np-mp-row .btn { min-height: 32px; }
}

/* ---------------------------------------------------------------- end-of-match card over the board (NPMatchUI.result) */
.game-area.np-res-on { position: relative; }
.np-res-ov { position: absolute; inset: 0; z-index: 22; display: flex; align-items: center; justify-content: center; padding: 10px; background: rgba(8, 10, 22, .42); }
.np-res-ov.is-hidden { background: transparent; pointer-events: none; align-items: flex-start; }
.np-res-ov.is-hidden .npr-show { pointer-events: auto; }
.game-area.np-mm-wait > .np-res-ov { display: none; }
.npr-card { position: relative; width: 100%; max-width: 360px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 16px 14px 14px;
  text-align: center; background: var(--bg-card, #fff); color: var(--text, #12142a); border: 1px solid var(--border, #e1ded3); border-radius: var(--r-lg, 20px);
  box-shadow: var(--shadow-3, 0 18px 48px rgba(0,0,0,.3)); }
.npr-card[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .npr-card { animation: npr-in .22s ease-out; } @keyframes npr-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } } }
.npr-hide { position: absolute; top: 6px; right: 6px; appearance: none; border: 0; background: transparent; color: var(--text-dim, #565a72); font: 700 12px/1 var(--font-body, system-ui);
  padding: 8px; border-radius: 8px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.npr-hide:hover { color: var(--text, #12142a); background: var(--bg-panel, #eceae2); }
.npr-t { font: 800 28px/1.1 var(--font-display, system-ui); letter-spacing: -.02em; margin-top: 10px; }
.npr-card.is-win .npr-t { color: var(--green, #1f9d55); }
.npr-card.is-loss .npr-t { color: var(--red, #e23d4b); }
.npr-why { font-size: 14px; font-weight: 600; color: var(--text-dim, #565a72); overflow-wrap: anywhere; }
.npr-meta { display: flex; align-items: center; justify-content: center; gap: 8px 12px; flex-wrap: wrap; font-size: 13px; }
.npr-opp { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.npr-opp b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; display: inline-block; vertical-align: bottom; }
.npr-av { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; color: #fff; font-size: 14px; font-weight: 800; }
.npr-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.npr-xp { padding: 3px 9px; border-radius: 999px; background: var(--volt, #d4ff3a); color: var(--volt-ink, #0e1020); font-weight: 800; font-size: 12px; }
.npr-note { font-size: 13px; color: var(--text-dim, #565a72); }
.npr-extra { font-size: 13px; }
.npr-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 2px; }
.npr-btns .btn { width: 100%; min-height: 42px; padding: 0 8px; white-space: normal; line-height: 1.15; }
.npr-btns .btn-primary { grid-column: 1 / -1; }
.npr-btns .np-chat-slot { grid-column: 1 / -1; justify-content: center; }
.npr-show { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); appearance: none; border: 0; border-radius: 999px; padding: 0 16px; min-height: 36px;
  background: var(--ink, #0e1020); color: #fff; font: 700 13px/1 var(--font-body, system-ui); box-shadow: var(--shadow-2, 0 6px 20px rgba(0,0,0,.25)); cursor: pointer; }
.npr-show[hidden] { display: none; }
@media (max-height: 640px) { .npr-card { gap: 6px; padding: 12px; } .npr-t { font-size: 24px; margin-top: 8px; } .npr-btns .btn { min-height: 38px; } }
@media (max-height: 500px) {
  .np-res-ov { padding: 6px; }
  .npr-card { max-width: 560px; gap: 4px; padding: 8px 10px; }
  .npr-t { font-size: 20px; margin-top: 0; }
  .npr-why { font-size: 13px; }
  .npr-av { width: 22px; height: 22px; font-size: 12px; }
  .npr-btns { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .npr-btns .btn-primary { grid-column: auto; }
  .npr-btns .btn { min-height: 34px; font-size: 13px; }
  .npr-hide { top: 2px; right: 2px; padding: 6px; }
}

/* short board areas (JS adds is-tight / is-tighter when the card would scroll) */
.np-mm-card.is-tight .npi { gap: 6px; }
.np-mm-card.is-tight .npi-t { font-size: 15px; }
.np-mm-card.is-tight .npi-sub { display: none; }
.np-mm-card.is-tight .npi .np-share { gap: 5px !important; }
.np-mm-card.is-tight .npi .np-sh, .np-mm-card.is-tight .npi-copy { min-height: 36px !important; padding: 0 10px !important; font-size: 13px !important; border-radius: 10px !important; flex: 1 1 auto; }
.np-mm-card.is-tight .npi .np-sh-whatsapp { flex-basis: auto; }
.np-mm-card.is-tight .npi-url { height: 24px; line-height: 24px; }
.np-mm-card.is-tight .npi-wt { flex-basis: auto; }
.np-mm-card.is-tight .npi-av { width: 22px; height: 22px; font-size: 12px; }
.np-mm-card.is-tight .npi .np-mp-row .btn { min-height: 34px; }
.np-mm-card.is-tight { padding: 10px; }
.np-mm-card.is-tighter .npi-url, .np-mm-card.is-tighter .np-mm-note { display: none; }
.np-mm-card.is-tighter .npi .np-sh, .np-mm-card.is-tighter .npi-copy { min-height: 32px !important; }
.npr-card.is-tight { gap: 4px; padding: 8px 10px; }
.npr-card.is-tight .npr-t { font-size: 20px; margin-top: 2px; }
.npr-card.is-tight .npr-btns .btn { min-height: 34px; font-size: 13px; }
.npr-card.is-tight .npr-av { width: 22px; height: 22px; font-size: 12px; }
.npr-card.is-tighter .npr-btns { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.npr-card.is-tighter .npr-btns .btn-primary { grid-column: auto; }
.npr-card.is-tighter .npr-btns .btn { min-height: 32px; }
