/* Showdown Duel — developer console. Dense, dark, desktop-first; tables scroll sideways on a phone.
   Tokens come from shared/base.css; tooltips from shared/tip.css. */

:root {
  --top-h: 52px;
  --row-h: 48px;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}
body { font-size: 14px; }
.muted { color: var(--muted); }
.num, .tnum { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.btn:hover { background: #222a42; border-color: #34405f; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--panel); border-color: var(--line); }
.btn-primary { background: linear-gradient(180deg, #3fcbff, #1fa6e0); border-color: transparent; color: #04121c; }
.btn-primary:hover { background: linear-gradient(180deg, #5ad4ff, #2ab1ea); border-color: transparent; }
.btn-primary.is-dirty { box-shadow: 0 0 0 3px rgba(55, 198, 255, .28); }
.btn-danger { background: rgba(226, 59, 71, .14); border-color: rgba(226, 59, 71, .55); color: #ff8a92; }
.btn-danger:not(:disabled):hover { background: var(--neg); border-color: var(--neg); color: #fff; }

.input {
  height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line);
  background: #0e1322; color: var(--text); min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:hover { border-color: #34405f; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(55, 198, 255, .2); }
.setting .input:invalid:not(:focus) { border-color: var(--neg); }

:where(button, a, summary, [tabindex], input, label):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus-visible { outline: none; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-panel {
  width: min(340px, 100%); display: grid; gap: 12px; padding: 28px 24px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: rise var(--t-med) var(--ease-out);
}
.login-brand { display: grid; justify-items: center; gap: 2px; margin-bottom: 8px; }
.login-brand b { font-size: 20px; letter-spacing: .2px; }
.login-brand span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 2px; }
.login-panel .input, .login-panel .btn { height: 42px; width: 100%; }
.login-error { margin: 0; color: #ff7b85; font-size: 13px; text-align: center; }
.shake { animation: shake 360ms ease; border-color: var(--neg) !important; }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  background: rgba(10, 13, 26, .82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1440px; height: 100%; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; min-width: 0; overflow: hidden; }
.brand b { overflow: hidden; text-overflow: ellipsis; }
.brand b { font-size: 15.5px; }
.brand-sep { color: var(--muted); }
.brand-version { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex: none; }
.updated { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-right: 8px; white-space: nowrap; transition: color var(--t-med); }
.updated::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pos); margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 0 0 rgba(34, 181, 95, .6); animation: live 2.4s ease-out infinite; }
.updated.stale { color: var(--warn); }
.updated.stale::before { background: var(--warn); animation: none; }
.updated.offline { color: #ff7b85; }
.updated.offline::before { background: var(--neg); animation: none; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(34, 181, 95, .55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(34, 181, 95, 0); } }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1440px; margin: 0 auto; padding: 16px 16px 48px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto 1fr; gap: 16px; align-items: start; }
/* Desktop: the cards column spans both rows; Classes sits above the settings in the side column. */
.col-main { grid-column: 1; grid-row: 1 / span 2; }
.classes-panel { grid-column: 2; grid-row: 1; }
.col-side { grid-column: 2; grid-row: 2; }
.col-main, .col-side { display: grid; gap: 16px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 10px; padding: 0 14px 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile {
  position: relative; overflow: hidden; padding: 12px 14px 13px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line);
  transition: border-color var(--t-fast), transform var(--t-fast);
  animation: rise var(--t-med) var(--ease-out) both;
}
.tile:hover, .tile:focus-visible { border-color: #3a4870; transform: translateY(-1px); }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; }
.tile-value { margin-top: 4px; font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.3px; line-height: 1.15; }
.tile-value small { font-size: 15px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.tile.bump .tile-value { animation: bump 600ms var(--ease-out); }
.tile.warn .tile-value { color: var(--warn); }
@keyframes bump { 30% { color: var(--accent); } }

/* ---------------------------------------------------------------- storage line */
.storage-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 2px 16px; font-size: 12.5px; }
.storage-status { font-variant-numeric: tabular-nums; }
.storage-status.ok { color: #4fd487; }
.storage-status.bad { color: #ff7b85; font-weight: 600; }
.smoke-result.ok { color: #4fd487; }
.smoke-result.bad { color: #ff7b85; font-weight: 600; }
.smoke-result { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- tables */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { width: 180px; height: 30px; }
.pill {
  height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 600; transition: all var(--t-fast);
}
.pill:hover { color: var(--text); border-color: #34405f; }
.pill[aria-pressed="true"] { color: #04121c; background: var(--pos); border-color: var(--pos); }

.table-wrap { border-top: 1px solid var(--line); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.grid th {
  position: sticky; top: var(--top-h); z-index: 2; background: #161c2e; color: var(--muted);
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; text-align: left;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid th.num { text-align: right; }
.grid th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; }
.grid th button:hover { color: var(--text); }
.grid th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid th[aria-sort] { color: var(--text); }
.grid th[aria-sort] button::after { content: "▼"; font-size: 8px; color: var(--accent); }
.grid th[aria-sort="ascending"] button::after { content: "▲"; }
.grid td { padding: 0 10px; height: 38px; border-bottom: 1px solid rgba(38, 48, 73, .6); white-space: nowrap; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tbody tr { transition: background var(--t-fast), opacity var(--t-med); }
.grid tbody tr:hover { background: rgba(55, 198, 255, .06); }
.grid tbody tr:last-child td { border-bottom: 0; }

/* cards table */
.cards-table td { height: var(--row-h); }
.cards-table tr.dim > td { opacity: .55; }
.cards-table tr.dim:hover > td { opacity: .8; }
.col-rank { width: 44px; }
.rank { color: var(--muted); font-weight: 600; }
.card-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.thumb { width: 28px; height: 40px; border-radius: 4px; object-fit: cover; background: var(--panel-2); flex: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.card-name { font-weight: 600; }
.cls { display: inline-flex; align-items: center; gap: 7px; }
.pip { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--pip, var(--muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pip, var(--muted)) 22%, transparent); }
.elo { font-weight: 750; font-size: 14px; transition: color 1.2s; }
.elo.up { color: #4fd487; transition: none; }
.elo.down { color: #ff7b85; transition: none; }
.wl .w { color: #8fe0ad; }
.wl .l { color: #ff9aa2; }
.wl .sep { color: var(--muted); margin: 0 1px; }
.rel-yes { color: #4fd487; font-weight: 800; font-size: 15px; }
.rel-no { color: var(--muted); font-size: 12.5px; }
.col-rel { width: 90px; }

/* the leader: the best reliable card gets a slow foil sweep on its name and a gold rank */
.cards-table tr.leader > td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.cards-table tr.leader .rank { color: var(--gold); }
.cards-table tr.leader .card-name {
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 38%, #fff3cf 47%, var(--gold) 52%, #fff3cf 57%, var(--text) 66%, var(--text) 100%);
  background-size: 260% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: foil 5.5s linear infinite;
}
.cards-table tr.leader .thumb { box-shadow: 0 0 0 1px rgba(242, 182, 61, .7), 0 2px 10px rgba(242, 182, 61, .35); }
@keyframes foil { from { background-position: 100% 0; } to { background-position: -160% 0; } }
.cards-table tr.pulse > td { animation: pulse 1.4s ease-out; }
@keyframes pulse { 0% { background: rgba(242, 182, 61, .28); } 100% { background: transparent; } }

/* voters */
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 12.5px; }
.collapsible > summary { list-style: none; cursor: pointer; user-select: none; border-radius: var(--radius); }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary:hover h2 { color: #fff; }
.chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); transition: transform var(--t-med); }
.collapsible[open] .chev { transform: rotate(-135deg) translate(-2px, -2px); }
.collapsible[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

/* ---------------------------------------------------------------- classes */
.class-list { list-style: none; margin: 0; padding: 4px 6px 8px; border-top: 1px solid var(--line); }
.class-row {
  display: grid; grid-template-columns: 18px 28px minmax(0, 1fr) auto 78px; align-items: center; gap: 10px;
  padding: 5px 8px; border-radius: 9px; transition: background var(--t-fast);
}
.class-row:hover, .class-row:focus-visible { background: var(--panel-2); }
.class-rank { color: var(--muted); font-weight: 600; font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.class-row:first-child .class-rank { color: var(--gold); }
.class-glyph { width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--cls) 35%, transparent)); }
.class-name { color: var(--cls); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-score { font-weight: 750; font-size: 14.5px; font-variant-numeric: tabular-nums; text-align: right; }
.class-games { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------------- settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 0 14px; }
.setting { display: grid; gap: 4px; padding: 6px 8px 8px; border-radius: 9px; transition: background var(--t-fast); }
.setting:hover, .setting:focus-within { background: var(--panel-2); }
.setting > span { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.setting > span em { font-style: normal; font-weight: 500; opacity: .75; }
.setting .input { width: 100%; height: 32px; font-variant-numeric: tabular-nums; }
.setting.changed > span { color: var(--accent); }
.setting.over > span { color: var(--warn); }
.setting.over .input { border-color: var(--warn); }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px 14px; }
.form-msg { margin: 0; font-size: 12.5px; min-height: 0; transition: opacity 600ms; overflow-wrap: anywhere; }
.form-msg:empty { display: none; }
.form-msg.ok { color: #4fd487; }
.form-msg.bad { color: #ff7b85; font-weight: 600; }
.form-msg.fade { opacity: 0; }

/* ---------------------------------------------------------------- backups / danger */
.restore-confirm { padding: 8px 10px; border-radius: 9px; background: rgba(226, 59, 71, .08); border: 1px dashed rgba(226, 59, 71, .45); font-size: 13px; }
.danger { margin: 0 14px 14px; padding: 12px; border-radius: 10px; border: 1px solid rgba(226, 59, 71, .35); background: rgba(226, 59, 71, .05); display: grid; gap: 8px; }
.danger-label { color: #ff8a92; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; width: max-content; cursor: help; }
.danger .input { flex: 1 1 120px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .5px; }

/* ---------------------------------------------------------------- diagnostics */
.log {
  list-style: none; margin: 0; padding: 6px 0; max-height: 240px; overflow: auto; border-top: 1px solid var(--line);
  font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 12px; line-height: 1.5;
}
.log li { display: grid; grid-template-columns: max-content 1fr; gap: 10px; padding: 2px 14px; }
.log li:hover { background: rgba(255, 255, 255, .03); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log span { overflow-wrap: anywhere; }
.log li.err span { color: #ff8a92; }
.log li.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: rgba(55, 198, 255, .14); } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .col-main, .classes-panel, .col-side { grid-column: 1; grid-row: auto; }
  .col-side { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
}
@media (max-width: 760px) {
  /* Tables scroll sideways inside their panel; the header then sticks only within the wrapper. */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .grid th { position: static; }
  .brand > span:not(.brand-version), .brand-sep { display: none; }
  .updated { margin-right: 2px; }
  .topbar-right .btn { padding: 0 9px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile-value { font-size: 22px; }
  .search { width: 130px; }
  .col-side { grid-template-columns: minmax(0, 1fr); }
  .settings-grid { gap: 6px; }
  .btn { height: 38px; }
}
@media (max-width: 480px) {
  .updated { font-size: 11.5px; }
  .updated .word, .hide-xs { display: none; }
  .brand-version { display: none; }
  .brand b { font-size: 14.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .cards-table tr.leader .card-name { animation: none; background-position: 40% 0; }
}
