/* Tap for 99 — Top 50 Commanders page */
:root {
  --bg: #17101f;
  --header: #281c35;
  --surface: #1e1529;
  --surface-2: #221830;
  --surface-3: #2c2040;
  --raised: #3a2b50;
  --line: #3d2e52;
  --line-2: #4a3864;
  --gold: #e0b45a;
  --gold-hi: #f3cf85;
  --text: #f1e9db;
  --text-2: #d6cbe3;
  --muted: #bcaecf;
  --dim: #9a8bb0;
  --good: #93d1a1;
  --warn: #f2a184;
  --pip-W: #f3ebcf; --pip-U: #9cc9ee; --pip-B: #c3b7bb; --pip-R: #f2a184; --pip-G: #93d1a1; --pip-C: #cfc8d8;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--gold); }
a:hover { color: var(--gold-hi); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.t99-wrap { max-width: 1240px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* Hero */
.t99-main { padding-top: 48px; padding-bottom: 64px; }
.t99-hero { text-align: center; margin-bottom: 40px; }
.t99-eyebrow { font-size: 12px; letter-spacing: .24em; font-weight: 600; color: var(--gold); }
.t99-hero h1 { font: 600 48px/1.1 Cinzel, serif; margin: 12px 0; }
.t99-hero p { margin: 0 auto; max-width: 560px; color: var(--muted); font-size: 17px; }
.t99-ornament { color: var(--gold); margin-top: 16px; font-size: 18px; }
@media (max-width: 600px) { .t99-hero h1 { font-size: 36px; } }

/* Toolbar */
.t99-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.t99-colors { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.t99-chip { min-height: 44px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.t99-chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1a1224; }
.t99-pipbtn { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.t99-pipbtn[aria-pressed="true"] { border: 2px solid var(--gold); background: var(--surface-3); }
.t99-pipbtn[aria-pressed="false"] .t99-pip { opacity: .75; }
.t99-seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.t99-seg button { min-height: 36px; padding: 8px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; }
.t99-seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); font-weight: 600; }

.t99-status { margin: 0 0 20px; color: var(--dim); font-size: 13px; min-height: 20px; }

/* Pips */
.t99-pip { width: 22px; height: 22px; border-radius: 999px; color: #1a1224; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.t99-pip--sm { width: 18px; height: 18px; font-size: 9px; }
.t99-pip--W { background: var(--pip-W); } .t99-pip--U { background: var(--pip-U); } .t99-pip--B { background: var(--pip-B); }
.t99-pip--R { background: var(--pip-R); } .t99-pip--G { background: var(--pip-G); } .t99-pip--C { background: var(--pip-C); }
.t99-pips { display: flex; gap: 3px; flex-shrink: 0; }

/* Grid + tiles */
.t99-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.t99-tile { position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; border: 1px solid #33254a; background: var(--surface); }
.t99-tile:hover { border-color: #6b5488; }
.t99-tile.is-open { border-color: var(--gold); }

.t99-tile__btn { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: var(--art-base, #2a1f3b); color: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; }
.t99-tile__btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.t99-tile__art { flex: 1; min-height: 0; position: relative; background: var(--art-base, #2a1f3b); overflow: hidden; }
.t99-tile__art img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.t99-tile:hover .t99-tile__art img { transform: scale(1.04); }
.t99-tile__noart { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); font: 600 28px Cinzel, serif; }
.t99-tile__bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--panel, #1c1428); border-top: 1px solid var(--line); }
.t99-tile__names { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.t99-tile__name { font-weight: 600; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t99-tile__tags { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t99-rank { position: absolute; top: 12px; left: 12px; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--gold); color: var(--gold); font: 700 15px/1 Cinzel, serif; display: flex; align-items: center; justify-content: center; }
.t99-badges { position: absolute; top: 14px; right: 12px; display: flex; gap: 6px; }
.t99-badge { font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--bg); border-radius: 999px; padding: 4px 10px; }
.t99-badge--up { color: var(--good); } .t99-badge--down { color: var(--warn); } .t99-badge--new { color: var(--gold); }

/* Overlay */
.t99-overlay { position: absolute; inset: 0; background: var(--panel, #1c1428); border-radius: 14px; padding: 16px; display: none; flex-direction: column; gap: 10px; overflow: auto; }
.t99-tile.is-open .t99-overlay { display: flex; }
.t99-overlay__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.t99-overlay__rank { font-size: 11px; letter-spacing: .16em; font-weight: 600; color: var(--gold); }
.t99-overlay__name { font: 600 17px/1.2 Cinzel, serif; color: var(--text); margin: 0; }
.t99-icon-btn { width: 32px; height: 32px; flex-shrink: 0; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.t99-icon-btn:hover { color: var(--text); border-color: var(--gold); }
.t99-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.t99-tag { font-size: 11px; font-weight: 600; color: var(--text); background: var(--raised); border-radius: 999px; padding: 3px 8px; }
.t99-pitch { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.t99-auto { font-size: 11px; color: var(--dim); }
.t99-meters { display: flex; flex-direction: column; gap: 6px; }
.t99-meter { display: flex; align-items: center; gap: 8px; }
.t99-meter__label { width: 78px; font-size: 12px; color: var(--muted); }
.t99-meter__bar { flex: 1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.t99-meter__bar span { height: 6px; border-radius: 2px; background: var(--line); }
.t99-meter__bar span.on { background: var(--gold); }
.t99-actions { margin-top: auto; display: flex; gap: 6px; }
.t99-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; text-align: center; min-height: 40px; padding: 10px 8px; border-radius: 999px; font-size: 13px; text-decoration: none; cursor: pointer; }
.t99-btn--gold { background: var(--gold); color: #1a1224; font-weight: 600; border: 0; }
.t99-btn--gold:hover { background: var(--gold-hi); color: #1a1224; }
.t99-btn--ghost { background: transparent; color: var(--text); font-weight: 500; border: 1px solid var(--line-2); }
.t99-btn--ghost:hover { border-color: var(--gold); color: var(--text); }

.t99-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--line-2); border-radius: 14px; }

.t99-more { display: flex; justify-content: center; margin-top: 32px; }
.t99-outline-btn { min-height: 44px; padding: 12px 24px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--gold); font-size: 14px; font-weight: 600; cursor: pointer; }
.t99-outline-btn:hover { border-color: var(--gold); }

.t99-footer { margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; text-align: center; display: flex; flex-direction: column; gap: 6px; }

/* Breakdown dialog */
.t99-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface-2); color: var(--text); }
.t99-dialog::backdrop { background: rgba(10, 6, 16, .75); }
.t99-dialog__art { position: relative; aspect-ratio: 16 / 7; background: var(--art-base, #2a1f3b); overflow: hidden; }
.t99-dialog__art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.t99-dialog__art .t99-icon-btn { position: absolute; top: 12px; right: 12px; background: var(--bg); width: 40px; height: 40px; }
.t99-dialog__credit { position: absolute; left: 12px; bottom: 10px; font-size: 11px; color: var(--text-2); background: rgba(23, 16, 31, .85); border-radius: 999px; padding: 3px 10px; }
.t99-dialog__content { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.t99-dialog__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.t99-dialog h2 { font: 600 28px/1.15 Cinzel, serif; margin: 4px 0 8px; }
.t99-dialog__type { color: var(--muted); font-size: 13px; }
.t99-label { font-size: 12px; letter-spacing: .12em; font-weight: 600; color: var(--gold); margin: 0 0 6px; }
.t99-label--good { color: var(--good); } .t99-label--warn { color: var(--warn); }
.t99-oracle { margin: 0; white-space: pre-line; font-size: 14px; color: var(--text-2); background: var(--panel, #1c1428); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.t99-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 560px) { .t99-two { grid-template-columns: 1fr; } }
.t99-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); }
.t99-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.t99-fact { background: var(--panel, #1c1428); border-radius: 10px; padding: 12px 14px; }
.t99-fact__k { font-size: 12px; color: var(--muted); }
.t99-fact__v { font-weight: 600; font-size: 15px; }
.t99-dialog__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.t99-dialog__actions .t99-btn { flex: 1 1 180px; min-height: 44px; font-size: 14px; }

/* Center the desktop hover view. Auto margins collapse when longer text needs scrolling. */
@media (min-width: 761px) and (hover: hover) and (pointer: fine) {
  .t99-overlay { text-align: center; }
  .t99-overlay > * { flex-shrink: 0; }
  .t99-overlay__head { position: relative; justify-content: center; padding-inline: 34px; margin-top: auto; }
  .t99-overlay__head .t99-icon-btn { position: absolute; top: 0; right: 0; }
  .t99-overlay .t99-tags { justify-content: center; }
  .t99-overlay .t99-meters { width: min(100%, 230px); align-self: center; text-align: left; }
  .t99-overlay .t99-actions { margin-top: 0; margin-bottom: auto; }
}

:root:not([data-theme=dark]) {
  --bg:#fbf6ed; --header:#fffaf1; --surface:#fffdf8; --surface-2:#f3ebe0;
  --surface-3:#efe2cd; --raised:#ffdea1; --line:#d8cbb9; --line-2:#ac9983;
  --gold:#79500c; --gold-hi:#624009; --text:#302638; --text-2:#493e50;
  --muted:#615466; --dim:#6e5f71; --good:#246340; --warn:#9b3e26;
  --panel:#fffaf2; --art-base:#e2d8cd;
}
:root:not([data-theme=dark]) :is(.t99-btn--gold,.t99-chip[aria-pressed=true]) { background:#ffd28b; color:#39273f; }
.t99-dialog__credit { color:#fff5e6; }
