/* Wild Rift Coach: dark theme, big tap targets, works in a 360x420 pop-up and on the Fold inner screen. */
:root {
  --bg: #0f1218;
  --panel: #171c26;
  --panel-2: #1f2633;
  --text: #e8ecf3;
  --muted: #9aa4b5;
  --line: #2a3344;
  --accent: #4cc2ff;
  --me: #43d17a;
  --enemy: #ff5d6c;
  --ally: #5b8cff;
  --counter: #ffb547;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
header h1 {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header .logo { flex: none; width: 22px; height: 22px; }
.title-short { display: none; }
.badge {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

main {
  padding: 8px;
  display: grid;
  gap: 8px;
}
main[hidden] { display: none; }
@media (min-width: 700px) {
  main { grid-template-columns: 1fr 1fr; align-items: start; }
  #result { position: sticky; top: 52px; max-height: calc(100vh - 60px); overflow: auto; }
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 10px;
}

h2 {
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
h2:first-child { margin-top: 0; }
h2 .value { color: var(--text); text-transform: none; letter-spacing: 0; }
h2.with-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h3 { margin: 0 0 6px; font-size: 15px; }
h4 { margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { margin: 8px; padding: 10px; border-radius: 8px; background: #3a1a1f; color: #ffb3bb; }

button, .btn {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 6px 10px;
  cursor: pointer;
  touch-action: manipulation;
}
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button[aria-pressed="true"] { border-color: var(--accent); background: #1a3447; }
.small-btn { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #06212f;
  font-weight: 700;
  border-color: transparent;
}

.row { display: flex; flex-wrap: wrap; gap: 6px; }
.roles button { flex: 1 1 60px; padding: 6px 4px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 6px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

input[type="search"] {
  width: 100%;
  min-height: var(--tap);
  margin: 6px 0;
  padding: 6px 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* Champion grid: initials in a coloured circle, name below. Scrolls inside so a pop-up stays usable. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  max-height: 236px;
  overflow: auto;
  padding: 2px;
}
.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 64px;
  padding: 6px 2px;
}
.cell-name {
  max-width: 100%;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell .star { position: absolute; top: 1px; right: 4px; font-size: 11px; color: var(--counter); }
.cell.on.me { border-color: var(--me); box-shadow: inset 0 0 0 1px var(--me); }
.cell.on.enemy { border-color: var(--enemy); box-shadow: inset 0 0 0 1px var(--enemy); }
.cell.on.ally { border-color: var(--ally); box-shadow: inset 0 0 0 1px var(--ally); }

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: hsl(var(--hue) 45% 35%);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; min-height: 20px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
}
.chip.enemy { border-color: var(--enemy); }
.chip.ally { border-color: var(--ally); }
.chip.threat { padding: 3px 12px; font-size: 13px; }
.chip.threat.urgent { border-color: var(--counter); }
#threat-why { min-height: 1.4em; margin: 6px 0 0; }

details.allies { margin-top: 14px; }
details.allies summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
}

/* Result card */
.block { margin-bottom: 14px; }
#result { scroll-margin-top: 48px; }
#result h2 { margin: 0 0 10px; }
#result .primary { margin: 0 0 14px; }
.items { list-style: none; margin: 0; padding: 0; }
.items li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 1px 8px;
  margin-bottom: 4px;
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}
.items .num {
  grid-row: 1 / span 2;
  align-self: center;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}
.items .item-name { font-weight: 600; }
.items .why { font-size: 12px; color: var(--muted); }
.items .why-chip { display: none; }
.items li.counter { border-left: 3px solid var(--counter); }
.items li.counter .why, .items li.counter .why-chip { color: var(--counter); }
.items li.urgent { border-left-color: var(--enemy); }
#item-why { min-height: 1.4em; margin: 4px 0 0; }

.dmg-bar {
  display: flex;
  height: 24px;
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  line-height: 24px;
  color: #fff;
}
.dmg-bar .phys { background: #c0392b; padding-left: 6px; white-space: nowrap; overflow: hidden; }
.dmg-bar .magic { flex: 1; background: #2e86de; text-align: right; padding-right: 6px; white-space: nowrap; overflow: hidden; }

.tips, .notes { margin: 0; padding-left: 18px; }
.tips li, .notes li { margin-bottom: 4px; }
.notes { font-size: 12px; color: var(--muted); }
details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }

/* ---------- In-game panel (ingame.html) ---------- */
.ingame-main { padding: 6px 8px; gap: 6px; display: flex; flex-direction: column; }
.ingame header h1 { font-size: 15px; text-align: center; justify-content: center; }

/* NEXT BUY banner: the one thing to read at a glance. Tap to let the reason wrap. */
.banner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  border-left: 4px solid var(--accent);
  background: var(--panel);
}
.banner-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.banner .label { flex: none; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.banner b { flex: 1 1 auto; min-width: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner .why { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner.expanded .why, .banner.expanded b { white-space: normal; }
.banner.urgent { border-left-color: var(--enemy); }
.banner.urgent .label { color: var(--enemy); }

/* Enemy rows: one line each, avatar + name + Fed/Behind + built picker. */
.enemy-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.erow {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 6px;
  border-radius: 10px;
  background: var(--panel);
}
.erow .avatar { width: 28px; height: 28px; font-size: 11px; }
.erow.biggest .avatar { box-shadow: 0 0 0 2px var(--enemy); }
.ename { flex: 1 1 60px; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Segmented chips: buttons share borders, only the ends are rounded. */
.seg { display: inline-flex; flex: none; }
.seg button {
  min-width: 36px;
  min-height: calc(var(--tap) - 8px);
  padding: 0 7px;
  font-size: 12px;
  border-radius: 0;
  margin-left: -1px;
}
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button[aria-pressed="true"] { position: relative; z-index: 1; }
.seg button[data-k="fed"][aria-pressed="true"] { border-color: var(--enemy); background: #47202a; }
.seg button[data-k="behind"][aria-pressed="true"] { border-color: var(--me); background: #1c3a2a; }

/* My items sheet: full-screen overlay, scrolls on its own. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.sheet[hidden] { display: none; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; }
.item-grid {
  flex: 1;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  padding: 8px;
  align-content: start;
}
.item-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 4px 8px;
  text-align: left;
  font-size: 13px;
}
.item-cell .num { flex: none; width: 18px; text-align: center; font-weight: 700; color: var(--counter); }
.item-cell .item-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-cell.on { border-color: var(--me); background: #1c3a2a; }

/* ---------- Compact mode: Samsung Internet pop-up over the game (~400x350) or a narrow screen ---------- */
@media (max-height: 480px), (max-width: 480px) {
  :root { --tap: 40px; }
  html, body { font-size: 13px; }

  header { padding: 2px 8px; gap: 6px; }
  header h1 { font-size: 14px; }
  .title-long { display: none; }
  .title-short { display: inline; }
  .badge {
    width: 10px;
    height: 10px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    background: var(--muted);
  }
  .small-btn { min-height: 32px; padding: 2px 8px; font-size: 12px; }

  main { padding: 4px; gap: 4px; }
  .panel { padding: 6px 8px; border-radius: 8px; }
  h2 { margin: 8px 0 4px; font-size: 11px; }
  h3 { margin-bottom: 4px; font-size: 13px; }
  h4 { margin: 6px 0 2px; }
  .block { margin-bottom: 8px; }
  .grid { max-height: 150px; }
  .cell { min-height: 52px; }
  input[type="search"] { margin: 4px 0; }
  .primary { margin-top: 8px; }
  #result { scroll-margin-top: 38px; }
  #result h2 { margin-bottom: 4px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #result .primary { margin-bottom: 8px; min-height: 36px; }

  /* Build rows: one line, short reason chip on the right, full reason on tap (#item-why). */
  .items li { grid-template-columns: 20px 1fr auto; gap: 0 6px; align-items: center; margin-bottom: 2px; padding: 4px 6px; }
  .items .num { grid-row: auto; font-size: 12px; }
  .items .item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .items .why { display: none; }
  .items .why-chip { display: inline; font-size: 11px; white-space: nowrap; }
  .dmg-bar { height: 18px; line-height: 18px; font-size: 11px; }
  .chip.threat { font-size: 12px; min-height: 32px; }

  /* In-game panel: banner + 5 rows must fit without scrolling. */
  .ingame-main { padding: 4px 6px; gap: 4px; }
  .banner { padding: 4px 10px; gap: 0; min-height: 0; }
  .banner b { font-size: 16px; }
  .banner .why { font-size: 11px; }
  .enemy-rows { gap: 3px; }
  .erow { gap: 5px; padding: 0 4px; }
  .erow .avatar { width: 24px; height: 24px; font-size: 10px; }
  .seg button { min-width: 32px; padding: 0 5px; font-size: 11px; }
}
