:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1e2330;
  --border: #2a3142;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #ffb627;
  --accent-2: #ff5d73;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2133 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

button, select, textarea, input { font: inherit; color: inherit; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(13, 15, 20, .8); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 32px; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.logo b { color: var(--accent); }
.logo-mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #111; font-weight: 900;
  font-size: 32px; line-height: 1;
}

main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- generic ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; color: var(--accent); font-weight: 700; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: clamp(28px, 4vw, 42px); }
h2 { font-size: 24px; }
.muted { color: var(--muted); }

.btn {
  border: 1px solid var(--border); background: var(--panel-2); padding: 10px 16px; border-radius: 10px;
  cursor: pointer; font-weight: 600; transition: transform .1s, background .15s, border-color .15s;
}
.btn:hover { border-color: #3d4660; background: #252b3a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff8a3d); color: #17120a; border: none; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 14px 28px; font-size: 17px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- home ---------- */
.hero { margin-bottom: 26px; }
.hero p { color: var(--muted); max-width: 640px; margin: 8px 0 0; }

.setup { display: grid; gap: 18px; }
.step-title { font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.step-num {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; color: var(--accent);
}

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.choice {
  text-align: left; padding: 16px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--panel-2); cursor: pointer; transition: border-color .15s, transform .1s;
}
.choice:hover { border-color: #46506b; }
.choice.active { border-color: var(--accent); background: #261f12; }
.choice .ic { font-size: 26px; display: block; margin-bottom: 6px; }
.choice .t { font-weight: 700; display: block; }
.choice .d { color: var(--muted); font-size: 13px; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field select, .field textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.field textarea { min-height: 160px; resize: vertical; }

/* checkbox dropdowns (multi-pick filters) */
.multi { position: relative; }
.multi summary {
  list-style: none; cursor: pointer; user-select: none;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 36px 10px 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
}
.multi summary::-webkit-details-marker { display: none; }
.multi summary::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg);
}
.multi[open] summary { border-color: var(--accent); }
.multi[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }
.multi-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5;
  max-height: 320px; overflow-y: auto; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}
.multi-opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.field .multi-opt { display: flex; font-size: 14px; color: var(--text); margin: 0; font-weight: 400; }
.multi-opt:hover { background: #252b3a; }
.multi-opt input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.multi-n { margin-left: auto; color: var(--muted); font-size: 12px; }
.multi-all { border-bottom: 1px solid var(--border); border-radius: 7px 7px 0 0; margin-bottom: 4px; }
.field .multi-group { margin-top: 6px; font-weight: 700; color: var(--accent); }
.multi-sub { padding-left: 26px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 1px solid var(--border); background: var(--panel-2); border-radius: 999px; padding: 7px 14px;
  cursor: pointer; font-weight: 600; font-size: 14px;
}
.pill.active { background: var(--accent); color: #17120a; border-color: var(--accent); }
.pill:disabled { opacity: .35; cursor: not-allowed; }

.pool-count { margin-top: 14px; color: var(--muted); font-size: 14px; }
.pool-count b { color: var(--text); }
.warn { color: var(--accent-2); }

.start-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; border-color: #4a3c1a; }

/* ---------- cards ---------- */
.card {
  position: relative; overflow: hidden; border-radius: 12px; padding: 14px 16px; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.35);
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.card-mark {
  position: absolute; right: -6px; bottom: -18px; font-size: 84px; font-weight: 900; opacity: .14;
  line-height: 1; pointer-events: none; letter-spacing: -.04em;
}
.card-badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  background: rgba(0,0,0,.35); padding: 3px 8px; border-radius: 999px; margin-bottom: 8px;
}
.card-name { font-weight: 800; font-size: 17px; line-height: 1.2; position: relative; }
.card-sub { font-size: 13px; opacity: .85; margin-top: 4px; position: relative; }

.card.big { padding: 28px 26px; min-height: 210px; display: flex; flex-direction: column; justify-content: flex-end; animation: pop .35s ease-out; }
.card.big .card-badge { align-self: flex-start; }
.card.big .card-name { font-size: clamp(24px, 3.4vw, 34px); }
.card.big .card-sub { font-size: 15px; }
.card.big .card-mark { font-size: 160px; bottom: -34px; }

/* player photos fill the card; a shade keeps the text readable */
.card-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 22%; pointer-events: none;
}
.has-photo::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.7) 0%, rgba(0,0,0,.35) 50%, rgba(0,0,0,.1) 100%);
}
.has-photo .card-mark { display: none; }
.has-photo .card-badge, .has-photo .card-name, .has-photo .card-sub, .card-credit { position: relative; z-index: 1; }
.card.big.has-photo { min-height: 300px; }
.card-credit {
  position: absolute; right: 10px; bottom: 8px; max-width: 70%; font-size: 11px; color: rgba(255,255,255,.75);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-credit:hover { color: #fff; text-decoration: underline; }
.card.big.has-photo .card-sub { margin-bottom: 14px; }

.credits { margin-top: 18px; color: var(--muted); font-size: 13px; }
.credits summary { cursor: pointer; }
.credits ul { margin: 8px 0 0; padding-left: 18px; columns: 2 280px; }
.credits a { color: var(--muted); }

@keyframes pop { from { transform: scale(.92) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- play header ---------- */
.play-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }

/* ---------- blind ranking ---------- */
.blind { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.stage { position: sticky; top: 90px; }
.counter { color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.counter b { color: var(--text); }
.upnext { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.upnext span { width: 26px; height: 8px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); }
.upnext span.done { background: var(--accent); border-color: var(--accent); }
.hint { color: var(--muted); font-size: 14px; }

.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slot {
  display: flex; align-items: stretch; gap: 10px; min-height: 58px; border-radius: 12px;
  background: var(--panel); border: 2px dashed var(--border);
}
.slot-num {
  flex: 0 0 52px; display: grid; place-items: center; font-weight: 900; font-size: 22px; color: var(--muted);
  border-right: 1px solid var(--border);
}
.slot-empty { align-self: center; color: var(--muted); }
.slot .card { flex: 1; margin: 4px 4px 4px 0; padding: 8px 12px; box-shadow: none; animation: pop .25s ease-out; }
.slot .card-name { font-size: 15px; }
.slot .card-sub { font-size: 12px; margin-top: 1px; }
.slot .card-mark { font-size: 48px; bottom: -10px; }
.slot.open { cursor: pointer; }
.slot.open:hover { border-color: var(--accent); background: #211c12; }
.slot.open:hover .slot-num { color: var(--accent); }
.slot.filled { border-style: solid; }
.slot.filled .slot-num { color: var(--text); }

.done-box { text-align: center; padding: 34px 22px; }
.done-box .big-emoji { font-size: 54px; }
.done-box h2 { margin: 8px 0 6px; }
.done-box .btn-row { justify-content: center; margin-top: 18px; }

/* ---------- tier list ---------- */
.tiers { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.tier { display: flex; min-height: 86px; border-bottom: 1px solid var(--border); }
.tier:last-child { border-bottom: none; }
.tier-label {
  flex: 0 0 96px; display: grid; place-items: center; text-align: center; padding: 8px;
  color: #1a1a1a; font-weight: 900; font-size: 26px; outline: none; word-break: break-word;
}
.tier-label:focus { box-shadow: inset 0 0 0 3px rgba(0,0,0,.35); }
.zone { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; align-content: flex-start; transition: background .12s; }
.zone.over { background: #232a3a; }
.zone.can-drop { cursor: pointer; }
.zone.can-drop:hover { background: #1d2331; }

.pool-wrap { margin-top: 18px; }
.pool-wrap h3 { font-size: 15px; margin-bottom: 8px; color: var(--muted); }
.pool { min-height: 90px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--panel); }

.chip {
  width: 128px; min-height: 70px; border-radius: 10px; padding: 8px 10px; cursor: grab; user-select: none;
  position: relative; overflow: hidden; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); transition: transform .1s, box-shadow .1s;
}
.chip:hover { transform: translateY(-2px); }
.chip:active { cursor: grabbing; }
.chip.selected { box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }
.chip.dragging { opacity: .4; }
.chip .card-name { font-size: 13px; font-weight: 800; }
.chip .card-sub { font-size: 11px; margin-top: 2px; }
.chip .card-mark { font-size: 44px; bottom: -10px; right: -4px; }

.tier-help { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 50;
  background: #fff; color: #111; padding: 10px 18px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

/* ---------- responsive ---------- */
@media (max-width: 800px) {
  .blind { grid-template-columns: 1fr; }
  .stage { position: static; }
  .card.big { min-height: 150px; }
  .tier-label { flex-basis: 64px; font-size: 20px; }
  .chip { width: 104px; }
}
