/* AI Rivals. Colors are tokens so light and dark mode are one switch. */

:root {
  --bg: #f3f1ea;
  --surface: #ffffff;
  --surface-2: #f2efe6;
  --surface-3: #e7e3d7;
  --text: #1c1d21;
  --muted: #5b5f68;
  --border: #d8d3c5;
  --ink: #202124;
  --accent: #e3350d;
  --focus: #1a73e8;
  --good: #1f9d55;
  --mid: #d99a00;
  --low: #d93025;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --bezel: #4a4d57;
  --ball-white: #fbfbfb;
  --radius: 14px;
  --pc: var(--accent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1b1d23;
    --surface-2: #23262d;
    --surface-3: #2d3039;
    --text: #ececef;
    --muted: #a5aab4;
    --border: #353944;
    --ink: #0d0e11;
    --focus: #8ab4f8;
    --good: #3ccf7e;
    --mid: #f2c14e;
    --low: #ff6b5e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    --bezel: #2b2d34;
    --ball-white: #e9e9ec;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #1b1d23;
  --surface-2: #23262d;
  --surface-3: #2d3039;
  --text: #ececef;
  --muted: #a5aab4;
  --border: #353944;
  --ink: #0d0e11;
  --focus: #8ab4f8;
  --good: #3ccf7e;
  --mid: #f2c14e;
  --low: #ff6b5e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --bezel: #2b2d34;
  --ball-white: #e9e9ec;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

body:has(dialog[open]) { overflow: hidden; }

h1, h2, h3 { line-height: 1.2; margin: 0; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
img.pixel, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: .5rem; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.empty { color: var(--muted); font-style: italic; padding: .75rem 0; }
.noscript { padding: 2rem 16px; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: .45rem .8rem; min-height: 40px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; }
.btn.icon { width: 40px; padding: 0; font-size: 1.1rem; }

/* ---- top bar ---------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem;
  padding: .6rem max(16px, calc((100% - 1200px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.season-pick select {
  font: inherit; font-weight: 600; padding: .4rem 2rem .4rem .7rem; min-height: 40px; max-width: 70vw;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.sync { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text); margin-right: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--good); animation: pulse 2s infinite; }
.dot.warn { background: var(--mid); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

@media (max-width: 640px) {
  .topbar { position: static; display: grid; grid-template-columns: 1fr auto; gap: .4rem .75rem; }
  #theme { grid-column: 2; grid-row: 1; }
  .season-pick { grid-column: 1 / -1; }
  .season-pick select { width: 100%; max-width: none; }
  .sync { grid-column: 1 / -1; margin: 0; }
}

main { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 2rem; }

/* ---- hero ------------------------------------------------------------- */

.hero { padding: .5rem 0 1rem; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.hero h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 800; }
.season-status { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: .25rem .6rem; border-radius: 99px; background: var(--surface-3); white-space: nowrap; }
.season-status.st-live { background: var(--accent); color: #fff; }
.versus-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; margin-top: .75rem; font-size: clamp(1.2rem, 3.5vw, 1.6rem); font-weight: 800; }
.vs-name { border-bottom: 4px solid var(--pc); }
.vs-word { font-size: .8em; color: var(--muted); font-style: italic; }

.tape-wrap { overflow-x: auto; margin-top: 1rem; }
.tape { border-collapse: collapse; min-width: 100%; font-size: .9rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tape th, .tape td { padding: .45rem .75rem; text-align: center; border-bottom: 1px solid var(--border); }
.tape tr:last-child th, .tape tr:last-child td { border-bottom: 0; }
.tape thead th { border-bottom: 3px solid var(--pc); font-weight: 800; }
.tape tbody th { text-align: left; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tape td { font-variant-numeric: tabular-nums; }
.tape td.lead { font-weight: 800; }
.tape td.lead::after { content: " ★"; color: var(--mid); }

/* ---- arena ------------------------------------------------------------ */

.arena { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.arena.duo { grid-template-columns: 1fr auto 1fr; }
.vs-badge {
  align-self: center; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 900; font-style: italic; letter-spacing: .02em;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 6px var(--border);
}
@media (max-width: 760px) {
  .arena.duo { grid-template-columns: 1fr; }
  .vs-badge { justify-self: center; margin: -.25rem 0; }
}

.trainer {
  container-type: inline-size;
  min-width: 0;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 6px solid var(--pc); padding: 1rem;
}
.trainer-head .version { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--pc); filter: saturate(1.1); }
:root[data-theme="dark"] .trainer-head .version { color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .trainer-head .version { color: var(--text); } }
.tname { font-size: clamp(1.6rem, 6cqi, 2.2rem); font-weight: 900; letter-spacing: .04em; margin-top: .2rem; overflow-wrap: anywhere; }
.model { color: var(--text); font-weight: 600; }

.pill { font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 99px; background: var(--surface-3); white-space: nowrap; }
.pill.st-playing { background: color-mix(in srgb, var(--good) 22%, var(--surface)); }
.pill.st-playing::before { content: "● "; color: var(--good); }
.pill.st-paused, .pill.st-quiet, .pill.st-waiting { background: color-mix(in srgb, var(--mid) 25%, var(--surface)); }
.pill.st-finished { background: var(--surface-3); }

.screen { margin: .9rem 0 0; }
.screen-bezel {
  position: relative; background: var(--bezel); padding: 10px; border-radius: 10px 10px 28px 10px;
  aspect-ratio: 180 / 164;
}
.screen-bezel img { display: block; width: 100%; height: 100%; object-fit: contain; background: #0f380f; border-radius: 3px; }
.no-shot { position: absolute; inset: 10px; display: grid; place-items: center; color: #c9cbd1; font-size: .9rem; background: #23252b; border-radius: 3px; }
.no-shot[hidden] { display: none; }
.screen-cap { font-size: .85rem; color: var(--muted); margin-top: .35rem; min-height: 1.3em; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; margin: .75rem 0 0; }
.stat { background: var(--surface-2); border-radius: 10px; padding: .4rem .5rem; min-width: 0; }
.stat dt { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 440px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.badge { font-size: .78rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; background: color-mix(in srgb, var(--mid) 30%, var(--surface)); }
.badge::before { content: "◆ "; color: var(--mid); }

/* ---- Poké Balls -------------------------------------------------------- */

.ball, .ball-icon {
  --ball-top: var(--pc);
  display: inline-block; position: relative; border-radius: 50%; flex: none;
  background: linear-gradient(to bottom, var(--ball-top) 0 45%, var(--ink) 45% 55%, var(--ball-white) 55% 100%);
  border: 3px solid var(--ink);
}
.ball::after, .ball-icon::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 32%; height: 32%; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--ball-white); border: 3px solid var(--ink);
}
.ball-icon { --ball-top: var(--accent); width: 22px; height: 22px; border-width: 2px; }
.ball-icon::after { border-width: 2px; }
.ball-icon.tiny { width: 14px; height: 14px; border-width: 1.5px; }
.ball-icon.tiny::after { border-width: 1.5px; }
.ball.big { width: 64px; height: 64px; }
.ball.empty { background: transparent; border: 3px dashed var(--border); }
.ball.empty::after { display: none; }

.party { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; margin-top: 1rem; }
@container (max-width: 440px) { .party { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.slot > a, .slot.empty {
  display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .5rem .25rem .45rem;
  border-radius: 12px; text-decoration: none; min-width: 0; height: 100%;
}
.slot > a { background: var(--surface-2); }
.slot > a:hover { background: var(--surface-3); }
.slot > a:hover .ball { transform: rotate(-12deg); }
.slot .ball { width: min(48px, 100%); aspect-ratio: 1; transition: transform .15s; }
.slot-name { font-weight: 800; font-size: .8rem; letter-spacing: .03em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-lv { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot-status { margin-left: .25rem; font-weight: 800; color: var(--low); }
.slot .hp { width: 100%; }
.slot.fainted .ball { filter: grayscale(1); opacity: .45; }
.slot.fainted .slot-name { text-decoration: line-through; color: var(--muted); }
.slot.fainted .slot-lv::after { content: " · FNT"; color: var(--low); font-weight: 800; }

.hp { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hp-fill { height: 100%; border-radius: 99px; background: var(--good); }
.hp-mid .hp-fill { background: var(--mid); }
.hp-low .hp-fill { background: var(--low); }

/* ---- menu --------------------------------------------------------------- */

.menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .9rem; }
.menu-btn {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  min-height: 46px; padding: .5rem .75rem; border-radius: 10px; text-decoration: none;
  background: var(--surface); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--pc);
  font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .85rem;
}
:root[data-theme="dark"] .menu-btn { border-color: var(--muted); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu-btn { border-color: var(--muted); } }
.menu-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--pc); }
.menu-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--pc); }
.menu-count { font-size: .75rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
@container (max-width: 340px) { .menu { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.thought { margin-top: .9rem; padding: .7rem .8rem; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--pc); }
.thought p { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; margin-top: .15rem; }
.actions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.action { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .75rem; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-3); }
.card-foot { margin-top: .75rem; }

/* ---- type chips ---------------------------------------------------------- */

.type-chip { display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .05em; padding: .12rem .5rem; border-radius: 6px; background: var(--type-bg); color: var(--type-fg); }
.type-chip.type-unknown { background: var(--surface-3); color: var(--text); }

/* ---- rivalry feed -------------------------------------------------------- */

.feed { margin-top: 2rem; }
.feed h2 { font-size: 1.3rem; font-weight: 800; }
.feed-list { margin-top: .75rem; display: grid; gap: .5rem; }
.feed-more { margin-top: .75rem; }
.feed-item { background: var(--surface); border-radius: 12px; padding: .6rem .8rem; border-left: 5px solid var(--pc); box-shadow: var(--shadow); }
.feed-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.feed-who { font-weight: 800; text-decoration: none; }
.feed-who:hover { text-decoration: underline; }
.feed-body { display: flex; gap: .75rem; align-items: flex-start; margin-top: .25rem; }
.feed-body p { min-width: 0; overflow-wrap: anywhere; }
.feed-thumb { width: 80px; height: auto; border-radius: 4px; flex: none; }
.quote { font-style: italic; }
.kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .08rem .45rem; border-radius: 6px; background: var(--surface-3); }
.kind-named, .kind-named_self { background: color-mix(in srgb, #8e44ad 25%, var(--surface)); }
.kind-caught { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.kind-badge { background: color-mix(in srgb, var(--mid) 35%, var(--surface)); }
.kind-evolved { background: color-mix(in srgb, #1a73e8 22%, var(--surface)); }
.kind-new_area, .kind-route_done { background: color-mix(in srgb, var(--good) 22%, var(--surface)); }

.site-foot { max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 2.5rem; color: var(--muted); font-size: .8rem; display: grid; gap: .4rem; border-top: 1px solid var(--border); }

/* ---- dialog ------------------------------------------------------------- */

dialog {
  width: min(640px, calc(100vw - 24px)); max-height: min(88vh, 900px); max-height: min(88dvh, 900px);
  padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); border-top: 6px solid var(--pc);
}
dialog.wide { width: min(980px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10, 12, 16, .55); }
.panel-inner { display: flex; flex-direction: column; max-height: inherit; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .9rem 1rem .6rem; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 1.4rem; font-weight: 900; letter-spacing: .03em; overflow-wrap: anywhere; }
.panel-who { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); font-weight: 600; }
.who-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.panel-body { overflow-y: auto; padding: .5rem 1rem 1.25rem; overscroll-behavior: contain; }
@media (max-width: 560px) {
  dialog, dialog.wide { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 .75rem; }
.chip {
  font: inherit; font-size: .82rem; font-weight: 600; padding: .3rem .7rem; min-height: 34px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip-count { margin-left: .35rem; opacity: .7; font-variant-numeric: tabular-nums; }

/* party member */
.mon-head { display: flex; align-items: center; gap: 1rem; margin-top: .5rem; }
.mon-head > div:nth-child(2) { flex: 1; min-width: 0; }
.mon-head.fainted .ball { filter: grayscale(1); opacity: .5; }
.mon-nick { font-weight: 900; font-size: 1.4rem; letter-spacing: .04em; overflow-wrap: anywhere; }
.mon-nick.small { font-size: 1rem; }
.mon-species { font-weight: 600; }
.mon-types { display: flex; gap: .3rem; margin-top: .3rem; flex-wrap: wrap; }
.mon-level { font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mon-hp { margin-top: 1rem; display: grid; gap: .35rem; }
.mon-hp .hp { height: 10px; }
.status-chip { justify-self: start; font-size: .75rem; font-weight: 800; padding: .12rem .5rem; border-radius: 6px; background: color-mix(in srgb, var(--low) 25%, var(--surface)); }
.name-reason { margin: 1.1rem 0 0; padding: .8rem 1rem; border-radius: 12px; background: color-mix(in srgb, var(--pc) 12%, var(--surface)); border-left: 5px solid var(--pc); }
.name-reason figcaption { font-weight: 800; font-size: .85rem; }
.name-reason blockquote, .name-item blockquote { margin: .25rem 0 0; font-style: italic; overflow-wrap: anywhere; }
.moves { display: grid; gap: .4rem; }
.move { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: 10px; background: var(--surface-2); }
.move-name { font-weight: 700; }
.move-pp { font-size: .82rem; color: var(--muted); }
.mon-nav { margin-top: 1.25rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* bag, box */
.item-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem .2rem; border-bottom: 1px solid var(--border); }
.item-list li:last-child { border-bottom: 0; }
.box-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem; }
.box-mon { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.box-mon > div { min-width: 0; }

/* pokédex */
.dex-summary { margin-top: .5rem; font-size: 1.05rem; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .35rem; }
.dex-cell { display: flex; align-items: center; gap: .45rem; padding: .35rem .55rem; border-radius: 8px; background: var(--surface-2); font-size: .85rem; min-width: 0; }
.dex-cell.unknown { opacity: .5; }
.dex-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dex-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.dex-cell.unknown .dex-dot { border-style: dashed; }

/* map */
.map-select { font: inherit; font-weight: 600; padding: .4rem .6rem; min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 100%; }
.map-wrap { margin-top: .75rem; overflow: auto; max-height: 62vh; max-height: 62dvh; border-radius: 10px; background: var(--surface-2); padding: 6px; }
.map-canvas { display: block; margin: 0 auto; width: auto; height: auto; max-width: 100%; max-height: calc(62vh - 12px); max-height: calc(62dvh - 12px); touch-action: manipulation; }
.map-wrap.zoomed .map-canvas { max-width: none; max-height: none; margin: 0; }
.map-hover { margin-top: .4rem; font-size: .85rem; min-height: 1.3em; }
.map-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
@media (max-width: 560px) { .map-meta { grid-template-columns: 1fr; } }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .3rem .75rem; font-size: .85rem; }
.legend li { display: flex; align-items: center; gap: .4rem; }
.legend-swatch { width: 16px; height: 16px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px var(--border); }
.exit-list li { padding: .2rem 0; }
.linkish { font-weight: 600; color: var(--text); text-decoration: underline; text-decoration-color: var(--pc); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.map-text { margin-top: 1rem; }
.map-text summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.map-text pre { font-size: 11px; line-height: 1.1; overflow: auto; background: var(--surface-2); padding: .5rem; border-radius: 8px; }

/* journal */
.journal { display: grid; gap: .9rem; }
.j-entry { padding: .75rem .9rem; border-radius: 12px; background: var(--surface-2); border-left: 4px solid var(--pc); }
.j-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; font-size: .85rem; }
.j-text { margin-top: .4rem; white-space: pre-line; overflow-wrap: anywhere; }
.j-shot { display: inline-block; margin-top: .6rem; }
.j-shot img { display: block; width: 320px; max-width: 100%; height: auto; border-radius: 6px; border: 4px solid var(--bezel); }

/* notebook */
.nb-section ul { list-style: disc; padding-left: 1.2rem; display: grid; gap: .25rem; }
.names, .thoughts, .events { display: grid; gap: .6rem; }
.name-item, .thoughts > li { padding: .65rem .8rem; border-radius: 10px; background: var(--surface-2); }
.thoughts p { margin-top: .2rem; overflow-wrap: anywhere; }
.events li { padding: .35rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

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

/* One trainer alone (or 3+): keep each card a comfortable size instead of the
   full page width, centered. Two-player seasons keep the duo layout. */
.arena:not(.duo):not(.solo) { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 560px)); justify-content: center; }
.screen { max-width: 520px; margin-inline: auto; }

/* One trainer: map | game | stats on wide screens, then the rivalry feed and
   the thinking feed side by side underneath. Tablets: game | stats with the
   map below. Phones: everything stacked. */
.arena.solo { grid-template-columns: minmax(0, 1fr); }
/* A lone trainer fits whatever screen it's on: the page uses the full window
   width (small side margins), and the top bar and footer line up with it. */
main:has(.arena.solo) { max-width: none; padding-inline: max(16px, 2vw); }
body:has(.arena.solo) .topbar { padding-inline: max(16px, 2vw); }
body:has(.arena.solo) .site-foot { max-width: none; padding-inline: max(16px, 2vw); }
.arena.solo .trainer-rest { container-type: inline-size; } /* stats/party size to their own column */
.arena.solo .trainer .thought { display: none; }          /* it has its own feed below */
.mini-map-box { margin-top: .9rem; }
.mini-map-box .mini-map { display: block; margin: .4rem auto 0; width: 100%; height: auto; max-height: 420px;
  object-fit: contain; image-rendering: pixelated; border-radius: 8px; }
@media (min-width: 820px) {
  .arena.solo .trainer {
    display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    grid-template-areas: "shot head" "shot rest" "map map"; grid-template-rows: auto 1fr auto; gap: 0 1.5rem; align-items: start;
  }
  .arena.solo .trainer-head { grid-area: head; }
  .arena.solo .screen { grid-area: shot; margin: 0; max-width: none; }
  .arena.solo .trainer-rest { grid-area: rest; }
  .arena.solo .mini-map-box { grid-area: map; }
  main:has(.arena.solo) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1.5rem; align-items: start; }
  main:has(.arena.solo) > .hero, main:has(.arena.solo) > .arena { grid-column: 1 / -1; }
  main:has(.arena.solo) > #feed { grid-column: 1; }
  main:has(.arena.solo) > #thinking { grid-column: 2; }
}
@media (min-width: 1100px) {
  .arena.solo .trainer {
    /* The game screen follows the window: at most ~46% of the width, and
       small enough that the whole top row fits the window's height. */
    grid-template-columns: minmax(220px, 1fr) minmax(0, min(46vw, calc((100vh - 262px) * 1.09))) minmax(290px, 1fr);
    grid-template-areas: "map shot head" "map shot rest"; grid-template-rows: auto 1fr;
  }
  .arena.solo .mini-map-box { margin-top: 0; }
  .mini-map-box .mini-map { max-height: calc(100vh - 300px); }
}
.thinking .think-item p { margin-top: .3rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.think-item .feed-meta .actions { margin-top: 0; }
.legend-fog, .legend-exit { display: inline-block; width: 16px; height: 16px; border-radius: 3px; vertical-align: -3px; }
.legend-fog { background: repeating-linear-gradient(45deg, #9aa0a6 0 4px, #3a3f48 4px 8px); opacity: .8; }
.legend-exit { border: 2px solid #e3350d; }
