/* TED dashboard. Plum-ink base, one honey accent (the teddy bear's). Dark first, light variant below. */
:root {
  --bg: #191722; --panel: #221f2e; --panel2: #2c2839; --line: #3a354a;
  --text: #ede9f5; --muted: #a49db6; --accent: #f2b544; --accent-text: #2a1e05; --link: #f2b544;
  --good: #4cc38a; --bad: #f06a6a; --warn: #e0a326;
  --c4-board: #3b55c9; --red: #f06a6a; --yellow: #f5c518; --water: #273b57; --ship: #8a94a6;
  --sq-light: #f0d9b5; --sq-dark: #b58863;
  --round: ui-rounded, "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --r-lg: 16px; --r: 10px; --r-sm: 7px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4fa; --panel: #fff; --panel2: #efebf6; --line: #ddd7e8;
    --text: #1e1a29; --muted: #625b73; --link: #8f5b00; --water: #cfe3f7; --ship: #6b7686;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f4fa; --panel: #fff; --panel2: #efebf6; --line: #ddd7e8;
  --text: #1e1a29; --muted: #625b73; --link: #8f5b00; --water: #cfe3f7; --ship: #6b7686;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-underline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--round); letter-spacing: -0.01em; }
h1 { font-size: 26px; margin: 0 0 8px; }
td, .bignum, .pill { font-variant-numeric: tabular-nums; }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: var(--r-sm); padding: 8px 14px; font-weight: 600; cursor: pointer; }
button:hover:not(:disabled) { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: var(--panel2); color: var(--text); font-weight: 500; }
button.ghost:hover:not(:disabled) { filter: none; background: color-mix(in srgb, var(--panel2) 70%, var(--line)); }
button.danger { background: var(--bad); color: #fff; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 11px; min-width: 0; }
input::placeholder { color: var(--muted); }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }

/* shell: sidebar on desktop, top bar on phones */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
#side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 18px 14px; background: var(--panel); border-right: 1px solid var(--line); }
#side[hidden] { display: none; }
#side[hidden] + main { grid-column: 1 / -1; }
header#top { display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.brand img { width: 36px; height: 36px; border-radius: 50%; }
.brand span { font: 800 22px/1 var(--round); letter-spacing: -0.02em; }
#guild { width: 100%; }
nav#tabs { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
nav#tabs a { display: block; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--muted); white-space: nowrap; }
nav#tabs a:hover { color: var(--text); background: var(--panel2); }
nav#tabs a.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.me { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; min-width: 0; }
.me img { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.me span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me button { padding: 6px 10px; font-size: 13px; }
main { width: 100%; max-width: 1120px; padding: 28px 32px 48px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  #side { position: sticky; z-index: 10; height: auto; display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  header#top { flex-direction: row; align-items: center; }
  .brand span { font-size: 19px; }
  .brand img { width: 30px; height: 30px; }
  #guild { width: auto; max-width: 46vw; }
  .me { grid-column: 2; grid-row: 1; padding: 0; border: 0; }
  .me span { display: none; }
  nav#tabs { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  main { padding: 18px 16px 40px; }
}

/* content */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card > p:last-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .grid2 + .grid2 { margin-top: 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type=text], .row > input:not([type]) { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 52px; height: 38px; object-fit: cover; border-radius: var(--r-sm); background: var(--panel2); flex: none; }
.np { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.np img { width: 176px; height: 99px; object-fit: cover; border-radius: var(--r); background: var(--panel2); }
.np .info { flex: 1; min-width: 220px; }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 10px 0 4px; }
.bar > div { height: 100%; background: var(--accent); }
.controls button { min-width: 42px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; background: var(--panel2); font-size: 12px; }
.win { color: var(--good); } .loss { color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; border-top: 0; }
.hero { width: 26px; height: 26px; border-radius: var(--r-sm); vertical-align: middle; margin-right: 6px; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--r); font-weight: 500; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 20; }
#toast.show { opacity: 1; }
.center { text-align: center; }

/* login */
.login { max-width: 440px; margin: 12vh auto 0; text-align: center; }
.login .mark { font: 800 56px/1 var(--round); letter-spacing: -0.03em; color: var(--accent); margin-bottom: 18px; }
.login kbd { font: 600 14px var(--round); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }

/* games */
.c4 { display: inline-grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: var(--c4-board); padding: 10px; border-radius: var(--r); }
.c4 button { width: 44px; height: 44px; border-radius: 50%; padding: 0; background: var(--bg); }
.c4 .r { background: var(--red); } .c4 .y { background: var(--yellow); }
.c4 .w { outline: 3px solid #fff; }
.bs { display: inline-grid; grid-template-columns: 22px repeat(10, 28px); gap: 2px; font-size: 11px; }
.bs span { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.bs button { width: 28px; height: 28px; padding: 0; border-radius: 4px; background: var(--water); }
.bs .ship { background: var(--ship); } .bs .hit { background: var(--warn); } .bs .sunk { background: var(--bad); }
.bs .miss { background: var(--water); } .bs .miss::after { content: "•"; color: var(--muted); }
.chess { display: inline-grid; grid-template-columns: repeat(8, 1fr); border-radius: var(--r-sm); overflow: hidden; }
.chess button { width: min(11vw, 54px); height: min(11vw, 54px); padding: 0; border-radius: 0; font-size: min(8vw, 38px); line-height: 1; color: #111; font-weight: 400; }
.chess .l { background: var(--sq-light); } .chess .d { background: var(--sq-dark); }
.chess .sel { box-shadow: inset 0 0 0 3px var(--accent); } .chess .tgt { box-shadow: inset 0 0 0 3px var(--good); }
.chess .last { filter: brightness(1.12) saturate(1.4); } .chess .chk { box-shadow: inset 0 0 0 3px var(--bad); }
.chess .wp { color: #fff; text-shadow: 0 0 2px #000, 0 0 1px #000; }
.race { display: grid; gap: 8px; margin: 10px 0; }
.lane { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 8px; }
.lane-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-track { position: relative; height: 36px; background: var(--panel2); border-radius: var(--r-sm); border: 1px solid var(--line); }
.lane-track .horse { position: absolute; top: 2px; font-size: 26px; transform: scaleX(-1); transition: left .9s linear; }
.lane-track .finish { position: absolute; right: 4px; top: 6px; font-size: 18px; }
@media (max-width: 600px) { .lane { grid-template-columns: 1fr; } }
.slotgrid { display: grid; grid-template-columns: repeat(3, 64px); gap: 6px; justify-content: center; margin: 12px 0; }
.slotgrid span { display: flex; align-items: center; justify-content: center; height: 64px; font-size: 38px; background: var(--panel2); border: 2px solid var(--line); border-radius: var(--r); }
.slotgrid span.hit { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel2)); }
.slots { font-size: 54px; letter-spacing: 10px; padding: 10px 0; }
.pcard { display: inline-block; min-width: 44px; padding: 10px 8px; border-radius: var(--r-sm); background: #fff; color: #111; border: 1px solid var(--line); text-align: center; font-weight: 700; font-size: 18px; }
.pcard.redsuit { color: #d42a2a; }
.bignum { font: 800 64px/1.1 var(--round); }
.poke img { width: 280px; border-radius: var(--r); }

/* satisfactory map */
.sfwrap { display: grid; grid-template-columns: 1fr 250px; gap: 14px; margin-bottom: 8px; }
.sfmap { height: 72vh; min-height: 380px; border-radius: var(--r); overflow: hidden; }
.sfmap.leaflet-container { background: #111; }
.sfside { max-height: 72vh; overflow-y: auto; font-size: 14px; }
.sfside h3 { margin: 12px 0 4px; font-size: 14px; }
.sfside p { margin: 0 0 6px; }
.sfcheck { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; }
.sw { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid; flex: none; }
@media (max-width: 800px) { .sfwrap { grid-template-columns: 1fr; } .sfmap { height: 60vh; } .sfside { max-height: none; } }
@media (max-width: 600px) { .np img { width: 100%; height: auto; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
