/* Shop Street: a street of shops. The awning over the header is the one loud thing; everything else stays quiet. */
@font-face { font-family: "Bricolage"; src: url("/fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: light dark;
  --bg: #eef2ee; --card: #fff; --raised: #f5f8f5; --text: #17241f; --muted: #56675f; --line: #d6dfd8;
  --brand: #0f5a45; --brand-ink: #fff; --brand-hover: #0b4636; --tag: #ffcf33; --tag-ink: #2a2100;
  --link: #0d6b51; --bad: #b8341f; --good: #1b7a43; --warn: #915400; --series: #0d6b51;
  --display: "Bricolage", system-ui, sans-serif;
  --radius: 6px; --stripe: #f4f7f2; --shelf: #c3cfc6; --wash: 20%; --me: 22%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1714; --card: #15211d; --raised: #1b2a25; --text: #e4ede8; --muted: #9db0a7; --line: #2b3d36;
    --brand: #36b386; --brand-ink: #04140e; --brand-hover: #4cc89a;
    --stripe: #c9d6cf; --shelf: #07100d; --wash: 9%; --me: 11%; --link: #5fd0a6; --bad: #ff8a78; --good: #5ad78c; --warn: #f2b45c; --series: #5fd0a6;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; scrollbar-gutter: stable; scrollbar-color: color-mix(in srgb, var(--brand) 55%, var(--bg)) var(--bg); }
::selection { background: var(--tag); color: var(--tag-ink); }
input, textarea { caret-color: var(--brand); }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
a, button, input, select, summary, label { touch-action: manipulation; }
h1, h2, #stats dd, .tiles b, .estimate b { font-family: var(--display); }
h1, h2 { text-wrap: balance; }

/* Header: the shop sign under a striped awning */
.sign { background: var(--card); position: relative; z-index: 3; }
header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
#stats, #tabs { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; position: relative;
  padding: 12px max(16px, calc((100% - 1000px) / 2 + 16px)) 10px; background: #0f5a45; color: #fff; z-index: 1;
}
.bar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 16px;
  background: repeating-linear-gradient(90deg, #0f5a45 0 32px, var(--stripe) 32px 64px);
  -webkit-mask: radial-gradient(16px 16px at 16px 0, #000 99%, #0000) 0 0 / 32px 16px repeat-x;
          mask: radial-gradient(16px 16px at 16px 0, #000 99%, #0000) 0 0 / 32px 16px repeat-x;
}
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
.account { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.account #who { font-weight: 600; opacity: .9; }
.bar button.quiet { color: #fff; border-color: rgb(255 255 255 / .35); background: transparent; }
.bar button.quiet:hover { background: rgb(255 255 255 / .12); border-color: rgb(255 255 255 / .6); }
.bar :focus-visible { outline-color: #ffcf33; }

#stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 6px 18px; font-variant-numeric: tabular-nums; margin-top: 24px; }
#stats dt { color: var(--muted); font-size: 12px; }
#stats dd { margin: 0; font-weight: 700; font-size: 19px; line-height: 1.3; }
#stats > div:first-child dd { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
#stats { align-items: end; }
.sign:has(#street-strip:not([hidden])) + header #stats { margin-top: 12px; }
/* The street, as a live strip under the awning on every tab but My shop */
#street-strip { display: block; background: #8fcf75; border-bottom: 1px solid var(--line); cursor: pointer; }
#street-strip[hidden] { display: none; }
#street-strip:focus-visible { outline: 3px solid var(--tag); outline-offset: -3px; }
#street-strip #street canvas { display: block; }
progress { width: 100%; height: 5px; accent-color: var(--brand); display: block; }

#tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 6px; }
#tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; transition: color .15s, border-color .15s; }
#tabs a:hover { color: var(--text); border-color: var(--line); }
#tabs a[aria-current] { color: var(--text); border-color: var(--tag); }
#tabs .short { display: none; }
.badge { background: var(--tag); color: var(--tag-ink); border-radius: 99px; padding: 0 7px; font-size: 12px; font-weight: 800; }

main { max-width: 1000px; margin: 0 auto; padding: 18px 16px; }
header:has(#stats[hidden]) + #message + main { padding-top: 34px; }
.card { background: var(--card); border: 1px solid var(--line); border-bottom: 4px solid var(--shelf); border-radius: var(--radius) var(--radius) 3px 3px; padding: 16px; margin: 0 0 16px; }
h3 { font-family: var(--display); font-size: 16px; font-weight: 700; margin: 0; line-height: 1.3; }
.icon { width: 1.05em; height: 1.05em; vertical-align: -.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.facts { display: flex; flex-wrap: wrap; gap: 2px 16px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 10px; line-height: 1.3; }
small { color: var(--muted); font-weight: normal; font-size: 13px; font-family: system-ui, sans-serif; }
.help, .empty { color: var(--muted); }

/* Tables: numbers right-aligned so they compare at a glance */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
.r2 :is(th, td):nth-child(n+2), .r3 :is(th, td):nth-child(n+3) { text-align: right; }
td { overflow-wrap: anywhere; }
tr.me td { font-weight: 700; background: color-mix(in srgb, var(--tag) var(--me), transparent); }

/* Controls */
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--text); }
input:hover, select:hover { border-color: var(--muted); }
input[type="range"] { padding: 0; border: 0; background: none; accent-color: var(--brand); }
button { font: inherit; font-weight: 650; padding: 9px 16px; border: 1px solid var(--brand); border-radius: 8px; background: var(--brand); color: var(--brand-ink); cursor: pointer; transition: background-color .15s, border-color .15s; }
button:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
button:active:not(:disabled) { transform: translateY(1px); }
button.quiet { background: transparent; color: var(--link); border-color: var(--line); }
button.quiet:hover:not(:disabled) { background: var(--raised); border-color: var(--link); }
button.small { padding: 3px 10px; font-size: 13px; }
button:disabled { cursor: default; background: var(--raised); border-color: var(--line); color: var(--muted); }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
summary { cursor: pointer; color: var(--link); }
details { margin-top: 14px; }
details form { margin-top: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Sign-in */
#auth { max-width: 440px; margin: 8px auto 16px; }
#auth h2 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
#auth label { display: block; font-weight: 600; }
#auth input { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
#auth .hint { display: block; margin: 4px 0 14px; }
#recover-form label { margin-bottom: 12px; }
.steps { padding-left: 20px; margin: 0 0 18px; }
.steps li { margin-bottom: 6px; }
.steps li::marker { font-family: var(--display); font-weight: 700; color: var(--link); }

/* Next step: tagged with the price-tag yellow */
.advice { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; background: color-mix(in srgb, var(--tag) var(--wash), var(--card)); border-color: color-mix(in srgb, var(--tag) 70%, var(--line)); border-bottom-color: color-mix(in srgb, var(--tag) 70%, var(--shelf)); }
.advice h2 { margin: 0; }
.advice p { margin: 4px 0 0; color: color-mix(in srgb, var(--text) 78%, var(--tag)); }
.away, .rival { font-variant-numeric: tabular-nums; }
.rival { display: block; color: var(--text); text-decoration: none; }
.rival:hover { border-color: var(--link); }

/* Figures stand on their own: no box per number */
.figures { display: flex; flex-wrap: wrap; gap: 8px 40px; margin: 0 0 14px; }
.figures dt { font-size: 12px; color: var(--muted); }
.figures dd { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
#crowns li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
#crowns li:last-child { border-bottom: 0; }
#crowns li > b { font-weight: 600; color: var(--muted); }
#crowns li.held > b { color: var(--text); font-weight: 700; }
#crowns .icon { color: #c79a00; margin-right: 5px; }
.medal { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; font: 800 12px/1 var(--display); color: #2a2100; margin-left: 2px; vertical-align: 1px; }
.laurel { display: inline-grid; place-items: center; height: 19px; padding: 0 6px; border-radius: 4px; font: 800 12px/1 var(--display); color: #2a2100; margin-left: 4px; vertical-align: 1px; box-shadow: inset 0 -2px 0 rgb(0 0 0 / 18%); }
.laurel.m1 { background: #f2c230; } .laurel.m2 { background: #c5ccd1; } .laurel.m3 { background: #d99a63; }
.season-card h2 { margin-bottom: 6px; }
.season-card p { margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.season-card progress { height: 8px; margin-bottom: 4px; }
.season-card #season-card-next { margin: 8px 0 0; }
.tier { display: inline-grid; place-items: center; height: 19px; padding: 0 7px; border-radius: 4px; font: 800 12px/1 var(--display); color: #2a2100; vertical-align: 1px; box-shadow: inset 0 -2px 0 rgb(0 0 0 / 18%); }
.tier.t1 { background: #d99a63; } .tier.t2 { background: #c5ccd1; } .tier.t3 { background: #f2c230; } .tier.t4 { background: linear-gradient(135deg, #bfeee9, #8fd3e8 50%, #d9c8f5); }
#season-about { margin: -4px 0 8px; }
.season-name { display: flex; flex-direction: column; flex: none; }
.season-name small { color: var(--muted); }
.next-season { margin: 0 0 10px; padding: 6px 10px; border-left: 3px solid var(--tag); background: color-mix(in srgb, var(--tag) var(--wash), var(--card)); }
.medal.m1 { background: #f2c230; } .medal.m2 { background: #c5ccd1; } .medal.m3 { background: #d99a63; }

/* Products */
.product { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 10px 24px; }
.product h2 { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0; }
.product p { margin: 4px 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { font: 600 12px/1.6 system-ui, sans-serif; border-radius: 4px 99px 99px 4px; padding: 0 10px 0 8px; color: var(--muted); background: var(--raised); border: 1px solid var(--line); }
.chip.good { color: var(--good); border-color: currentColor; } .chip.warn { color: var(--warn); border-color: currentColor; } .chip.bad { color: var(--bad); border-color: currentColor; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.switch { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }
.price { display: flex; gap: 10px; align-items: center; }
.price input[type="range"] { flex: 1; min-width: 0; }
.price input[type="number"] { width: 110px; }
.suppliers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.page:focus { outline: none; }
.suppliers label { position: relative; cursor: pointer; }
.suppliers input { position: absolute; opacity: 0; }
.suppliers span { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; color: var(--muted); height: 100%; transition: border-color .15s; }
.suppliers label:hover span { border-color: var(--muted); }
.suppliers b { display: block; color: var(--text); font-size: 13px; }
.suppliers input:checked + span { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.suppliers input:focus-visible + span { outline: 3px solid var(--link); outline-offset: 2px; }
.stock input { width: 110px; }
.estimate { border-radius: 8px; background: var(--raised); padding: 10px 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.estimate b { font-size: 16px; }
.warning { color: var(--warn); font-size: 13px; margin: 0; }
.product.locked { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; color: var(--muted); background: transparent; border-style: dashed; border-bottom-width: 1px; }
.lock .icon { margin-right: 8px; }
.lock b { color: var(--text); margin-right: 4px; }

/* Demand charts */
figure { margin: 10px 0 0; }
figcaption { font-size: 13px; }
figcaption small { display: block; min-height: 20px; font-variant-numeric: tabular-nums; }
figure svg { display: block; width: 100%; height: 80px; overflow: visible; touch-action: pan-y; border-radius: 4px; }
figure path { fill: none; stroke: var(--series); stroke-width: 2; vector-effect: non-scaling-stroke; }
figure line { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
figure line.normal { stroke-dasharray: 4 4; opacity: .7; }
figure line.base { stroke: var(--line); }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Upgrades and staff */
/* Upgrades and staff read as a price list: one row each, price on the right */
.ledger .item { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 2.2fr) 210px; gap: 6px 24px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.ledger .item:first-child { border-top: 0; padding-top: 4px; }
.ledger .item:last-child { padding-bottom: 2px; }
.ledger .head small { display: block; }
.ledger p { margin: 0; color: var(--muted); }
.ledger .change { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger .row { margin-top: 8px; }
.deal { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; }
.deal button { grid-column: 1 / -1; }
.deal .tag { font: 700 17px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.deal .tag:empty { display: none; }
.item.hired { background: color-mix(in srgb, var(--good) 9%, transparent); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.item.hired h3::after { content: "Hired"; margin-left: 8px; font: 700 12px/1 system-ui, sans-serif; color: var(--good); text-transform: none; }
ul { list-style: none; margin: 0; padding: 0; }
li .line { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
#build-queue li { margin-bottom: 8px; }
.board td:nth-child(n+3) { white-space: nowrap; }
.board td.gap { text-align: center; color: var(--muted); padding: 2px; }
#news li, #champions li, #seasons li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
#news li small { white-space: nowrap; }
.rivals { font-size: 13px; color: var(--muted); }

/* Street */
#street-home #street { border-radius: 8px; overflow: hidden; min-height: 200px; background: #8fcf75; }
#street canvas { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.legend .s0 { background: #257de0; } .legend .s1 { background: #f47230; } .legend .s2 { background: #00b894; }

/* Toast and dialogs */
#message { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 10px; background: var(--card); border: 2px solid var(--bad); box-shadow: 0 6px 24px #0004; z-index: 3; }
#message.good { border-color: var(--good); }
dialog { max-width: 520px; width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 22px; }
dialog::backdrop { background: #000a; }
dialog h2 { font-size: 22px; }
#recovery code { font-size: 17px; user-select: all; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .product { grid-template-columns: minmax(0, 1fr); }
  .suppliers { grid-template-columns: minmax(0, 1fr); }
  .ledger .item { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  header { position: static; }
  #who { display: none; }
}

/* Phones: tabs become a bottom bar within thumb reach */
@media (max-width: 560px) {
  h1 { font-size: 20px; }
  .bar button.quiet { padding: 6px 12px; }
  #stats { grid-template-columns: repeat(3, 1fr); gap: 4px 10px; padding-bottom: 10px; }
  #stats dd, #stats > div:first-child dd { font-size: 17px; }
  #tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; margin: 0; padding: 0 0 env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; overflow: visible;
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .08);
  }
  #tabs a { padding: 12px 2px 11px; text-align: center; font-size: 12.5px; border-bottom: 0; border-top: 3px solid transparent; position: relative; }
  #tabs a[aria-current] { border-top-color: var(--tag); }
  #tabs .long { display: none; }
  #tabs .short { display: inline; }
  #tabs .badge { position: absolute; top: 3px; right: 6px; font-size: 11px; padding: 0 5px; }
  body:has(#tabs:not([hidden])) main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  body:has(#tabs:not([hidden])) #message { bottom: calc(70px + env(safe-area-inset-bottom)); }
}

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