/* Setup page */
.back { margin-left: -6px; }
.tabs {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 61px); z-index: 15;
  display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto;
  background: rgba(11, 13, 17, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabs a {
  flex: 1; text-align: center; text-decoration: none; padding: 10px 14px; border-radius: 10px; color: var(--muted);
  font-family: var(--din); font-size: 21px; letter-spacing: .04em; white-space: nowrap;
}
.tabs a.on { background: var(--panel-3); color: #fff; }
@media (min-width: 800px) { .tabs a { flex: none; } }

.setup { max-width: 1100px; margin: 0 auto; padding: 14px 12px 60px; }
.tab { display: none; flex-direction: column; gap: 14px; }
.tab.on { display: flex; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.with-btn { display: flex; gap: 8px; }
.with-btn .in { flex: 1; }
code { background: var(--panel-3); padding: 2px 6px; border-radius: 5px; }

/* ---------- matchup */
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; }
.pick {
  appearance: none; cursor: pointer; border: 2px solid var(--line-2); border-radius: 14px; background: var(--panel-2);
  padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; transition: border-color .15s;
}
.pick:hover { border-color: #4b5570; }
.pick-logo { position: relative; width: 100%; max-width: 180px; aspect-ratio: 256 / 269; background: #e5e6e6; border-radius: 10px; overflow: hidden; }
.pick-logo img { position: absolute; inset: 7%; width: 86%; height: 86%; object-fit: contain; }
.pick-side { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.pick-name { font-family: var(--din); font-weight: 500; font-size: 26px; line-height: 1.05; text-align: center; text-transform: uppercase; word-break: break-word; }
.pick-change { font-size: 12px; color: var(--blue); }
.swap { align-self: center; font-size: 22px; min-width: 52px; }
@media (max-width: 520px) {
  .matchup { grid-template-columns: 1fr 1fr; }
  .swap { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .pick-name { font-size: 22px; }
}

/* ---------- online game (lhf.lv) */
.on-linked { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; background: #14213d; border: 1px solid #2d4a86; border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.on-find { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; margin: 12px 0 10px; }
.on-find .btn { min-width: 48px; }
.games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.games li { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 8px 8px 8px 12px; cursor: pointer; }
.games li:hover { border-color: #4b5570; }
.games li.used { border-color: var(--blue); background: #14213d; }
.games li.msg { display: block; cursor: default; color: var(--muted); background: none; border: 0; padding: 6px 2px; }
.games .gt { font-family: var(--din); font-size: 22px; }
.games .gm { min-width: 0; }
.games .gm b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.games .gm small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.games .gs { font-family: var(--din); font-size: 20px; color: var(--muted); text-align: right; }
.games .gs.live { color: var(--green-2); }
.on-paste { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }

/* ---------- teams */
.teams-bar { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
@media (max-width: 620px) { .teams-bar { grid-template-columns: 1fr 1fr; } .teams-bar .in { grid-column: 1 / -1; } }
.drop-hint { margin: -4px 4px 0; }
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tcard {
  appearance: none; cursor: pointer; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; transition: border-color .15s, transform .08s; padding: 0;
}
.tcard:hover { border-color: #4b5570; }
.tcard:active { transform: scale(.98); }
.tcard .tc-logo { aspect-ratio: 1.3; background: #e5e6e6; display: flex; align-items: center; justify-content: center; position: relative; }
.tcard .tc-logo img { position: absolute; inset: 10% 14%; width: 72%; height: 80%; object-fit: contain; }
.tcard .tc-logo .noimg { color: #777; font-size: 13px; }
.tcard .tc-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.tcard .tc-name { font-family: var(--din); font-size: 22px; line-height: 1.05; text-transform: uppercase; }
.tcard .tc-row { display: flex; align-items: center; gap: 8px; }
.tcard .tc-short { color: var(--muted); font-family: var(--din); font-size: 17px; text-transform: uppercase; }
.badge { position: absolute; top: 8px; left: 8px; font-family: var(--din); font-size: 14px; letter-spacing: .06em; background: var(--blue); color: #fff; border-radius: 6px; padding: 2px 7px 1px; }
.badge.away { background: #8a3ffc; }
body.dragging .team-grid { outline: 3px dashed var(--blue); outline-offset: 6px; border-radius: 14px; }

/* scorebug cell (101x61 like the output) */
.sb-cell { position: relative; width: 101px; height: 61px; background: #fff; overflow: hidden; flex: none; }
.sb-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 50% 50%; }
.tcard .sb-cell { transform: scale(.55); transform-origin: 0 50%; margin-right: -45px; margin-top: -14px; margin-bottom: -14px; }

/* ---------- dialogs */
.sheet.wide { width: min(760px, calc(100vw - 20px)); }
.sheet-actions.one { grid-template-columns: 1fr; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 12px; max-height: 60vh; overflow: auto; padding: 2px; }
.pick-grid button {
  appearance: none; cursor: pointer; border: 2px solid var(--line-2); border-radius: 12px; background: var(--panel-2); padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.pick-grid button.on { border-color: var(--blue); }
.pick-grid .pg-logo { position: relative; aspect-ratio: 1.25; background: #e5e6e6; }
.pick-grid .pg-logo img { position: absolute; inset: 11% 15%; width: 70%; height: 78%; object-fit: contain; }
.pick-grid b { font-family: var(--din); font-weight: 500; font-size: 18px; padding: 8px 6px; text-transform: uppercase; line-height: 1.05; }
.pick-grid .pg-disabled { opacity: .35; pointer-events: none; }

.editor { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
@media (max-width: 560px) { .editor { grid-template-columns: 112px 1fr; gap: 12px; } .team-logo-drop span { font-size: 9px; } }
.editor-fields { display: flex; flex-direction: column; gap: 12px; }
.drop {
  position: relative; border: 2px dashed #4b5570; border-radius: 12px; background: #e5e6e6; cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center; transition: border-color .15s, box-shadow .15s;
}
.drop img { position: absolute; inset: 8% 8% 18%; width: 84%; height: 74%; object-fit: contain; }
.drop span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; text-align: center; padding: 4px; }
.drop.over { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(61, 123, 255, .3); }
.drop.busy { opacity: .5; }
.team-logo-drop { aspect-ratio: 256 / 269; }

.fit { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
@media (max-width: 560px) { .fit { grid-template-columns: 1fr; } }
.fit-preview { --z: 2; display: flex; transform: scale(var(--z)); transform-origin: 0 0; width: 202px; height: 61px; margin: 0 calc(202px * (var(--z) - 1)) calc(61px * (var(--z) - 1)) 0; }
@media (max-width: 560px) { .fit-preview { --z: 1.6; } }
.fit-preview .sb-bar { width: 101px; height: 61px; background: #b4b5b5 url('/assets/scorebug-texture.png') 0 0 / 535px 61px; display: flex; align-items: center; justify-content: center; font-family: var(--din); font-size: 30px; color: #000; text-transform: uppercase; overflow: hidden; }
.fit-controls { display: flex; flex-direction: column; gap: 10px; }
.fit-controls input[type=range] { width: 100%; accent-color: var(--blue); height: 30px; }
.fit-controls .fld span b { color: var(--text); margin-left: 6px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; align-items: center; }
.editor-actions .spacer { flex: 1; }

/* ---------- graphics tab */
.league-drops { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.league-drops .drop { height: 120px; }
.league-head { background: var(--red) !important; }
.league-sb { background: #b4b5b5 url('/assets/scorebug-texture.png') center / cover !important; }

/* ---------- output tab */
.urls { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.urls li { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 12px; }
.urls li b { font-family: var(--din); font-weight: 500; font-size: 18px; }
.urls li code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; padding: 0; }
@media (max-width: 560px) { .urls li { grid-template-columns: 1fr auto; } .urls li b { grid-column: 1 / -1; } }
.phone { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: center; }
@media (max-width: 480px) { .phone { grid-template-columns: 1fr; } }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 180px; }
.qr svg { display: block; width: 100%; height: auto; }
@media (max-width: 560px) {
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .editor-actions .spacer { display: none; }
  .editor-actions #edDone { grid-column: 1 / -1; min-height: 52px; }
}

.games .gm b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.games .gm i { font-style: normal; color: var(--muted); }
.gteam { display: inline-flex; align-items: center; gap: 6px; }
.gteam img { width: 24px; height: 24px; object-fit: contain; background: #fff; border-radius: 4px; padding: 1px; }
.fld.narrow { max-width: 420px; margin-top: 8px; }

.stat-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 14px; }
