/* Layout: 방송 스코어보드 같은 상단 대진 카드 → 아래로 표 섹션. 홈=남색, 원정=적갈색(엑셀 대시보드와 같은 팀색). */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --line: #d6dae0;
  --ink: #1d232b;
  --ink-2: #5b6470;
  --home: #3f5873;
  --home-soft: #e7ecf2;
  --away: #a07d4c;
  --away-soft: #f4ece0;
  --focus: #f6f0e4;
  --focus-line: #d6bf93;
  --good: #4f7a5a;
  --bad: #9a7b6b;
  --on-team: #ffffff;
  --win: #b8675b;   /* 승: 차분한 테라코타 */
  --loss: #6f88a6;  /* 패: 차분한 스틸 블루 */
  --rise: #a9554a;  /* 기대승률 상승 글씨 (빨강 계열) */
  --fall: #46688f;  /* 기대승률 하락 글씨 (파랑 계열) */
  --font-body: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b; --surface: #1a2028; --surface-2: #222a34; --line: #323c48;
    --ink: #e8ecf1; --ink-2: #9aa5b2;
    --home: #93a9c4; --home-soft: #232c38; --away: #cfae80; --away-soft: #382f22;
    --focus: #352e22; --focus-line: #a88d62; --good: #8fbf98; --bad: #c2a393; --on-team: #14181e; --win: #d99286; --loss: #8fa6c2; --rise: #e3a196; --fall: #9db6d4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161b; --surface: #1a2028; --surface-2: #222a34; --line: #323c48;
  --ink: #e8ecf1; --ink-2: #9aa5b2;
  --home: #93a9c4; --home-soft: #232c38; --away: #cfae80; --away-soft: #382f22;
  --focus: #352e22; --focus-line: #a88d62; --good: #8fbf98; --bad: #c2a393; --on-team: #14181e; --win: #d99286; --loss: #8fa6c2; --rise: #e3a196; --fall: #9db6d4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 48px;
}
.layout { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.num, td, .odds, .pct { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--home); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.brandbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { font-weight: 900; letter-spacing: .06em; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--away); }
/* PODODO 로고: 밝은 화면용 / 어두운 화면용 그림을 테마에 따라 바꿔 보여줌 */
.brand { display: inline-flex; align-items: center; }
.brand-logo { display: block; height: 24px; width: auto; }
.brand-logo.dk { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo.lt { display: none; } :root:not([data-theme="light"]) .brand-logo.dk { display: block; } }
:root[data-theme="dark"] .brand-logo.lt { display: none; } :root[data-theme="dark"] .brand-logo.dk { display: block; }
.brand-sub { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--ink-2); padding-left: 10px; border-left: 1px solid var(--line); }
.status { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); flex: none; }
.dot.live { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.dot.stale { background: var(--focus-line); }

/* ---------- game strip ---------- */
.strip { display: grid; gap: 8px; min-width: 0; }
.strip-head { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-date { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.chip-date[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.games { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.game {
  flex: none; display: grid; grid-template-columns: auto auto auto; gap: 2px 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer; text-align: left; min-width: 168px;
}
.game:hover { border-color: var(--ink-2); }
.game[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.game .t { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); }
.game .tm { font-weight: 700; }
.game .o { font-family: var(--font-num); font-size: 12px; color: var(--ink-2); }
.game .vs { font-size: 11px; color: var(--ink-2); }

/* ---------- scoreboard ---------- */
.board {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 1.1fr) minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.side { padding: 12px 16px; min-width: 0; overflow: hidden; container-type: inline-size; display: grid; align-content: center; }
.sin { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); grid-template-areas: "id st" "fm fm"; align-items: center; gap: 6px 16px; }
.side.away .sin { grid-template-columns: minmax(0, 1fr) minmax(0, auto); grid-template-areas: "st id" "fm fm"; }
.sin .id { grid-area: id; } .sin .stat { grid-area: st; } .sin .form { grid-area: fm; }
.side.home .form { justify-self: start; } .side.away .form { justify-self: end; }
.side .id > * { max-width: 100%; min-width: 0; }
/* 박스가 좁을 때만 승률을 아래 줄로 */
@container (max-width: 250px) {
  .sin, .side.away .sin { grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "fm" "st"; }
  .side .stat { justify-self: start; } .side.away .stat { justify-self: end; }
}
.side .id { display: grid; gap: 2px; min-width: 0; }
.side .stat { display: grid; gap: 2px; justify-self: end; text-align: right; min-width: 0; }
.side.away .stat { justify-self: start; text-align: left; }
.side.away .id { text-align: right; justify-items: end; }
.side .form { display: inline-flex; align-items: center; gap: 2px; }
.side .form em { font-style: normal; font-size: 11px; color: var(--ink-2); margin-right: 4px; white-space: nowrap; }
.side .form b { width: 16px; height: 16px; border-radius: 3px; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; line-height: 1; }
.side .form b.w { background: var(--win); color: var(--on-team); }
.side .form b.l { background: var(--loss); color: var(--on-team); }
.side.home { border-top: 5px solid var(--home); }
.side.away { border-top: 5px solid var(--away); }
.side .label { font-size: 11px; letter-spacing: .1em; color: var(--ink-2); font-weight: 700; writing-mode: vertical-rl; }
.side .code { font-size: 34px; font-weight: 900; line-height: 1; letter-spacing: .02em; }
.side.home .code { color: var(--home); }
.side.away .code { color: var(--away); }
.side .name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12em; }
.side .ln { display: grid; grid-template-columns: 2.2em 4em 2.8em; align-items: baseline; gap: 4px; white-space: nowrap; }
.side .ln em { font-style: normal; font-size: 11px; color: var(--ink-2); }
.side .ln b { font-family: var(--font-num); font-size: 14px; font-weight: 600; text-align: right; }
.side .ln i { font-style: normal; font-family: var(--font-num); font-size: 12px; color: var(--ink-2); text-align: right; }
.center { padding: 10px 14px; display: grid; gap: 6px; align-content: center; background: var(--surface-2); border-inline: 1px solid var(--line); }
.meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 8px; font-size: 11px; color: var(--ink-2); }
.final { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-num); font-size: 22px; font-weight: 600; color: var(--ink-2); margin: 2px 0; }
.final em { font-style: normal; font-family: inherit; font-size: 12px; font-weight: 700; color: var(--ink); }
.final .w { font-weight: 700; } .final .w.h { color: var(--home); } .final .w.a { color: var(--away); }
.meta .live { color: var(--good); font-weight: 700; }
.pill { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 1px 10px; font-size: 12px; }
.pill.live { color: var(--good); border-color: currentColor; }
.oddsrow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.odds { font-family: var(--font-num); font-size: 30px; font-weight: 600; line-height: 1; }
.odds.h { color: var(--home); }
.odds.a { color: var(--away); text-align: right; }
.trend { font-size: 13px; margin-left: 4px; }
.trend.up { color: var(--bad); } .trend.down { color: var(--home); }
.oddslabel { font-size: 11px; color: var(--ink-2); text-align: center; padding-bottom: 4px; }
.initial { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); font-family: var(--font-num); }
.bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; font-family: var(--font-num); font-size: 12px; font-weight: 600; color: var(--on-team); }
.bar > div { display: flex; align-items: center; padding-inline: 8px; transition: flex-basis .6s ease; min-width: 0; white-space: nowrap; }
.bar .bh { background: var(--home); }
.bar .ba { background: var(--away); justify-content: flex-end; }
.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: var(--focus); } 100% { background: transparent; } }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.field { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.field select, .field input { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 96px; color: var(--ink); }
.field input { width: 84px; min-width: 0; font-family: var(--font-num); }
.manual { display: flex; gap: 8px; align-items: end; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.manual { flex-wrap: wrap; }
.btn:hover { border-color: var(--ink-2); }

/* ---------- sections & tables ---------- */
section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
section > h2 { font-size: 16px; font-weight: 700; padding-bottom: 6px; border-bottom: 2px solid var(--ink); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
section > h2 small { font-size: 12px; font-weight: 400; color: var(--ink-2); }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.tbl { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
table { border-collapse: collapse; width: 100%; min-width: 360px; font-size: 13px; }
th, td { padding: 6px 7px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { white-space: normal; line-height: 1.25; word-break: keep-all; }
tr:last-child td { border-bottom: 0; }
thead th { font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--surface-2); }
thead .team th { color: var(--on-team); font-size: 13px; letter-spacing: .04em; }
.t-home thead .team th { background: var(--home); }
.t-away thead .team th { background: var(--away); }
tbody th { text-align: left; font-weight: 700; background: var(--surface-2); font-size: 13px; }
tr.total td, tr.total th { font-weight: 700; border-top: 2px solid var(--line); }
tr.is-current td, tr.is-current th { background: var(--focus); }
tr.is-current th { box-shadow: inset 4px 0 0 var(--focus-line); }
tr.is-current.flash td, tr.is-current.flash th { animation: pulse 1.6s ease 2; }
@keyframes pulse { 50% { background: color-mix(in srgb, var(--focus-line) 45%, var(--focus)); } }
.g { color: var(--good); font-weight: 700; }
.b { color: var(--bad); }
.b.strong { font-weight: 700; }
.muted { color: var(--ink-2); }
.sub { font-size: 11px; color: var(--ink-2); font-weight: 400; }

/* head-to-head */
.h2h { display: grid; gap: 8px; }
.h2h-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; display: grid; grid-template-columns: 90px 54px 1fr auto; gap: 4px 14px; align-items: center; }
.h2h-row .d { font-family: var(--font-num); font-weight: 600; }
.h2h-row .sc { font-family: var(--font-num); font-weight: 600; }
.res { font-weight: 900; padding: 1px 10px; border-radius: 6px; }
.res.w { color: var(--good); } .res.l { color: var(--bad); }
.outs { grid-column: 1 / -1; font-size: 12px; color: var(--ink-2); display: grid; gap: 2px; border-top: 1px dashed var(--line); padding-top: 6px; }
.outs b { color: var(--ink); font-weight: 700; margin-right: 6px; }
.empty { color: var(--ink-2); padding: 14px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

/* injuries */
.injtbl table { min-width: 360px; }
.injtbl tbody th { background: var(--surface); font-weight: 600; white-space: normal; min-width: 160px; }
.injtbl td:first-child { width: 56px; }
.inj { display: inline-block; min-width: 40px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 900; letter-spacing: .04em; }
.inj.out { background: var(--bad); color: var(--surface); }
.inj.gone { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.inj.note { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.injtbl .cmt-row { font-weight: 400; color: var(--ink-2); }
.inj.dtd { background: var(--focus); color: var(--ink); box-shadow: inset 0 0 0 1px var(--focus-line); }
.cmt { display: block; font-size: 11px; font-weight: 400; color: var(--ink-2); line-height: 1.4; margin-top: 2px; max-width: 46ch; }

/* chat */
.chat { position: sticky; top: calc(16px + env(safe-area-inset-top, 0px)); height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 2px solid var(--ink); font-size: 14px; }
.chat-head .muted { font-size: 12px; }
.chat-close { display: none; border: 0; background: none; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 13px; }
.chat-note { margin: 8px 12px 0; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; }
.chat-list { list-style: none; margin: 0; padding: 10px 12px; flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 10px; }
.msg { display: grid; gap: 2px; }
.msg .who { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.msg .who time { color: var(--ink-2); margin-left: auto; font-size: 11px; }
.msg p { margin: 0; padding: 7px 10px; border-radius: 4px 10px 10px 10px; background: var(--surface-2); font-size: 13px; overflow-wrap: anywhere; }
.msg.mine p { background: var(--home-soft); }
.cheer-tag { font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 4px; color: var(--on-team); }
.cheer-tag.home { background: var(--home); } .cheer-tag.away { background: var(--away); }
.chat-empty { color: var(--ink-2); text-align: center; padding: 24px 0; font-size: 13px; }
.chat-form { border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; }
.chat-meta, .chat-input { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--ink); font: inherit; font-size: 13px; }
#chat-nick { flex: 0 1 110px; }
.cheer { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.cheer button { border: 0; background: var(--surface); padding: 0 10px; font: inherit; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.cheer button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.chat-rule { margin: 0; font-size: 11px; color: var(--ink-2); }
.btn.send { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chat-fab { display: none; }

footer { font-size: 12px; color: var(--ink-2); display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 13px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgb(0 0 0 / .2); z-index: 20;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .chat { position: fixed; inset: auto 0 0 0; height: min(78vh, 640px); top: auto; z-index: 30; border-radius: 14px 14px 0 0;
    transform: translateY(105%); transition: transform .25s ease; box-shadow: 0 -8px 30px rgb(0 0 0 / .18); }
  body.chat-on .chat { transform: none; }
  .chat-close { display: inline; }
  .chat-fab { display: block; position: fixed; z-index: 25; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border: 0; border-radius: 999px; padding: 12px 18px; background: var(--ink); color: var(--surface); font: inherit; font-weight: 700; box-shadow: 0 6px 20px rgb(0 0 0 / .25); cursor: pointer; }
  body.chat-on .chat-fab { display: none; }
}
@media (max-width: 900px) {
  .pair { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .center { grid-column: 1 / -1; grid-row: 2; border-inline: 0; border-top: 1px solid var(--line); }
  .side .code { font-size: 32px; }
}
@media (max-width: 600px) {
  .side { padding: 10px 12px; }
  .side .code { font-size: 28px; }
}
@media (max-width: 480px) {
  .h2h-row { grid-template-columns: auto auto 1fr; }
  .h2h-row .res { justify-self: end; }
  .odds { font-size: 26px; }
  .side { padding: 14px; }
  .side .rate { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash, tr.is-current.flash td, tr.is-current.flash th { animation: none; }
  .bar > div { transition: none; }
}

