.link-btn { background: none; border: 0; padding: 2px 0; color: var(--cyan); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; justify-self: center; align-self: center; }
.link-btn:hover { color: var(--yellow); }
.auth-legal a { color: var(--muted); }
.auth-legal a:hover { color: var(--cyan); }

.nav-search, .nav-bell { position: relative; color: var(--text-2); }
.nav-bell .badge { position: absolute; top: -4px; right: -6px; }
@media (max-width: 420px) { .nav-sound { display: none; } }

.notif-panel {
  position: fixed; top: 62px; right: 16px; z-index: 60; width: min(380px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 90px));
  display: flex; flex-direction: column; background: var(--bg-elev); box-shadow: 0 0 0 3px var(--border), var(--shadow-lg);
}
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 2px dashed var(--border); }
.notif-head strong { font: 0.85rem var(--font-display); text-transform: uppercase; color: var(--yellow); }
.notif-todo { display: flex; flex-direction: column; padding: 6px; gap: 4px; border-bottom: 2px dashed var(--border); }
.notif-todo-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #ffe94d14; color: var(--text); box-shadow: 0 0 0 2px #8a7a1f; }
.notif-todo-item svg { width: 16px; height: 16px; color: var(--yellow); flex: none; }
.notif-todo-item svg:last-child { margin-left: auto; transform: rotate(-90deg); color: var(--muted); }
.notif-todo-item:hover { background: #ffe94d26; }
.notif-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; flex: 1; }
.notif { display: flex; gap: 10px; padding: 10px; color: var(--text-2); }
.notif:hover { background: #ffffff0d; }
.notif.unread { background: #22e4ff0f; color: var(--text); }
.notif.unread .notif-title::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; background: var(--cyan); vertical-align: middle; }
.notif-icon { flex: none; display: grid; place-items: center; width: 32px; height: 32px; background: #000; box-shadow: 0 0 0 2px var(--border); color: var(--cyan); }
.notif-icon svg { width: 16px; height: 16px; }
.notif-icon.k-warning { color: var(--yellow); }
.notif-icon.k-gift, .notif-icon.k-season { color: var(--gold); }
.notif .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-weight: 600; font-size: .9rem; }
.notif-body { font-size: .84rem; color: var(--text-2); overflow-wrap: anywhere; }
.notif-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 12px; color: var(--muted); font-size: .9rem; }
.notif-empty svg { width: 28px; height: 28px; }
.notif-foot { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 10px; border-top: 2px dashed var(--border); color: var(--muted); font-size: .85rem; }
.notif-foot svg { width: 15px; height: 15px; }
.notif-foot:hover { color: var(--cyan); }
@media (max-width: 860px) { .notif-panel { left: 12px; right: 12px; width: auto; } }

.modal.modal-palette { width: min(620px, calc(100vw - 24px)); padding: 0; align-self: start; margin-top: 10vh; }
.palette { display: flex; flex-direction: column; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 2px dashed var(--border); }
.palette-input > svg { width: 20px; height: 20px; color: var(--cyan); flex: none; }
.palette-input input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: 1.05rem var(--font); }
.palette-input input::-webkit-search-cancel-button { display: none; }
kbd { display: inline-block; padding: 1px 6px; background: #000; box-shadow: 0 0 0 2px var(--border); color: var(--text-2); font: 0.7rem var(--font-display); }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 60vh); overflow-y: auto; }
.palette-list li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; color: var(--text-2); }
.palette-list li.active { background: var(--yellow); color: #000; }
.palette-list li.active .muted, .palette-list li.active .name { color: #000 !important; -webkit-text-fill-color: #000; }
.pal-icon { display: grid; place-items: center; width: 22px; height: 22px; flex: none; }
.pal-icon svg { width: 18px; height: 18px; }
.palette-empty { justify-content: center; color: var(--muted); cursor: default !important; }
.palette-tip { padding: 8px 14px 12px; text-align: center; }

.chat-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 40; display: grid; place-items: center; width: 56px; height: 56px; padding: 0;
  border: 0; cursor: pointer; background: var(--pink); color: #fff; box-shadow: 0 0 0 3px #000, 5px 5px 0 #000, var(--glow-pink);
}
.chat-fab svg { width: 26px; height: 26px; }
.chat-fab .badge { position: absolute; top: -8px; right: -8px; }
.chat-fab:hover { filter: brightness(1.15); }
.chat-fab:active { transform: translateY(3px); }
.chat-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(400px, 100vw); display: flex; flex-direction: column;
  background: var(--bg-elev); box-shadow: -3px 0 0 var(--pink), -12px 0 30px #000a;
}
.chat-drawer[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 2px dashed var(--border); }
.chat-head .tabs { flex: 1; margin: 0; }
.chat-head .tab svg { width: 15px; height: 15px; }
.chat-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list { list-style: none; margin: 0; padding: 10px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.cmsg { display: flex; gap: 8px; align-items: flex-start; }
.cmsg-avatar { flex: none; }
.cmsg-body { min-width: 0; flex: 1; }
.cmsg-head { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.cmsg-head time { margin-left: auto; }
.cmsg-text { margin: 2px 0 0; padding: 6px 9px; background: #000; box-shadow: 0 0 0 2px var(--border-soft); overflow-wrap: anywhere; font-size: .92rem; white-space: pre-wrap; }
.cmsg.mine .cmsg-text { box-shadow: 0 0 0 2px #a01588; background: #ff2bd612; }
.cmsg.staff .cmsg-text { box-shadow: 0 0 0 2px #8a6408; }
.cmsg-del { background: none; border: 0; padding: 2px; color: var(--muted); cursor: pointer; opacity: 0; }
.cmsg:hover .cmsg-del, .cmsg-del:focus-visible { opacity: 1; }
.cmsg-del:hover { color: var(--red); }
.cmsg-del svg { width: 14px; height: 14px; }
.chat-compose { display: flex; gap: 8px; padding: 10px; border-top: 2px dashed var(--border); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.chat-compose .input { flex: 1; min-width: 0; }
.chat-locked { padding: 12px; border-top: 2px dashed var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chat-locked p { margin: 0; }
.chat-rules { margin: 0; padding: 0 10px 6px; }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; text-align: center; }
.chat-threads { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.chat-thread { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; }
.chat-thread:hover { background: #ffffff0d; }
.chat-thread .grow { display: flex; flex-direction: column; min-width: 0; }
.chat-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-peer { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 2px solid var(--border-soft); }
@media (max-width: 860px) {
  .chat-fab { bottom: calc(78px + env(safe-area-inset-bottom)); right: 14px; width: 50px; height: 50px; }
  .chat-drawer { width: 100vw; z-index: 70; }
  body.chat-open { overflow: hidden; }
}
@media (min-width: 1280px) { body.chat-open .main { margin-right: 400px; } }

.public-page { min-height: 100vh; }
.public-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 3vw, 28px); background: #07050ff2; border-bottom: 3px solid #000; box-shadow: 0 3px 0 var(--pink); }
.public-page .view { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
.auth:has(.public-page) { display: block; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 2px; }
.kpi-row.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
.kpi-tile { padding: 12px 14px; background: #000; box-shadow: 0 0 0 2px var(--border); }
.kpi-tile .kv { font: 1.9rem/1 var(--font-digits); color: var(--yellow); overflow-wrap: anywhere; }
.kpi-tile .kl { margin-top: 4px; font: 0.68rem var(--font-display); text-transform: uppercase; color: var(--text-2); }
.kpi-tile .kh { margin-top: 4px; }
.kpi-tile.warn .kv { color: var(--orange); }

.chart { margin: 6px 0 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--border-soft); stroke-width: 1; }
.chart text { fill: var(--muted); font: 11px var(--font); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bars .hit:hover { fill: #ffffff10; }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 4px; padding: 0; font-size: .8rem; color: var(--text-2); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; flex: none; background: var(--c); box-shadow: 0 0 0 1px #000; margin-right: 4px; }
.chart-tip { position: fixed; z-index: 200; pointer-events: none; min-width: 120px; max-width: 260px; padding: 8px 10px; background: #000; color: var(--text); font-size: .8rem; box-shadow: 0 0 0 2px var(--cyan), 4px 4px 0 #000; }
.chart-tip .tip-head { margin-bottom: 4px; color: var(--yellow); font: 0.68rem var(--font-display); text-transform: uppercase; }
.chart-tip .tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border); }
.chart-table { margin-top: 8px; }
.chart-table summary { cursor: pointer; }
.chart-table .table-wrap { max-height: 260px; overflow: auto; margin-top: 6px; }

.heatmap { display: grid; grid-template-columns: 34px repeat(var(--cols), minmax(0, 1fr)); gap: 2px; align-items: center; font-size: .7rem; color: var(--muted); }
.hm-col { text-align: left; white-space: nowrap; overflow: visible; }
.hm-row { padding-right: 4px; text-align: right; }
.hm-cell { aspect-ratio: 1; min-height: 8px; background: #ffffff08; box-shadow: inset 0 0 0 1px #00000060; }
.hm-cell:hover { outline: 2px solid var(--text); }

.calendar { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); grid-template-columns: repeat(var(--weeks), minmax(0, 1fr)); gap: 2px; }
.cal-cell { aspect-ratio: 1; display: block; background: #ffffff0a; }
.cal-cell.future { visibility: hidden; }
.cal-cell.l1 { background: color-mix(in srgb, var(--c) 30%, transparent); }
.cal-cell.l2 { background: color-mix(in srgb, var(--c) 52%, transparent); }
.cal-cell.l3 { background: color-mix(in srgb, var(--c) 76%, transparent); }
.cal-cell.l4 { background: var(--c); }
.cal-cell:hover { outline: 2px solid var(--text); }
.cal-scale { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: 6px; }
.cal-scale .cal-cell { width: 10px; }

.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbars li { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: .84rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hb-track { height: 10px; background: #ffffff0a; }
.hb-fill { display: block; height: 100%; background: var(--c); border-radius: 0 2px 2px 0; }
.hb-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

.hour-bars { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; height: 90px; align-items: end; padding-bottom: 16px; position: relative; }
.hour-bar { position: relative; height: 100%; display: flex; align-items: flex-end; }
.hour-bar i { display: block; width: 100%; height: max(2px, var(--h)); background: var(--cyan); border-radius: 2px 2px 0 0; }
.hour-bar b { position: absolute; bottom: -16px; left: 0; font: 400 .66rem var(--font); color: var(--muted); }
.hour-bar:hover i { background: var(--yellow); }

.stats-filter { margin-bottom: 12px; }
.stats-filter .tab .swatch { width: 8px; height: 8px; }
.wdl-bar { display: flex; gap: 2px; height: 10px; margin: 12px 2px 8px; }
.wdl-bar .w { background: var(--green); }
.wdl-bar .d { background: var(--yellow); }
.wdl-bar .l { background: var(--red); }
.form-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.form-row > span:first-child { margin-right: 6px; }
.form-dot { display: grid; place-items: center; width: 20px; height: 20px; font: 0.62rem var(--font-display); color: #000; }
.form-dot.win { background: var(--green); }
.form-dot.loss { background: var(--red); }
.form-dot.draw { background: var(--yellow); }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stats-block { padding: 12px; background: #0006; box-shadow: 0 0 0 2px var(--border-soft); min-width: 0; }
.stats-block.wide { grid-column: 1 / -1; }
.stats-block h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font: 0.74rem var(--font-display); text-transform: uppercase; color: var(--text-2); }
.stats-block h4 svg { width: 15px; height: 15px; color: var(--cyan); }
.opp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.opp-list li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.c-win { color: var(--green); }
.c-draw { color: var(--yellow); }
.c-loss { color: var(--red); }
@media (max-width: 700px) { .stats-grid { grid-template-columns: 1fr; } }

.friend-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.friend-rank li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #0006; }
.friend-rank li.me { box-shadow: 0 0 0 2px var(--pink); background: #ff2bd612; }
.fr-rank { width: 26px; text-align: center; font: 1.3rem/1 var(--font-digits); color: var(--yellow); }
.friend-rank li:nth-child(1) .fr-rank { color: var(--gold); text-shadow: 0 0 8px #ffd36b88; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.feed li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #0006; }
.feed-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; }
.feed-icon svg { width: 26px; height: 26px; }

.settings .card { scroll-margin-top: 80px; }
.settings-nav { position: sticky; top: 64px; z-index: 4; }
.setting-list { margin: 0; }
.setting-row { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-bottom: 1px dashed var(--border-soft); }
.setting-row:last-child { border-bottom: 0; }
.setting-row dd { margin: 0; }
.setting-label { display: block; font-weight: 600; }
.setting-hint { display: block; margin-top: 2px; }
.setting-sub { display: flex; align-items: center; gap: 8px; margin: 16px 0 6px; font: 0.74rem var(--font-display); text-transform: uppercase; color: var(--text-2); }
.setting-sub svg { width: 15px; height: 15px; }
.setting-cta { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.danger-zone .setting-label { color: #ffb3c1; }
.switch { appearance: none; position: relative; flex: none; width: 46px; height: 24px; margin: 0; cursor: pointer; background: #000; box-shadow: 0 0 0 2px var(--border); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; background: var(--muted); transition: transform .15s, background .15s; }
.switch:checked { background: #3dff9a33; box-shadow: 0 0 0 2px #1d7a4c; }
.switch:checked::after { transform: translateX(22px); background: var(--green); }
.switch:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.switch:disabled { opacity: .4; cursor: not-allowed; }
.reduce-motion .switch, .reduce-motion .switch::after { transition: none; }

.help-search { display: flex; align-items: center; gap: 10px; }
.help-search svg { width: 18px; height: 18px; color: var(--cyan); }
.help-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font: 1rem var(--font); padding: 4px 0; }
.help-nav { position: sticky; top: 64px; z-index: 4; }
.public-page .help-nav { top: 66px; }
.help .card { scroll-margin-top: 130px; }
.help-games { display: flex; flex-direction: column; gap: 6px; }
.help-game, .faq details { background: #0006; box-shadow: 0 0 0 2px var(--border-soft); }
.help-game summary, .faq summary { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; list-style: none; }
.help-game summary::-webkit-details-marker, .faq summary::-webkit-details-marker { display: none; }
.help-game summary > svg:last-child, .faq summary > svg:last-child { width: 16px; height: 16px; margin-left: auto; flex: none; transition: transform .15s; }
details[open] > summary > svg:last-child { transform: rotate(180deg); }
.help-game .nav-game-icon { width: 26px; height: 26px; flex: none; }
.help-game-body { padding: 0 14px 14px; }
.rules { margin: 8px 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.faq { display: flex; flex-direction: column; gap: 6px; }
.faq summary { font-weight: 600; }
.faq details p { margin: 0; padding: 0 12px 12px; color: var(--text-2); }

.legal-body h3 { margin: 18px 0 6px; color: var(--yellow); font: 0.8rem var(--font-display); text-transform: uppercase; }
.legal-body h3:first-child { margin-top: 0; }
.legal-body p, .legal-body li { color: var(--text-2); font-size: .92rem; line-height: 1.6; }
.legal-body ul { padding-left: 20px; }
.legal-body a, .legal a, .help a:not(.btn):not(.tab) { color: var(--cyan); }

.analytics-bar { align-items: center; gap: 10px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; background: #000; box-shadow: 0 0 0 2px var(--border); }
.error-list { gap: 6px; }
.error-item { background: #0006; box-shadow: 0 0 0 2px var(--border-soft); }
.error-item summary { display: flex; align-items: center; gap: 10px; padding: 10px; cursor: pointer; list-style: none; }
.error-item summary::-webkit-details-marker { display: none; }
.err-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-detail { display: flex; flex-direction: column; gap: 6px; padding: 0 12px 12px; align-items: flex-start; }
.stack-trace { width: 100%; max-height: 220px; overflow: auto; margin: 0; padding: 10px; background: #000; color: var(--text-2); font-size: .74rem; white-space: pre-wrap; word-break: break-all; }

.report-context { list-style: none; margin: 0; padding: 8px; background: #000; display: flex; flex-direction: column; gap: 4px; font-size: .86rem; max-height: 220px; overflow: auto; }
.report-context li { padding: 3px 6px; color: var(--text-2); overflow-wrap: anywhere; }
.report-context li.hit { background: #ff4d6d26; box-shadow: inset 3px 0 0 var(--red); color: var(--text); }

.guest-banner { display: flex; align-items: center; gap: 10px; padding: 8px clamp(14px, 3vw, 28px); background: #22e4ff12; border-bottom: 2px solid #0b6177; color: var(--text-2); }
.guest-banner > svg { color: var(--cyan); flex: none; }
.guest-banner.urgent { background: #ff4d6d1c; border-bottom-color: var(--red); color: var(--text); }
.guest-banner.urgent > svg { color: var(--red); }
.guest-banner[hidden] { display: none; }
@media (max-width: 560px) { .guest-banner { flex-wrap: wrap; } .guest-banner .grow { flex-basis: calc(100% - 60px); } }

.profile-title { display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--gold); font: 0.72rem var(--font-display); text-transform: uppercase; letter-spacing: .04em; }
.showcase-pick { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow: auto; }
.showcase-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; background: #0006; cursor: pointer; }
.showcase-item:has(input:checked) { box-shadow: 0 0 0 2px var(--gold); }
.showcase-item input:disabled { opacity: .3; }
.referral .invite-link { margin-top: 8px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px 0; }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
.sr-only:focus { position: static; width: auto; height: auto; clip: auto; }

@media (max-width: 860px) { body.in-match .chat-fab { display: none; } }
