/* Punch Throttle's control panel. Numbers first: the game's loud look stays in the header; below it everything is quiet
   so that what needs attention stands out. Colours of the series are checked for colour-blind readers in both themes
   (orange, teal, violet, pink, in this order). */
@font-face { font-family: Bungee; src: url(fonts/Bungee.ttf); font-display: swap; }
@font-face { font-family: Rubik; src: url(fonts/Rubik.ttf); font-weight: 300 900; font-display: swap; }

:root {
  color-scheme: light;
  --page: #f6f1ea; --card: #ffffff; --sunk: #f3eef7; --line: #e6dfec; --axis: #cfc5d8;
  --ink: #21102f; --ink2: #64566f; --ink3: #8a7d94;
  --s1: #d96c00; --s2: #0e8f86; --s3: #7a55e0; --s4: #d93a66; --rest: #cbc1d4;
  --wash: #f1ecfb; --heat: 122, 85, 224;
  --good: #16803c; --warn: #9a6200; --bad: #c22b3a;
  --good-bg: #e6f5ea; --warn-bg: #fdf1d8; --bad-bg: #fde8ea;
  --head: #1b0c2a; --shadow: 0 1px 2px rgba(33, 16, 47, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #140820; --card: #211030; --sunk: #2b1840; --line: #382550; --axis: #513c6b;
    --ink: #f4eef9; --ink2: #b9a9c8; --ink3: #8f7da1;
    --s1: #e07b1a; --s2: #17a398; --s3: #9a7bf0; --s4: #e8507a; --rest: #4d3a63;
    --wash: #2f1c48; --heat: 154, 123, 240;
    --good: #5fd184; --warn: #ffc64d; --bad: #ff8088;
    --good-bg: #17372a; --warn-bg: #3d2c12; --bad-bg: #45192a;
    --head: #0e0518; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #140820; --card: #211030; --sunk: #2b1840; --line: #382550; --axis: #513c6b;
  --ink: #f4eef9; --ink2: #b9a9c8; --ink3: #8f7da1;
  --s1: #e07b1a; --s2: #17a398; --s3: #9a7bf0; --s4: #e8507a; --rest: #4d3a63;
  --wash: #2f1c48; --heat: 154, 123, 240;
  --good: #5fd184; --warn: #ffc64d; --bad: #ff8088;
  --good-bg: #17372a; --warn-bg: #3d2c12; --bad-bg: #45192a;
  --head: #0e0518; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15px/1.45 Rubik, system-ui, sans-serif; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--s3); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, p { margin: 0; }
button, select, input { font: inherit; color: inherit; }

/* header */
.top { background: var(--head); color: #f4eef9; position: sticky; top: 0; z-index: 5; }
.top::after { content: ""; display: block; height: 4px; background: linear-gradient(90deg, #ffd23f, #ff9f1c 45%, #ff4d6d); }
.bar { display: flex; align-items: center; gap: 12px; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 6px; }
.mark { display: grid; text-decoration: none; font: 400 17px/.98 Bungee, Rubik, sans-serif; letter-spacing: .01em; }
.mark span:first-child { color: #ffd23f; }
.status { margin-left: auto; font-size: 13px; color: #b9a9c8; text-align: right; min-width: 0; }
.status b { font-weight: 600; color: #f4eef9; }
.plain { background: #2f1c48; color: #f4eef9; border: 0; border-radius: 8px; padding: 8px 12px; min-height: 36px; cursor: pointer; }
.plain:hover { background: #3f285e; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 9px 12px 10px; text-decoration: none; color: #b9a9c8; font-weight: 500; border-bottom: 3px solid transparent; }
.tabs a:hover { color: #fff; }
.tabs a[aria-current] { color: #fff; border-color: #ffd23f; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 16px 0 14px; }
.seg { display: inline-flex; background: var(--sunk); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 6px 11px; min-height: 34px; color: var(--ink2); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
select, input[type="search"], input[type="password"], input[type="text"] { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; min-height: 40px; }
input[type="search"] { min-width: 0; width: 240px; max-width: 100%; }

@media (max-width: 560px) {
  .bar { flex-wrap: wrap; row-gap: 2px; } #reload { margin-left: auto; } .plain { padding: 8px 10px; }
  .bar .status { order: 1; flex-basis: 100%; margin-left: 0; text-align: left; } .status br { display: none; } .status b::after { content: " · "; }
  .seg { display: flex; width: 100%; } .seg button { flex: auto; padding: 6px 3px; font-size: 14px; }
  .filters select { flex: 1; min-width: 0; } .filters input { width: 100%; }
}

/* cards */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); padding-bottom: 40px; transition: opacity .15s; }
.grid.old { opacity: .5; }
.card { grid-column: span 12; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); min-width: 0; align-self: start; }
@media (min-width: 900px) { .w3 { grid-column: span 3; } .w4 { grid-column: span 4; } .w5 { grid-column: span 5; } .w6 { grid-column: span 6; } .w7 { grid-column: span 7; } .w8 { grid-column: span 8; } }
.card > header { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.card h2 { font-size: 16px; font-weight: 600; line-height: 1.3; }
.card header p { color: var(--ink2); font-size: 13.5px; margin-top: 2px; max-width: 70ch; }
.card header .grow { flex: 1; min-width: 0; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--ink2); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.link:hover { color: var(--ink); }
.none { color: var(--ink2); padding: 18px 0; }
.note { color: var(--ink2); font-size: 13.5px; margin-top: 10px; max-width: 75ch; }

/* numbers */
.tiles { grid-column: span 12; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--card); padding: 14px 16px 13px; min-width: 0; }
.tile .k { color: var(--ink2); font-size: 13.5px; }
.tile .v { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.tile .v small { font-size: 15px; font-weight: 500; color: var(--ink2); }
.tile .d { font-size: 13px; color: var(--ink2); margin-top: 2px; }
.up { color: var(--good); font-weight: 600; } .down { color: var(--bad); font-weight: 600; }

/* what to look at */
.advice { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.advice li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 4px 14px; padding: 13px 0; border-top: 1px solid var(--line); }
.advice li:first-child { border-top: 0; padding-top: 2px; }
.advice .tag { align-self: start; justify-self: start; font-size: 12.5px; font-weight: 600; border-radius: 6px; padding: 3px 8px; }
.tag.bad { background: var(--bad-bg); color: var(--bad); } .tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.good { background: var(--good-bg); color: var(--good); } .tag.info { background: var(--sunk); color: var(--ink2); }
.advice h3 { font-size: 15px; font-weight: 600; }
.advice p { color: var(--ink2); margin-top: 2px; max-width: 78ch; }
.advice p + p { color: var(--ink); }
@media (max-width: 560px) { .advice li { grid-template-columns: minmax(0, 1fr); } }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.chart text { font: 400 12px Rubik, sans-serif; fill: var(--ink2); font-variant-numeric: tabular-nums; }
.chart text.on { fill: var(--ink); font-weight: 600; }
.grid-line { stroke: var(--line); } .base-line { stroke: var(--axis); } .cross { stroke: var(--ink3); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; } .legend i.line { height: 3px; width: 16px; border-radius: 2px; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--head); color: #f4eef9; border-radius: 10px; padding: 9px 12px; font-size: 13px; max-width: 280px; box-shadow: 0 6px 24px rgba(14, 5, 24, .35); left: 0; top: 0; }
.tip .t { color: #b9a9c8; margin-bottom: 3px; }
.tip div.r { display: flex; align-items: center; gap: 7px; } .tip b { font-weight: 600; }
.tip i { width: 14px; height: 3px; border-radius: 2px; flex: none; }

/* bars in rows */
/* (subgrid: every bar has the same room, so their lengths compare) */
.rows { display: grid; grid-template-columns: minmax(96px, 30%) minmax(0, 1fr) auto; gap: 9px 12px; margin: 0; padding: 0; list-style: none; }
.rows li { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; row-gap: 4px; align-items: center; }
.rows .n { overflow-wrap: anywhere; line-height: 1.25; }
.rows .b { height: 14px; border-radius: 0 4px 4px 0; background: var(--s3); min-width: 2px; }
.rows .b.o { background: var(--s1); } .rows .b.t { background: var(--s2); } .rows .b.r { background: var(--rest); }
.rows .f { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rows .f small { color: var(--ink2); font-size: 13px; }
.rows .sub { grid-column: 2 / -1; color: var(--ink2); font-size: 13px; margin-top: -3px; }
.rows .sub.bad { color: var(--bad); }
@media (max-width: 560px) { .rows { grid-template-columns: minmax(0, 1fr) auto; } .rows .track { grid-row: 2; grid-column: 1 / -1; } .rows .sub { grid-column: 1 / -1; } }

/* tables */
.scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--ink2); font-size: 13px; padding: 4px 10px 7px 0; border-bottom: 1px solid var(--axis); vertical-align: bottom; }
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.go { cursor: pointer; } tr.go:hover td { background: var(--wash); }
td a { text-underline-offset: 3px; }
td.heat { text-align: center; font-variant-numeric: tabular-nums; border-bottom: 2px solid var(--card); border-right: 2px solid var(--card); border-radius: 6px; padding: 8px 4px; min-width: 46px; }
td.nowrap { white-space: nowrap; }
th.mid { text-align: center; }
td .soft { color: var(--ink2); font-size: 13px; display: block; }
code { font: 13px ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }

/* one player */
.stars { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; max-width: 520px; }
.stars i { aspect-ratio: 1; border-radius: 4px; background: var(--sunk); display: grid; place-items: center; font: 500 11px Rubik; color: var(--ink2); }
.stars i.s1 { background: rgba(var(--heat), .3); } .stars i.s2 { background: rgba(var(--heat), .6); color: var(--ink); } .stars i.s3 { background: rgb(var(--heat)); color: #fff; }
.story { margin: 0; padding: 0; list-style: none; }
.story li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 5px 0; }
.story time { color: var(--ink2); font-variant-numeric: tabular-nums; }
.story .day { display: block; font-weight: 600; padding: 14px 0 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.story .soft { color: var(--ink2); }

/* typing in expenses */
.doing { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.do { background: #ffd23f; color: #1b0c2a; border: 0; border-radius: 10px; min-height: 42px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
.do.second { background: var(--sunk); color: var(--ink); font-weight: 500; }
.do:disabled { opacity: .5; cursor: default; }
.entry { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); align-items: end; }
.entry label { display: grid; gap: 4px; min-width: 0; } .entry label[hidden] { display: none; }
.entry label > span:first-child { font-size: 13px; color: var(--ink2); }
.entry input, .entry select { width: 100%; min-width: 0; }
.entry .pair { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 6px; }
.entry .doing { grid-column: 1 / -1; margin: 2px 0 0; }
.entry .err { color: var(--bad); }
.tools { display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.told { display: grid; gap: 6px; color: var(--ink2); max-width: 90ch; } .told b { color: var(--ink); font-weight: 600; }

/* the door */
.door { max-width: 340px; margin: 14vh auto; display: grid; gap: 12px; }
.door button { background: #ffd23f; color: #1b0c2a; border: 0; border-radius: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.door .err { color: var(--bad); min-height: 1.4em; }
.door .note { margin: 0; }
.door button.plain { background: none; color: inherit; border: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
