:root {
    color-scheme: light;
    --surface: #fffdf8; --field: #eceeea; --cream: #f4f3ed; --fg: #202d3b;
    --muted: #556372; --line: #b7c0c5; --link: #175c9d; --blue: #2463a8;
    --red: #b84135; --gold: #85600f; --success: #26643e;
    --ink: #182531; --paper: var(--surface); --shadow: 0 3px 12px #15263708;
}
html[data-theme="dark"] {
    color-scheme: dark;
    --surface: #19232d; --field: #101a23; --cream: #0c141c; --fg: #ecf1f4;
    --muted: #a7b7c4; --line: #435463; --link: #99cbff; --red: #ffa497;
    --gold: #f2cb76; --success: #97ddb0; --shadow: 0 3px 12px #0002;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 140px; }
body { margin: 0; color: var(--fg) !important; background: var(--cream); font-family: 'Chakra Petch', system-ui, sans-serif; line-height: 1.6; background-image: linear-gradient(#7b8b9b06 1px, transparent 1px), linear-gradient(90deg, #7b8b9b06 1px, transparent 1px); background-size: 32px 32px; }
header { background: var(--ink) !important; border-color: #435463 !important; box-shadow: 0 2px 12px #0002; }
header .text-white { color: #f6f8fa !important; }
header a, header button { background: transparent !important; color: #dce7ef !important; border: 1px solid #435463 !important; border-radius: 5px; box-shadow: none; white-space: nowrap; }
header a:hover, header button:hover { background: #294052 !important; border-color: #8cb9df !important; }
header h1 { font-family: 'Press Start 2P', monospace; font-size: .75rem !important; line-height: 1.8 !important; }
header nav { flex-wrap: wrap; }
main { max-width: 1180px; }
main > section { scroll-margin-top: 12px; }
main h2 { color: var(--fg) !important; letter-spacing: -.025em; text-shadow: none; }
main .bg-retro-card { background: var(--surface) !important; border-color: var(--line) !important; box-shadow: var(--shadow); border-radius: 6px; }
main .bg-retro-base, main [class*="bg-retro-card/"] { background: var(--field) !important; }
main .text-white, main .text-slate-200, main .text-slate-300 { color: var(--fg) !important; }
main .text-slate-400, main .text-slate-500, main .text-slate-600 { color: var(--muted) !important; }
main .text-retro-cyber { color: var(--link) !important; }
main .text-retro-accent { color: var(--red) !important; }
main .text-retro-gold { color: var(--gold) !important; }
main .text-green-400, main .text-green-700 { color: var(--success) !important; }
main .border-retro-border, main .border-slate-800 { border-color: var(--line) !important; }
main input, main select, main textarea { max-width: 100%; background: var(--field) !important; color: var(--fg) !important; border: 1px solid var(--line) !important; border-radius: 4px; min-height: 44px; font: inherit; }
main input::placeholder, main textarea::placeholder { color: var(--muted); opacity: 1; }
main input[type="hidden"] { display: none; }
main input[type="file"] { min-height: 44px; width: 100%; font-size: 12px; }
main button, main .forum-action { min-height: 44px; border-radius: 4px; }
main button.bg-retro-cyber { background: var(--blue); color: #fff !important; }
main button.bg-retro-accent { background: #ae3d32; color: #fff !important; }
.bg-green-950\/40 { background: #dcebdc !important; color: #235333 !important; }
.bg-yellow-950\/40 { background: #f3e7c5 !important; color: #72540a !important; }
.bg-rose-950\/40 { background: #f2d9d3 !important; color: #8d3028 !important; }
footer { background: var(--ink) !important; color: #b7c6d2; border-color: #435463 !important; }
footer .text-slate-300 { color: #edf2f6 !important; }
footer .text-slate-500 { color: #b7c6d2 !important; }
.skip-link { position: fixed; left: 12px; top: -100px; z-index: 100; padding: 12px 18px; color: #fff; background: #175c9d; }
.skip-link:focus { top: 12px; }
.market-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 12px 0 28px; border-bottom: 1px solid var(--line); }
.eyebrow { font: 700 11px 'JetBrains Mono', monospace; letter-spacing: .16em; color: var(--link); }
.market-intro h2 { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 700; line-height: 1.12; margin: 12px 0; }
.market-intro p:last-child { max-width: 54ch; font-size: 14px; color: var(--muted); }
.intro-action { display: inline-flex; gap: 24px; padding: 12px 16px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 4px; color: var(--link); font-weight: 700; }
#main-page > div:first-child { align-items: start; flex-direction: column; }
#main-page > div:first-child > div:last-child { width: 100%; gap: 6px; }
#searchInput { margin-left: auto; width: min(100%, 320px); }
#valuesGrid { gap: 14px; }
.cat-btn[aria-pressed="true"], .cat-btn[aria-pressed="true"]:hover, .sort-btn[aria-pressed="true"], .sort-btn[aria-pressed="true"]:hover { background: var(--blue) !important; border-color: var(--blue) !important; color: #fff !important; box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); }
html[data-theme="dark"] .cat-btn[aria-pressed="true"], html[data-theme="dark"] .cat-btn[aria-pressed="true"]:hover, html[data-theme="dark"] .sort-btn[aria-pressed="true"], html[data-theme="dark"] .sort-btn[aria-pressed="true"]:hover { background: #8dc5ff !important; border-color: #8dc5ff !important; color: #101720 !important; }
.trade-chip { display: inline-flex; align-items: center; max-width: 100%; gap: 8px; border-radius: 4px; }
.trade-chip > span { overflow-wrap: anywhere; }
.trade-chip button { min-height: 32px; min-width: 32px; line-height: 1; padding: 0 6px; border: 1px solid currentColor; font-weight: 800; }
:focus-visible { outline: 3px solid #f4cc75; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: wait; }
#notifications { position: fixed; right: 16px; bottom: 16px; width: min(360px, calc(100% - 32px)); z-index: 60; display: grid; gap: 8px; }
.notice { background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-left: 4px solid var(--link); border-radius: 4px; padding: 14px; box-shadow: var(--shadow); font-size: 13px; }
#activityLog { max-height: 420px; overflow: auto; }
#activityLog details { border-bottom: 1px solid var(--line); padding: 12px 0; overflow-wrap: anywhere; }
#activityLog pre { white-space: pre-wrap; font-size: 11px; padding: 8px; }
@media (max-width: 640px) {
    header .max-w-7xl { height: auto; padding-top: 12px; padding-bottom: 12px; align-items: flex-start; gap: 12px; flex-direction: column; }
    header nav { width: 100%; padding-bottom: 3px; }
    header nav a { white-space: nowrap; }
}

/* ---- Site logo ---- */
header > .max-w-7xl { max-width: none; padding-left: 8px; padding-right: 16px; gap: 16px; height: auto; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
header > .max-w-7xl > .flex { min-width: 0; max-width: 100%; }
#siteLogo.has-logo { flex-shrink: 0; overflow: visible; }
.has-logo { width: auto; max-width: min(20rem, 40vw); height: 5rem; border: 0 !important; background: transparent !important; transform: none !important; }
.has-logo img { height: 100%; width: auto; max-width: 100%; object-fit: contain; display: block; }
@media (max-width: 640px) {
    .has-logo { height: 4rem; max-width: 35vw; }
    header > .max-w-7xl > .flex > div:last-child { min-width: 0; overflow-wrap: anywhere; }
}

/* ---- Forum lists, server pages and staff publishing ---- */
.forum-page { width: min(100%, 860px); margin-inline: auto; padding: 24px 16px; }
.forum-page { box-sizing: border-box; font-family: 'Chakra Petch', sans-serif; }
.forum-page > nav { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.forum-page h1 { font-family: 'Chakra Petch', sans-serif; font-size: clamp(1.5rem, 5vw, 2.25rem) !important; overflow-wrap: anywhere; }
.forum-page h2 { margin: 0; font-size: 1.25rem; }
.forum-page .forum-feed { display: grid; gap: 16px; margin: 24px 0; }
.forum-page a.forum-card { text-decoration: none; }
.forum-list { display: grid; gap: 12px; }
.forum-card, .forum-post { min-width: 0; padding: 20px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.forum-card { display: grid; gap: 8px; }
.forum-card h3, .forum-post h1, .forum-post h2 { font-family: 'Chakra Petch', sans-serif; font-weight: 700; }
.forum-card h3 { font-size: 1.125rem; line-height: 1.4; }
.forum-card p { font-size: .875rem; line-height: 1.6; }
.forum-meta, .forum-card .forum-meta { color: var(--muted); font: .75rem/1.6 'JetBrains Mono', monospace; overflow-wrap: anywhere; }
.forum-link, .forum-page a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.forum-link:hover, .forum-page a:hover { text-decoration-thickness: 2px; }
.forum-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9375rem; line-height: 1.8; margin-top: 16px; }
.forum-action { padding: 8px 12px; border: 1px solid var(--line); background: var(--surface); color: var(--link); font: 700 .75rem 'JetBrains Mono', monospace; }
.forum-publish { display: grid; gap: 12px; }
.forum-publish textarea { resize: vertical; min-height: 160px; }

/* ---- Anonymous feedback and staff inbox ---- */
.feedback-panel { min-width: 0; display: grid; gap: 16px; padding: 24px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.feedback-panel[hidden], .feedback-honeypot { display: none !important; }
.feedback-form, .feedback-list { display: grid; gap: 12px; min-width: 0; }
.feedback-form textarea { box-sizing: border-box; width: 100%; min-height: 140px; padding: 12px; resize: vertical; font-size: 1rem; }
.feedback-form > button { justify-self: start; }
.feedback-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.feedback-card { min-width: 0; padding: 16px; background: var(--field); border: 1px solid var(--line); overflow-wrap: anywhere; }
.feedback-card h4 { font-weight: 700; margin-bottom: 4px; }
.feedback-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9375rem; line-height: 1.7; margin-top: 12px; }
.feedback-panel button:disabled { cursor: not-allowed; }
#feedback { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); align-items: start; gap: 32px; padding: 28px; }
.feedback-intro { display: grid; gap: 12px; }
.feedback-intro h2 { line-height: 1.2; }
.feedback-intro .forum-meta { max-width: 42ch; font-family: inherit; font-size: 14px; }
.feedback-privacy { justify-self: start; color: var(--link); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-size: 11px; }
#feedbackForm { padding: 20px; border: 1px solid var(--line); border-radius: 6px; background: var(--field); }
#feedbackMessage { background: var(--surface) !important; min-height: 160px; line-height: 1.65; }
#feedbackSubmit { background: var(--blue); color: #fff; width: 100%; padding: 12px 16px; }
#feedbackChallenge { min-width: 0; max-width: 100%; }
#feedbackStatus { min-height: 2.8em; }

/* ---- Compact values cards ---- */
.value-card { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.value-card { padding: 16px; align-items: start; }
.value-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--link) !important; }
.value-card h3 { line-height: 1.4; overflow-wrap: anywhere; }
.value-card .card-img { border-color: var(--line); border-radius: 4px; padding: 4px; }
.value-card .card-img img { width: 100%; height: 100%; object-fit: contain; }
.value-card .card-img img { transition: transform .25s ease; }
.value-card:hover .card-img img { transform: scale(1.07); }

/* ---- Calculator "+" trigger ---- */
.add-tower-btn { width: 40px; height: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; font: 800 22px/1 'JetBrains Mono', monospace; color: var(--link); background: transparent; border: 2px dashed var(--line); box-shadow: none; transition: background-color .18s ease, color .18s ease, border-color .18s ease, transform .18s ease; }
main .add-tower-btn:hover:not(:disabled) { background: var(--blue); border-color: var(--blue); border-style: solid; color: #fff; transform: scale(1.08) rotate(90deg); box-shadow: none; }
html[data-theme="dark"] main .add-tower-btn:hover:not(:disabled) { background: #8dc5ff; border-color: #8dc5ff; color: #101720; }

/* ---- Tower picker dialog ---- */
dialog.picker { padding: 0; margin: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); width: min(820px, calc(100% - 24px)); max-height: min(86dvh, 800px); box-shadow: 0 24px 80px #0006; }
dialog.picker[open] { display: flex; animation: picker-in .38s cubic-bezier(.22, 1.4, .4, 1); }
dialog.picker::backdrop { background: rgba(10,16,24,.62); animation: fade-in .2s ease-out; }
html:has(dialog[open]) { overflow: hidden; }
.picker-panel { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.picker-head, .picker-tools, .picker-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.picker-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.picker-tools { flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.picker-foot { justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--line); }
.picker-x { width: 34px; font-size: 20px; line-height: 1; background: transparent; border: 1px solid var(--line); color: var(--fg); }
.picker-list { flex: 1; min-height: 160px; overflow-y: auto; padding: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-content: start; }
.pick-heading { grid-column: 1 / -1; font: 800 11px 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 4px 2px; }
.pick-row { position: relative; display: flex; flex-direction: column; justify-content: space-between; align-items: center; gap: 8px; width: 100%; aspect-ratio: 1; min-height: 0; padding: 14px 10px 10px; text-align: center; color: var(--fg); background: var(--field); border: 1px solid var(--line); border-radius: 8px; box-shadow: none; transition: background-color .18s ease, border-color .18s ease, transform .3s cubic-bezier(.22, 1.6, .4, 1), box-shadow .18s ease; }
.pick-row:hover { background: var(--surface); border-color: var(--link); transform: translateY(-4px) scale(1.025); }
.pick-row:active { transform: scale(.94); }
.pick-row[aria-pressed="true"] { border-color: var(--link); background: color-mix(in srgb, var(--link) 14%, var(--field)); box-shadow: inset 0 0 0 1px var(--link); animation: pick-bounce .38s ease-out; }
.pick-check { position: absolute; top: 8px; right: 8px; z-index: 1; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: transparent; border: 2px solid var(--line); transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.pick-row[aria-pressed="true"] .pick-check { background: var(--link); border-color: var(--link); color: var(--surface); }
.pick-thumb { width: 100%; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(32px, 6vw, 64px); overflow: hidden; }
.pick-thumb img { width: 100%; height: 100%; max-height: 130px; object-fit: contain; }
.pick-main { display: grid; gap: 3px; width: 100%; min-width: 0; flex-shrink: 0; }
.pick-main strong { font-size: 12px; line-height: 1.3; text-transform: uppercase; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.pick-main small { font: 10px 'JetBrains Mono', monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-price { font: 800 14px 'JetBrains Mono', monospace; color: var(--link); }
.trade-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: start; }
.trade-card-grid .add-tower-btn { align-self: center; justify-self: center; }
.trade-card-grid > #sideAList, .trade-card-grid > #sideBList { display: contents; }
.trade-card-grid > .contents > span:only-child { grid-column: 1 / -1; }
.trade-card { position: relative; display: flex; flex-direction: column; justify-content: space-between; width: min(100%, 118px); aspect-ratio: 1; min-width: 0; gap: 4px; padding: 8px 7px 7px; border-radius: 6px; text-align: center; }
.trade-card .pick-thumb { font-size: 30px; }
.trade-card .pick-thumb img { max-height: 64px; }
.trade-card .pick-main strong { font-size: 10px; line-height: 1.15; }
.trade-card .pick-price { font-size: 11px; }
.trade-card .pick-main small { display: none; }
.trade-card-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 118px)); justify-content: start; }
.trade-card-grid .add-tower-btn { width: 42px; height: 42px; }
.trade-card > button { position: absolute; top: 6px; right: 6px; background: var(--surface); color: var(--fg); border-color: var(--line); border-radius: 50%; font-size: 18px; }
.trade-card.chip-in { animation: pick-bounce .38s ease-out; }
@keyframes pick-bounce { 0% { transform: scale(.94); } 55% { transform: scale(1.045); } 78% { transform: scale(.985); } 100% { transform: scale(1); } }

/* ---- Transitions and hover feedback ---- */
@keyframes card-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes chip-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes picker-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.card-in { animation: card-in .26s ease-out backwards; animation-delay: calc(var(--i, 0) * 20ms); }
.chip-in { animation: chip-in .2s ease-out backwards; }
#valuesGrid { transition: opacity .14s ease, transform .14s ease; }
#valuesGrid.is-leaving { opacity: 0; transform: translateY(4px); }
.cat-btn, .sort-btn { transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .15s ease; }
#tradeResult { transition: background-color .3s ease, color .3s ease, border-color .3s ease; }
button:not(:disabled), a[href], select, summary, label[for], input[type="file"], input[type="checkbox"] { cursor: pointer; }
header a, header button { transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease; }
header a:hover, header button:hover { transform: translateY(-1px); }
main button { transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease; }
main button:hover:not(:disabled):not(.pick-row):not(.add-tower-btn) { transform: translateY(-1px); }
main button:hover:not(:disabled):not(.pick-row):not(.add-tower-btn):not([aria-pressed="true"]) { box-shadow: 0 3px 0 rgba(38,54,75,.28); }
main button:active:not(:disabled):not(.pick-row):not(.add-tower-btn) { transform: translateY(1px); box-shadow: 0 1px 0 rgba(38,54,75,.2); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 700px) {
    .market-intro { align-items: start; flex-direction: column; gap: 16px; }
    #searchInput { margin-left: 0; width: 100%; }
    main input, main textarea, main select { font-size: 16px; }
    .feedback-panel { padding: 16px; }
    #feedback { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 16px; }
    #feedbackForm { padding: 12px; }
    .picker-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; }
    .pick-row { padding: 10px 8px 8px; gap: 4px; }
    .trade-card { width: 96px; }
    .pick-thumb img { max-height: 95px; }
}
