:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1f232c; --border: #2a2f3a;
  --text: #e6e8ec; --muted: #9aa3b2; --accent: #4f8cff; --accent2: #3a73e0;
  --danger: #e5484d; --ok: #30a46c; --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--border); background: var(--panel); }
.topbar h1 { margin: 0 auto; max-width: 1100px; font-size: 1.15rem; font-weight: 650; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

.player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
@supports not (aspect-ratio: 16 / 9) { .player { height: 0; padding-top: 56.25%; } }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 16px; }
.now-playing { margin-top: 8px; color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }

textarea, input[type=text], input[type=search] {
  width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 16px; /* 16px avoids iOS zoom */
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; resize: vertical; min-height: 96px; }
@media (max-width: 600px) { textarea { font-size: 16px; } }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; margin-top: 10px; }
.wrap-row { flex-wrap: wrap; }
.toggle { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: .95rem; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font-size: 15px; font-weight: 550; cursor: pointer; min-height: 44px;
}
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: #ff8a8d; }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }

.msg { margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: .95rem; white-space: pre-line; }
.msg.error { background: rgba(229,72,77,.12); border: 1px solid rgba(229,72,77,.5); color: #ffb3b5; }
.msg.ok { background: rgba(48,164,108,.12); border: 1px solid rgba(48,164,108,.5); color: #9be3bd; }
.msg.info { background: rgba(79,140,255,.10); border: 1px solid rgba(79,140,255,.4); color: #b8cfff; }

.list-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h2 { margin: 0; }
.list-head input { max-width: 320px; }
.count { color: var(--muted); font-weight: 400; font-size: .9rem; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.item { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.item.playing { border-color: var(--accent); }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); text-transform: uppercase; letter-spacing: .03em; }
.badge.shared { color: #9be3bd; border-color: rgba(48,164,108,.5); }
.badge.local { color: #ffd38a; border-color: rgba(255,180,60,.5); }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--muted); margin: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (max-width: 600px) {
  .wrap { padding: 10px; gap: 12px; }
  .card { padding: 12px; }
  .list-head input { max-width: none; }
  .grid { grid-template-columns: 1fr; }
}

/* ---------- Sports / matches ---------- */
.player-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); text-align: center; padding: 16px; white-space: pre-line; overflow-wrap: anywhere; }
.player .player-custom { position: absolute; inset: 0; width: 100%; height: 100%; }
select {
  width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 16px; min-height: 44px; font-family: inherit;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sports-controls { display: grid; grid-template-columns: minmax(180px, 260px) auto minmax(160px, 1fr); gap: 8px; align-items: center; }
.seg { display: inline-flex; gap: 4px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg .btn { border-color: transparent; background: transparent; min-height: 36px; }
.seg .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.match-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; max-height: min(600px, 70vh); overflow-y: auto; overscroll-behavior: contain; }
.match-list:empty { margin: 0; }
.match { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.match.playing { border-color: var(--accent); }
.match-main { min-width: 0; }
.match-title { font-weight: 600; overflow-wrap: anywhere; }
.match-meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.match .btn { flex-shrink: 0; }
.badge.live { color: #ffb3b5; border-color: rgba(229,72,77,.6); background: rgba(229,72,77,.12); }
.badge.popular { color: #ffd38a; border-color: rgba(255,180,60,.5); }
@media (max-width: 600px) {
  .sports-controls { grid-template-columns: auto 1fr; }
  .sports-controls select { grid-column: 1 / -1; }
  .match { padding: 10px; }
}
