/* FRAMED — dark HUD, two player colors carry the whole UI.
   p1 = teal, p2 = pink. Every vote, rank and frame is color-coded. */
:root {
  --bg: #121018;
  --surface: #1b1826;
  --surface-2: #241f33;
  --line: #322b47;
  --text: #ece9f4;
  --muted: #8f88a6;
  --p1: #2ee6d0;   /* teal */
  --p2: #ff5fa2;   /* pink */
  --gold: #ffd166;
  --danger: #ff6b6b;
  --radius: 12px;
  --display: 'Chakra Petch', sans-serif;
  --body: 'Rubik', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--body); font-size: 15px; line-height: 1.5;
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; outline: none;
}
input:focus { border-color: var(--p1); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { font-family: var(--display); letter-spacing: .02em; }
.hud-label {
  font-family: var(--display); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .18em; color: var(--muted);
  margin: 28px 0 12px;
}

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  padding: 10px 18px; font-weight: 500; transition: transform .06s, filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(105deg, var(--p1), #23b8f0);
  color: #06231f; border: none; font-weight: 700;
  font-family: var(--display); text-transform: uppercase; letter-spacing: .06em;
}
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--p1); outline-offset: 2px; }

/* ---- logo: three tilted item frames, a nod to Minecraft ---- */
.logo { display: inline-flex; gap: 6px; }
.logo-frame {
  width: 22px; height: 22px; border-radius: 4px; display: inline-block;
  border: 2.5px solid var(--muted);
}
.logo-frame.f1 { border-color: var(--p1); transform: rotate(-8deg); }
.logo-frame.f2 { border-color: var(--gold); transform: translateY(-3px); }
.logo-frame.f3 { border-color: var(--p2); transform: rotate(8deg); }
.logo.mini .logo-frame { width: 12px; height: 12px; border-width: 2px; border-radius: 3px; }

/* ---- login ---- */
.login-body { display: grid; place-items: center; padding: 24px; }
.login-card {
  text-align: center; max-width: 380px; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 44px 32px;
}
.login-card h1 { margin: 16px 0 4px; font-size: 34px; letter-spacing: .14em; }
.tagline { color: var(--muted); margin: 0 0 28px; }
.login-form { display: flex; gap: 8px; }
.login-form input { flex: 1; }
.login-msg { min-height: 20px; color: var(--p2); }

/* ---- layout ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(18,16,24,.9); backdrop-filter: blur(8px); z-index: 10;
}
.brand {
  font-family: var(--display); font-weight: 700; letter-spacing: .14em;
  color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 10px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.player-chip {
  font-family: var(--display); font-size: 13px; font-weight: 700;
  padding: 4px 12px; border-radius: 99px; border: 1.5px solid;
}
.player-chip.p1 { color: var(--p1); border-color: var(--p1); }
.player-chip.p2 { color: var(--p2); border-color: var(--p2); }
.view { max-width: 1060px; margin: 0 auto; padding: 12px 20px 80px; }

/* ---- dashboard ---- */
.new-session-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
#new-name { flex: 1 1 240px; }
.mode-pick { display: flex; gap: 8px; }
.mode-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); padding: 8px 14px; text-align: left; display: grid;
}
.mode-btn span { font-size: 12px; color: var(--muted); }
.mode-btn.selected { border-color: var(--p1); box-shadow: 0 0 0 1px var(--p1); }
.session-list { display: grid; gap: 10px; }
.session-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; color: var(--text); text-align: left; width: 100%;
}
.session-card:hover { border-color: var(--muted); }
.session-card .s-name { font-weight: 700; font-family: var(--display); }
.session-card .s-meta { margin-left: auto; color: var(--muted); font-size: 13px; }
.badge {
  font-family: var(--display); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; padding: 3px 10px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.live { color: var(--gold); border-color: var(--gold); }
.badge.done { color: var(--p1); border-color: var(--p1); }

/* ---- session ---- */
.session-head { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; }
.session-head h2 { margin: 0; flex: 1; font-size: 22px; }

/* setup */
.drop-zone {
  border: 2px dashed var(--line); border-radius: 16px; text-align: center;
  padding: 34px 20px; margin-top: 16px; cursor: pointer; transition: border-color .15s;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--p1); }
.drop-zone p { margin: 4px 0; }
.thumb-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; margin-top: 18px;
}
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  border: 2px solid var(--line);
}
.thumb.by-p1 { border-color: var(--p1); }
.thumb.by-p2 { border-color: var(--p2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .rm {
  position: absolute; top: 4px; right: 4px; border: none; border-radius: 6px;
  background: rgba(0,0,0,.65); color: #fff; width: 24px; height: 24px; line-height: 1;
}
.setup-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }

/* classic ranking */
.rank-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.rank-status { display: flex; align-items: center; gap: 12px; }
.rank-scale {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 8px;
  font-family: var(--display); font-size: 11px; font-weight: 700; letter-spacing: .18em;
}
.rank-scale span:first-child { color: var(--danger); }
.rank-scale span:last-child { color: var(--gold); }
.rank-scale-line { flex: 1; height: 2px; background: linear-gradient(90deg, var(--danger), var(--gold)); border-radius: 2px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px 8px 8px; cursor: grab; user-select: none;
}
.rank-item.sortable-ghost { opacity: .35; }
.rank-item.sortable-chosen { border-color: var(--p1); }
.rank-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.rank-item .num {
  font-family: var(--display); font-weight: 700; font-size: 15px;
  width: 34px; text-align: center; color: var(--muted);
}
.rank-item .grip {
  margin-left: auto; color: var(--muted); font-size: 20px;
  padding: 16px 14px; cursor: grab; touch-action: none;
  border-radius: 8px;
}
.rank-item .grip:active { color: var(--text); cursor: grabbing; }
.rank-item { cursor: default; }

/* waiting */
.center-stage { text-align: center; padding: 60px 0; }
.pulse-ring {
  width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid var(--p1); animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.8); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }

/* results */
.sync-banner {
  display: flex; align-items: center; gap: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 24px; margin-top: 18px;
}
.sync-score { font-family: var(--display); font-weight: 700; font-size: 52px; line-height: 1;
  background: linear-gradient(105deg, var(--p1), var(--p2));
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.sync-pct { font-size: 24px; }
.sync-text h3 { margin: 0 0 4px; }
.sync-text p { margin: 0; }
.pairs { display: grid; gap: 12px; }
.pair {
  display: grid; grid-template-columns: 56px 1fr 46px 1fr; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.pair .pos { font-family: var(--display); font-weight: 700; text-align: center; color: var(--muted); }
.pair .pos strong { display: block; font-size: 20px; color: var(--text); }
.pair-side { display: flex; align-items: center; gap: 10px; }
.pair-side img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; border: 2.5px solid; cursor: zoom-in; }
.pair-side.side-p1 img { border-color: var(--p1); }
.pair-side.side-p2 img { border-color: var(--p2); flex-direction: row-reverse; }
.pair-side.side-p2 { flex-direction: row-reverse; }
.pair .vs { font-family: var(--display); font-weight: 700; text-align: center; color: var(--muted); }
.pair.match-same { border-color: var(--gold); }
.pair.match-same .vs { color: var(--gold); }
.pair-name { font-size: 12px; color: var(--muted); word-break: break-all; max-width: 140px; }

/* ---- tournament ---- */
.vs-card {
  position: relative; border-radius: 18px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface); margin-top: 18px;
}
.vs-head {
  display: flex; justify-content: space-between; padding: 14px 18px;
  font-family: var(--display); font-weight: 700; letter-spacing: .1em; font-size: 13px;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line);
}
.vs-arena { display: grid; grid-template-columns: 1fr 70px 1fr; align-items: stretch; }
.vs-slot { padding: 16px; display: grid; gap: 10px; justify-items: center; }
.vs-slot img {
  width: 100%; max-height: 380px; object-fit: contain; border-radius: 12px;
  background: #0c0a12; cursor: zoom-in;
}
.vs-mid { display: grid; place-items: center; font-family: var(--display); font-size: 26px; font-weight: 700;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.04), transparent); }
.pick-btn {
  width: 100%; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: var(--radius); padding: 12px; font-family: var(--display); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
}
.pick-btn:hover { border-color: var(--gold); }
.pick-btn.picked { border-color: var(--gold); color: var(--gold); background: rgba(255,209,102,.08); }
.vs-status { text-align: center; padding: 12px; color: var(--muted); border-top: 1px solid var(--line); }

/* RPS duel */
.rps {
  margin-top: 18px; border-radius: 18px; padding: 24px; text-align: center;
  border: 1px solid var(--gold);
  background:
    linear-gradient(115deg, rgba(46,230,208,.10), transparent 45%, transparent 55%, rgba(255,95,162,.10)),
    var(--surface);
}
.rps h3 { margin: 0 0 2px; font-size: 22px; }
.rps .rps-sub { color: var(--muted); margin: 0 0 18px; }
.rps-score { font-family: var(--display); font-weight: 700; font-size: 30px; margin-bottom: 14px; }
.rps-score .me { color: var(--p1); } .rps-score .them { color: var(--p2); }
.rps-hands { display: flex; justify-content: center; gap: 14px; }
.rps-hand {
  font-size: 40px; width: 84px; height: 84px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--surface-2);
  transition: transform .1s;
}
.rps-hand:hover { transform: translateY(-4px); border-color: var(--gold); }
.rps-hand.chosen { border-color: var(--gold); background: rgba(255,209,102,.1); }
.rps-hand:disabled { opacity: .45; }
.rps-log { margin-top: 14px; font-size: 14px; color: var(--muted); display: grid; gap: 2px; }
.rps-log .win { color: var(--p1); } .rps-log .loss { color: var(--p2); }

/* bracket */
.bracket { display: flex; gap: 18px; overflow-x: auto; padding-bottom: 12px; }
.bracket-round { display: grid; gap: 10px; align-content: center; min-width: 190px; }
.bracket-round-title { font-family: var(--display); font-size: 11px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-align: center; }
.b-match { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 4px; }
.b-slot { display: flex; align-items: center; gap: 8px; padding: 3px; border-radius: 7px; }
.b-slot img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.b-slot.won { outline: 2px solid var(--gold); }
.b-slot.lost { opacity: .35; }
.b-tag { margin-left: auto; font-size: 10px; font-family: var(--display); font-weight: 700;
  letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.champion-frame img {
  max-width: min(480px, 90vw); max-height: 60vh; border-radius: 16px;
  border: 3px solid var(--gold); box-shadow: 0 0 60px rgba(255,209,102,.25);
}

/* lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(10,8,15,.92); z-index: 50;
  display: grid; place-items: center; cursor: zoom-out; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (max-width: 720px) {
  .vs-arena { grid-template-columns: 1fr; }
  .vs-mid { padding: 6px; }
  .pair { grid-template-columns: 40px 1fr; }
  .pair .vs { display: none; }
  .pair-side.side-p2 { flex-direction: row; }
  .pair-side img { width: 84px; height: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
