/* Perfect XI — styles. Mobile-first, dark/light themes, RTL-safe (logical props). */

:root {
  --accent: #2fbf71;
  --bg: #0b1220;
  --bg2: #101a2e;
  --card: #141f36;
  --card2: #1a2742;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef2f7;
  --muted: #93a0b4;
  --gold: #ffd75e;
  --win: #2fbf71;
  --draw: #e7b93c;
  --loss: #e05252;
  --pitch: #1c3c26;
  --pitch-line: rgba(255, 255, 255, 0.22);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}
:root[data-theme="light"] {
  --bg: #f2f4f8;
  --bg2: #e9edf4;
  --card: #ffffff;
  --card2: #f2f5fa;
  --line: rgba(15, 30, 60, 0.12);
  --text: #14213a;
  --muted: #5b6b83;
  --pitch: #2e7d43;
  --shadow: 0 8px 24px rgba(20, 40, 80, 0.12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "Noto Sans Arabic", sans-serif;
  background: radial-gradient(1200px 500px at 50% -100px, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
h1, h2, h3, h4 { margin: 0.2em 0; line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.warn { color: var(--draw); font-weight: 600; }

#app { max-width: 1080px; margin: 0 auto; padding: 0 14px calc(48px + env(safe-area-inset-bottom)); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 2px; gap: 8px; flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: baseline; gap: 2px; cursor: pointer; user-select: none; direction: ltr; }
/* Latin brand + numeric records always read left-to-right, even in RTL locales. */
.hero-record, .comp-record, .result-rec strong, .grade-chip { direction: ltr; unicode-bidi: isolate; }
.brand-name { font-weight: 900; letter-spacing: 0.08em; font-size: 1.15rem; }
.brand-xi { font-weight: 900; font-size: 1.3rem; color: var(--accent); }
.brand-zero { font-weight: 900; font-size: 1.1rem; opacity: 0.35; }
.btn-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--card);
  border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.lang-select {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font: inherit; max-width: 150px;
}

/* ---------- buttons / chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; font-weight: 700;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #08121f; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent { background: var(--gold); color: #241a00; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--loss); color: var(--loss); margin-top: 16px; }
.btn-big { padding: 15px 30px; font-size: 1.05rem; border-radius: 14px; }
.small-btn { padding: 6px 10px; font-size: 0.82rem; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn {
  flex: 1 1 auto; min-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 700;
}
.seg-btn small { font-weight: 400; color: var(--muted); font-size: 0.72rem; }
.seg-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--card)); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-weight: 600; font-size: 0.88rem;
}
.chip.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--card)); }

/* ---------- home ---------- */
.hero { text-align: center; padding: 26px 8px 10px; }
.hero-record {
  font-size: clamp(64px, 16vw, 130px); font-weight: 900; letter-spacing: -0.02em; margin: 0;
  background: linear-gradient(180deg, var(--text), color-mix(in srgb, var(--accent) 45%, var(--text)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-tagline { font-size: 1.15rem; font-weight: 700; margin-top: 2px; }
.hero-sub { max-width: 640px; margin: 8px auto; }
.hero-stats { font-size: 0.85rem; color: var(--muted); }

.section-title { margin: 22px 0 10px; font-size: 1.05rem; }

.daily-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(120deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  border-radius: var(--radius); padding: 16px; margin-top: 18px; box-shadow: var(--shadow);
}
.daily-card h3 { margin: 0 0 4px; }
.daily-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.9rem; margin: 6px 0 0; }
.streak { color: var(--gold); font-weight: 700; }

.comp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.comp-card {
  --accent: #2fbf71;
  text-align: start; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 3px;
  transition: transform 0.08s ease, border-color 0.15s;
  border-block-end: 3px solid var(--accent);
}
.comp-card:hover { transform: translateY(-2px); }
.comp-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.comp-flag { font-size: 1.5rem; }
.comp-name { font-weight: 800; font-size: 0.95rem; }
.comp-record { font-weight: 900; font-size: 1.25rem; color: color-mix(in srgb, var(--accent) 55%, var(--text)); }
.comp-real { font-size: 0.68rem; color: var(--muted); min-height: 2.2em; }

.options { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.opt-block h3 { font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }

.start-wrap { text-align: center; margin: 26px 0 8px; }
.home-links { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0 20px; }
.footer { text-align: center; border-block-start: 1px solid var(--line); padding-top: 14px; }

/* ---------- pitch ---------- */
.pitch {
  position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: var(--radius);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 12%, transparent 12% 24%),
    var(--pitch);
  border: 2px solid var(--pitch-line);
  overflow: hidden;
}
.pitch::before {
  content: ""; position: absolute; inset-inline: 0; top: 50%; height: 0;
  border-top: 2px solid var(--pitch-line);
}
.pitch::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1;
  transform: translate(-50%, -50%); border: 2px solid var(--pitch-line); border-radius: 50%;
}
.slot {
  position: absolute; transform: translate(-50%, 50%); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 64px;
}
[dir="rtl"] .slot { transform: translate(50%, 50%); }
.slot-num, .slot-pos {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.92rem;
}
.slot.empty .slot-pos {
  border: 2px dashed rgba(255, 255, 255, 0.45); color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.18);
}
.slot.empty.compat .slot-pos {
  border-color: var(--gold); color: var(--gold);
  animation: pulse 1s infinite; background: rgba(0, 0, 0, 0.4);
}
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--gold) 25%, transparent); } }
.slot.filled .slot-num { background: #eef2f7; color: #0b1220; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4); }
.slot.filled.legend .slot-num { background: var(--gold); }
.slot.filled.swap-from .slot-num { outline: 3px solid var(--gold); outline-offset: 2px; }
.slot.filled.compat .slot-num { outline: 3px dashed var(--gold); outline-offset: 2px; animation: pulse 1s infinite; }
.slot-name {
  font-size: 0.66rem; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- draft ---------- */
.view-draft .draft-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px;
}
.view-draft .draft-head h2 { font-size: 1.1rem; flex: 1; }
.draft-progress { font-weight: 800; color: var(--accent); }
.blind-tag { font-size: 1.1rem; }
.draft-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 860px) { .draft-grid { grid-template-columns: 1.1fr 0.9fr; align-items: start; } }

.offer {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); min-height: 200px;
}
.offer.spinning { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 260px; }
.spin-name { font-size: 1.3rem; font-weight: 900; animation: blink 0.14s infinite; }
@keyframes blink { 50% { opacity: 0.55; } }
.offer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.offer-swatch {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--c1, #888) 50%, var(--c2, #ccc) 50%);
  border: 1px solid var(--line);
}
.offer-title { flex: 1; min-width: 0; }
.offer-title h3 { font-size: 1.15rem; }
.offer-title p { margin: 0; font-size: 0.85rem; }
.offer-ovr {
  font-size: 1.4rem; font-weight: 900; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 10px; padding: 4px 10px;
}
.placing-hint { color: var(--gold); font-weight: 700; font-size: 0.9rem; }

.player-list { display: flex; flex-direction: column; gap: 5px; max-height: 46vh; overflow-y: auto; }
.player-row {
  display: flex; align-items: center; gap: 10px; text-align: start;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
}
.player-row:hover:not(.disabled) { border-color: var(--accent); }
.player-row.selected { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--card2)); }
.player-row.disabled { opacity: 0.35; cursor: not-allowed; }
.player-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-star { color: var(--gold); }
.player-rating { font-weight: 900; font-variant-numeric: tabular-nums; min-width: 30px; text-align: end; }
.player-price { color: var(--gold); font-weight: 700; font-size: 0.85rem; }
.pos-chip {
  flex: none; width: 34px; text-align: center; font-size: 0.7rem; font-weight: 800;
  padding: 3px 0; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line);
}
.pos-GK { color: #e7b93c; } .pos-CB, .pos-RB, .pos-LB { color: #6fd3ff; }
.pos-DM, .pos-CM, .pos-AM { color: #9ef0a5; } .pos-LW, .pos-RW, .pos-ST { color: #ff9d9d; }

.reroll-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.budget-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 0.9rem; }
.budget-track { flex: 1; height: 8px; border-radius: 4px; background: var(--card2); overflow: hidden; }
.budget-fill { height: 100%; background: var(--gold); border-radius: 4px; transition: width 0.3s; }
.budget-num { font-weight: 800; color: var(--gold); }

.complete-box { display: flex; flex-direction: column; gap: 12px; }
.team-meters { display: flex; gap: 10px; justify-content: center; }
.meter { display: flex; flex-direction: column; align-items: center; background: var(--card2); border-radius: 10px; padding: 8px 16px; }
.meter-label { font-size: 0.72rem; color: var(--muted); }
.meter-val { font-size: 1.4rem; font-weight: 900; color: var(--accent); }
.label { font-size: 0.85rem; color: var(--muted); }
.input {
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px; font: inherit; width: 100%;
}

/* ---------- reveal ---------- */
.reveal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.reveal-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reveal-controls .seg-btn { min-width: 0; padding: 6px 10px; }
.status-chips { display: flex; gap: 6px; }
.chip-status { font-size: 0.8rem; font-weight: 700; border-radius: 999px; padding: 5px 12px; }
.chip-status.perfect { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }
.chip-status.unbeaten { background: color-mix(in srgb, var(--win) 18%, transparent); color: var(--win); }

.reveal-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 860px) { .reveal-grid { grid-template-columns: 1.3fr 0.7fr; align-items: start; } }
.reveal-feed { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; padding: 2px; }
.reveal-side { position: sticky; top: 10px; }
.seg-label { background: var(--card2); border-radius: 10px; padding: 8px 12px; font-size: 0.95rem; }

.match-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  animation: slidein 0.25s ease;
  border-inline-start: 4px solid var(--line);
}
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }
.match-card.win { border-inline-start-color: var(--win); }
.match-card.draw { border-inline-start-color: var(--draw); }
.match-card.loss { border-inline-start-color: var(--loss); }
.match-stage { margin: 0 0 4px; }
.match-line { display: flex; align-items: center; gap: 10px; }
.match-line .team { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-line .team.away { text-align: end; }
.match-line .team.you { color: var(--accent); }
.match-line .score { font-weight: 900; font-size: 1.15rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.result-chip { font-size: 0.7rem; font-weight: 900; border-radius: 6px; padding: 2px 8px; }
.result-chip.win { background: color-mix(in srgb, var(--win) 22%, transparent); color: var(--win); }
.result-chip.draw { background: color-mix(in srgb, var(--draw) 22%, transparent); color: var(--draw); }
.result-chip.loss { background: color-mix(in srgb, var(--loss) 22%, transparent); color: var(--loss); }
.scorers { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.scorer { font-size: 0.75rem; color: var(--muted); }
.scorer:not(.opp) { color: var(--text); }
.pens-line { font-size: 0.85rem; font-weight: 700; margin: 6px 0 0; }
.drama { color: var(--gold); font-weight: 700; margin: 4px 0 0; }
.group-table { background: var(--card); border-radius: 12px; padding: 10px; border: 1px solid var(--line); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.league-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 420px; }
.table-wrap.mini .league-table { min-width: 300px; font-size: 0.78rem; }
.league-table th, .league-table td { padding: 6px 8px; text-align: center; font-variant-numeric: tabular-nums; }
.league-table th.left, .league-table td.left { text-align: start; }
.league-table thead th { color: var(--muted); font-weight: 600; border-block-end: 1px solid var(--line); }
.league-table tbody tr { border-block-end: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.league-table td.left { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.league-table .pts { font-weight: 900; }
.league-table .user-row { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 700; }
.league-table .zone-title td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.league-table .zone-cont td:first-child { box-shadow: inset 3px 0 0 #4a9eff; }
.league-table .zone-rel td:first-child { box-shadow: inset 3px 0 0 var(--loss); }

/* ---------- result ---------- */
.result-hero {
  text-align: center; padding: 26px 14px; border-radius: var(--radius);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 20%, var(--card)), var(--card));
  border: 1px solid var(--line); box-shadow: var(--shadow); margin-top: 6px;
}
.result-hero.champion { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.result-emoji { font-size: 3rem; }
.result-hero h1 { font-size: clamp(1.6rem, 6vw, 2.6rem); letter-spacing: 0.02em; }
.result-rec { font-size: 1.1rem; }
.result-rec strong { font-size: 1.35rem; }
.grade-chip {
  display: inline-block; background: var(--accent); color: #08121f; font-weight: 900;
  border-radius: 999px; padding: 8px 20px; margin: 10px 0; font-size: 1.05rem;
}
.recap { max-width: 560px; margin: 10px auto; font-size: 1rem; }
.badge-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.badge {
  background: var(--card2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-weight: 800; font-size: 0.82rem;
}
.badge.gold { background: color-mix(in srgb, var(--gold) 25%, var(--card2)); border-color: var(--gold); color: var(--gold); }
.badge.heartbreak { border-color: var(--loss); color: var(--loss); }
.verified { margin-top: 12px; opacity: 0.75; }

.treble-panel { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.trophy-row {
  display: flex; justify-content: space-between; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 600;
}
.trophy-row.won { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--card)); }
.trophy-state { font-weight: 800; }

.awards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.award-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.award-icon { font-size: 1.4rem; }
.award-label { font-size: 0.72rem; color: var(--muted); }
.award-name { font-weight: 800; }
.award-count { font-size: 0.8rem; }

.tabs { display: flex; gap: 6px; margin: 18px 0 10px; flex-wrap: wrap; }
.tab-btn { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 0.88rem; }
.tab-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
.rounds-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.result-pitch { max-width: 460px; margin: 0 auto; }

.daily-result {
  text-align: center; background: linear-gradient(120deg, color-mix(in srgb, var(--gold) 14%, var(--card)), var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); border-radius: var(--radius);
  padding: 16px; margin-top: 14px;
}
.emoji-grid { font-size: 1.3rem; letter-spacing: 2px; margin: 6px 0; }

.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 26px 0 10px; }

/* ---------- share ---------- */
.share-panel { margin-top: 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.share-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .share-grid { grid-template-columns: 0.8fr 1.2fr; align-items: start; } }
.share-preview { width: 100%; max-width: 300px; border-radius: 12px; border: 1px solid var(--line); display: block; margin: 0 auto; }
.share-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.share-btns .btn { justify-content: flex-start; }
.share-x { border-color: #4d5661; } .share-fb { border-color: #1877f2; }
.share-th { border-color: #7c7c7c; } .share-wa { border-color: #25d366; }
.share-tg { border-color: #2aabee; } .share-ig { border-color: #e1306c; }
.share-utils { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- challenge ---------- */
.challenge-cta { text-align: center; margin: 26px 0; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4, 8, 16, 0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
  width: min(620px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-block-end: 1px solid var(--line); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 16px 18px; overflow-y: auto; }

.howto-step { margin-bottom: 12px; }
.howto-tip { background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 0.88rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; align-items: center; }
.stat-val { font-size: 1.3rem; font-weight: 900; color: var(--accent); }
.stat-label { font-size: 0.72rem; text-align: center; }
.bests { display: flex; flex-direction: column; gap: 6px; }
.best-row { display: flex; justify-content: space-between; gap: 10px; background: var(--card); border-radius: 8px; padding: 8px 12px; font-size: 0.88rem; }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.ach-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; gap: 3px; opacity: 0.55;
}
.ach-card.unlocked { opacity: 1; border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); }
.ach-icon { font-size: 1.4rem; }
.ach-name { font-weight: 800; font-size: 0.85rem; }
.ach-desc { font-size: 0.72rem; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 8px; background: var(--card2); border: 1px solid var(--accent);
  border-radius: 12px; padding: 12px 16px; font-weight: 700; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: all 0.3s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { font-size: 1.2rem; }

/* ---------- responsive tweaks ---------- */
@media (max-width: 480px) {
  .comp-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-tagline { font-size: 1rem; }
  .slot { width: 56px; }
  .slot-num, .slot-pos { width: 34px; height: 34px; font-size: 0.8rem; }
  .slot-name { font-size: 0.6rem; max-width: 62px; }
}
@media (min-width: 1024px) {
  .comp-grid { grid-template-columns: repeat(5, 1fr); }
}

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

/* === contrast-fix (gen-assets) === */
/* ============================================================
   LIGHT-MODE CONTRAST FIX
   Redefines accent/status/gold tokens (and pitch line) to
   accessible, same-hue-family variants that reach >= 4.5:1 as
   TEXT on white surfaces. Token-level first, then targeted
   rules for elements that use these as text color or that
   hardcode light text on light surfaces.
   Dark theme is untouched.
   ============================================================ */

/* (a) Token redefinitions for the explicit user toggle */
:root[data-theme="light"] {
  /* darker green — accent & win (~5.3:1 on #fff) */
  --accent: #0a7c3f;
  --win: #0a7c3f;
  /* darker amber/gold for text (~5:1 on #fff) */
  --gold: #8a6d00;
  /* darker draw amber (~4.9:1 on #fff) */
  --draw: #96660a;
  /* loss red darkened to pass as text (~5.3:1 on #fff) */
  --loss: #c62828;
  /* pitch lines: light pitch needs dark strokes, not white */
  --pitch-line: rgba(0, 0, 0, .30);
  /* optional accessible tints for solid chip backgrounds */
  --accent-strong: #0a7c3f;
  --gold-strong: #8a6d00;
}

/* (a') Same fix as an OS-preference fallback when no explicit
   data-theme is set. Guarded so it never leaks into dark. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --accent: #0a7c3f;
    --win: #0a7c3f;
    --gold: #8a6d00;
    --draw: #96660a;
    --loss: #c62828;
    --pitch-line: rgba(0, 0, 0, .30);
    --accent-strong: #0a7c3f;
    --gold-strong: #8a6d00;
  }
}

/* ============================================================
   (b) Targeted rules — for cases where a token swap alone is
   not enough (elements hardcoding a hue, or using a token as a
   CHIP FILL where light text sits on top).
   ============================================================ */

/* --- Text usages: force the accessible token as the color --- */
:root[data-theme="light"] .hero-record,
:root[data-theme="light"] .comp-record,
:root[data-theme="light"] .stat-label,
:root[data-theme="light"] .best-row .muted {
  color: var(--muted);
}

/* Gold-colored text (records, titles, highlights) */
:root[data-theme="light"] .hero-record .gold,
:root[data-theme="light"] .comp-record .gold,
:root[data-theme="light"] [class*="gold"] {
  color: var(--gold);
}

/* Accent/green text anywhere it is applied inline */
:root[data-theme="light"] .accent,
:root[data-theme="light"] [class*="accent"] {
  color: var(--accent);
}

/* Muted text: guarantee it never falls back to a pale value */
:root[data-theme="light"] .muted {
  color: var(--muted);
}

/* --- Status TEXT in tables (win/draw/loss result cells) --- */
:root[data-theme="light"] .win,
:root[data-theme="light"] td.win,
:root[data-theme="light"] .result-w,
:root[data-theme="light"] .cell-win {
  color: var(--win);
}
:root[data-theme="light"] .draw,
:root[data-theme="light"] td.draw,
:root[data-theme="light"] .result-d,
:root[data-theme="light"] .cell-draw {
  color: var(--draw);
}
:root[data-theme="light"] .loss,
:root[data-theme="light"] td.loss,
:root[data-theme="light"] .result-l,
:root[data-theme="light"] .cell-loss {
  color: var(--loss);
}

/* --- Chips / badges that use a token as BACKGROUND fill ---
   The darkened tokens above are dark enough to carry white
   text, so pin the foreground to white and use the accessible
   token as the fill. Covers grade-chip, badge, seg-btn. */
:root[data-theme="light"] .grade-chip,
:root[data-theme="light"] .badge {
  color: #fff;
}
:root[data-theme="light"] .grade-chip.win,
:root[data-theme="light"] .badge.win,
:root[data-theme="light"] .grade-chip[data-kind="win"] {
  background: var(--win);
  border-color: var(--win);
  color: #fff;
}
:root[data-theme="light"] .grade-chip.draw,
:root[data-theme="light"] .badge.draw,
:root[data-theme="light"] .grade-chip[data-kind="draw"] {
  background: var(--draw);
  border-color: var(--draw);
  color: #fff;
}
:root[data-theme="light"] .grade-chip.loss,
:root[data-theme="light"] .badge.loss,
:root[data-theme="light"] .grade-chip[data-kind="loss"] {
  background: var(--loss);
  border-color: var(--loss);
  color: #fff;
}
:root[data-theme="light"] .grade-chip.gold,
:root[data-theme="light"] .badge.gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

/* Chips that instead render the token as TEXT on a pale fill
   (outline / soft style). Detect via transparent-ish bg is not
   possible in CSS, so provide a soft variant hook. */
:root[data-theme="light"] .grade-chip.soft,
:root[data-theme="light"] .badge.soft {
  background: transparent;
}
:root[data-theme="light"] .grade-chip.soft.win,
:root[data-theme="light"] .badge.soft.win { color: var(--win); }
:root[data-theme="light"] .grade-chip.soft.draw,
:root[data-theme="light"] .badge.soft.draw { color: var(--draw); }
:root[data-theme="light"] .grade-chip.soft.loss,
:root[data-theme="light"] .badge.soft.loss { color: var(--loss); }
:root[data-theme="light"] .grade-chip.soft.gold,
:root[data-theme="light"] .badge.soft.gold { color: var(--gold); }

/* --- Segmented control buttons --- */
:root[data-theme="light"] .seg-btn {
  color: var(--muted);
}
:root[data-theme="light"] .seg-btn.active,
:root[data-theme="light"] .seg-btn[aria-selected="true"] {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* --- Defensive: any element hardcoding white text on a light
   surface. Only applies where an explicit light-surface hook
   is present so we don't clobber intentional dark chips. --- */
:root[data-theme="light"] .on-card,
:root[data-theme="light"] .card .text-white:not(.grade-chip):not(.badge):not(.seg-btn) {
  color: var(--text);
}

/* === icons, flags, SEO blocks (icon system) === */
.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; fill: currentColor; flex: 0 0 auto; }
.flag-ico { width: 1.5em; height: 1em; display: inline-block; vertical-align: -0.12em; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); flex: 0 0 auto; }
.btn-icon .ico { width: 1.25em; height: 1.25em; }

.draft-head h2, .reveal-head h2, .seg-label, .daily-today, .best-comp, .challenge-comp,
.home-links .btn, .share-btns .btn, .scorer, .pens-line, .drama, .howto-tip,
.badge, .trophy-state, .seg-lbl, .award-icon, .opt-block h3 {
  display: inline-flex; align-items: center; gap: 0.4em;
}
.home-links .btn, .share-btns .btn { justify-content: center; }
.scorer, .pens-line, .drama, .howto-tip { gap: 0.3em; }

.comp-flag { display: flex; align-items: center; justify-content: center; }
.comp-flag .flag-ico { width: 2.6em; height: 1.73em; border-radius: 4px; }
.result-emoji { display: flex; justify-content: center; }
.result-emoji .ico { width: 56px; height: 56px; }
.leg-star .ico { width: 0.85em; height: 0.85em; color: var(--gold); }
.award-icon .ico { width: 1.5em; height: 1.5em; }
.ach-icon .ico { width: 1.6em; height: 1.6em; }
.toast-icon .ico { width: 1.15em; height: 1.15em; }
.badge .ico { width: 1em; height: 1em; }

/* daily rating tiles (on-site; share text keeps colored-square emoji) */
.tile-grid { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 0.5em 0; }
.tier-tile { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.tier-s { background: var(--win); }
.tier-a { background: var(--gold); }
.tier-b { background: #e0862c; }
.tier-c { background: var(--loss); }

/* localized SEO copy */
.seo-intro { max-width: 70ch; margin: 0 auto 1rem; color: var(--muted); font-size: 0.98rem; line-height: 1.6; }
.seo-intro p { margin: 0.45em 0; }
.seo-guide { max-width: 70ch; margin: 1.4rem auto 0.4rem; }
.guide-steps { margin: 0.5em 0; padding-inline-start: 1.4em; line-height: 1.6; }
.guide-steps li { margin: 0.35em 0; }

/* first-visit how-to popup actions */
.howto-actions { display: flex; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }
.howto-actions .btn { flex: 1 1 auto; }
