:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: #101116;
  --panel-2: #161820;
  --line: #2A2D34;
  --text: #F3F5FF;
  --muted: #B8BBC4;
  --brand: #8EDBFF;
  --good: #9B7CFF;
  --warn: #F1A7C8;
  --danger: #F1A7C8;
  --lavender: #9B7CFF;
  --ice: #8EDBFF;
  --pink: #F1A7C8;
  --glow: #F3F5FF;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(155, 124, 255, .18), transparent 32rem),
    radial-gradient(circle at 86% 8%, rgba(142, 219, 255, .12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  overflow-x: hidden;
}
button, input, select {
  font: inherit;
}
button {
  border: 1px solid rgba(184, 187, 196, .22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(155, 124, 255, .22), rgba(42, 45, 52, .92));
  color: var(--text);
  min-height: 44px;
  padding: 0 18px;
  cursor: pointer;
}
button:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 5, 7, .8);
  color: var(--text);
  padding: 0 12px;
}
label {
  color: var(--muted);
  font-size: 14px;
}
.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}
.view { display: none; }
.view.active { display: block; }
.brand {
  padding: 10vh 0 48px;
}
.eyebrow {
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0;
}
h1, h2, p { margin: 0; }
h1 {
  font-size: clamp(48px, 8vw, 96px);
  line-height: 1;
}
.brand p:last-child {
  margin-top: 16px;
  color: var(--muted);
  font-size: 20px;
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.mode-button {
  min-height: 180px;
  text-align: left;
  padding: 24px;
  background: linear-gradient(135deg, rgba(155, 124, 255, .2), rgba(16, 17, 22, .96));
}
.mode-button span {
  display: block;
  font-size: 30px;
  font-weight: 800;
}
.mode-button small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 17, 22, .94);
}
.auth-panel {
  width: min(460px, 100%);
  margin: 12vh auto 0;
  padding: 24px;
  display: grid;
  gap: 12px;
}
.login-ad {
  min-height: 96px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px dashed rgba(184, 187, 196, .28);
  border-radius: 8px;
  background: rgba(5, 5, 7, .7);
  color: var(--muted);
  text-align: center;
}
.login-ad strong {
  color: var(--text);
}
.streamer-ad {
  border-color: rgba(142, 219, 255, .55);
}
.guest-ad {
  border-color: rgba(241, 167, 200, .55);
}
.back-btn {
  margin-top: 16px;
}
.ghost {
  background: transparent;
}
.message {
  min-height: 24px;
  color: var(--warn);
}
.game-layout {
  width: min(1768px, calc(100vw - 20px));
  margin: 0 auto;
  transform: none;
}
.game-topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 17, 22, .92);
}
.player-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(5, 5, 7, .86);
  object-fit: cover;
}
#playerRoleLabel {
  font-size: 20px;
}
#playerIdLabel {
  color: var(--brand);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#modeLabel {
  color: var(--muted);
}
.profile-trust {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.player-name-with-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.trust-badge {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.trust-badge-verified {
  background: #1e8f51;
  color: #ffffff;
}
.trust-badge-hack {
  background: #45111d;
  color: #ff6f91;
  border: 1px solid #ff6f91;
}
.small-button {
  min-height: 34px;
  padding: 0 10px;
}
.timer-strip {
  display: flex;
  gap: 16px;
  color: var(--muted);
}
.timer-strip b {
  color: var(--text);
}
.live-button.online {
  border-color: var(--good);
  color: var(--good);
}
.hidden { display: none !important; }
.game-main {
  display: grid;
  grid-template-columns: 240px 260px minmax(720px, 720px) 260px 240px;
  grid-template-areas: "mode queue board event info";
  gap: 12px;
  align-items: start;
  justify-content: center;
}
.mode-panel { grid-area: mode; }
.queue-panel { grid-area: queue; }
.board-wrap { grid-area: board; }
.multi-monitor-panel { grid-area: event; }
.event-panel { grid-area: event; }
.info-panel { grid-area: info; }
.mode-panel, .info-panel, .queue-panel, .event-panel, .multi-monitor-panel {
  padding: 16px;
  display: grid;
  gap: 10px;
}
.mode-chip.active {
  border-color: var(--brand);
  background: #183b52;
}
.pack-box {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}
.pack-credit {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.pack-credit img {
  width: 100%;
  max-height: 90px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}
.pack-credit a {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}
.event-launchpad {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}
.event-launchpad h3 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.event-launchpad button {
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}
.event-launch-button {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.event-launch-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid #ffffffaa;
  border-radius: 50%;
  overflow: hidden;
  font-weight: 900;
}
.event-launch-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.event-launch-title,
.event-launch-menu-image {
  min-width: 0;
  overflow-wrap: anywhere;
}
.danger-button {
  border-color: #ff6f91;
  color: #ffb1c2;
  background: rgba(255, 111, 145, .08);
}
.event-launch-title {
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-launch-menu-image img {
  width: 100%;
  max-height: 54px;
  object-fit: contain;
  border-radius: 8px;
}
.broadcast-hud-card {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 14, 24, .78);
}
.broadcast-hud-card strong {
  font-size: 28px;
  line-height: 1.1;
}
.broadcast-hud-card span {
  font-size: 15px;
}
.hud-tools {
  display: flex;
  gap: 8px;
}
.hud-tools button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
}
.event-queue-list {
  display: grid;
  gap: 6px;
  max-height: none;
  overflow: auto;
}
.mini-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.mini-field input {
  min-height: 34px;
  padding: 6px 8px;
}
.queue-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
}
.queue-item img,
.queue-tier-fallback {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: contain;
  border: 1px solid #ffffff88;
  display: grid;
  place-items: center;
  font-weight: 900;
}
.hint-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.board-wrap {
  position: relative;
  width: min(720px, 100%);
  min-height: 760px;
  display: grid;
  place-items: center;
  align-content: start;
  gap: 10px;
}
.tier-progress-strip {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 4px;
}
.board-hud-strip {
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.board-hud-strip > * {
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 14, 24, .86);
  font-size: 18px;
}
.tier-progress-item {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
  overflow: hidden;
  color: #f5f7fb;
  font-weight: 900;
}
.tier-progress-item img {
  width: 100%;
  height: 40px;
  object-fit: contain;
}
#gameCanvas {
  width: min(720px, 100%);
  aspect-ratio: 720 / 1240;
  border: 1px solid #4a6380;
  border-radius: 8px;
  background: #07101a;
  transition: transform .65s ease;
  transform-origin: center;
}
.board-wrap.bottle-flip #gameCanvas {
  transform: rotate(180deg);
}
.away-overlay, .countdown-overlay, .content-end-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: rgba(5, 9, 15, .88);
  border-radius: 8px;
  text-align: center;
  padding: 20px;
}
.away-overlay h2 {
  font-size: 42px;
}
.away-overlay p {
  color: var(--muted);
}
.ad-box {
  width: min(340px, 80%);
  min-height: 90px;
  display: grid;
  place-items: center;
  border: 1px dashed #617894;
  color: var(--muted);
  overflow: hidden;
  text-align: center;
  padding: 10px;
}
.ad-box a, .login-ad a {
  color: inherit;
  text-decoration: none;
  display: grid;
  place-items: center;
  gap: 4px;
  width: 100%;
}
.ad-box img, .login-ad img {
  width: 100%;
  max-height: 110px;
  object-fit: cover;
  border-radius: 6px;
}
.countdown-overlay {
  font-size: 92px;
  font-weight: 900;
}
.content-end-card {
  width: min(560px, 86%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 18, 30, .94);
}
.content-end-card h2 {
  margin: 0;
  font-size: 42px;
}
.content-end-card p {
  color: var(--muted);
}
#contentEndTimer {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 54px;
  font-weight: 900;
}
.content-end-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-weight: 700; }

.rank-board, .multi-panel {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 100%;
}
.rank-board h3, .multi-panel h3 {
  margin: 8px 0 2px;
  font-size: 16px;
}
.rank-board h3 small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.rank-tier {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
}
.rank-tier h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  color: var(--accent);
}
.rank-tier ol, .multi-standings {
  margin: 0;
  padding-left: 20px;
}
.rank-tier li, .multi-standings li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  color: #f5f7fb;
}
.small-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #203551;
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  cursor: pointer;
}
.rank-history-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 12, .76);
}
.rank-history-card {
  width: min(860px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}
.rank-history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.rank-history-head h2,
.rank-history-week h3,
.rank-history-week h4 {
  margin: 0;
}
.rank-history-head p {
  margin: 4px 0 0;
  color: var(--muted);
}
.rank-history-list {
  display: grid;
  gap: 12px;
}
.rank-history-week {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
  padding: 12px;
}
.rank-history-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.rank-history-columns ol {
  margin: 8px 0 0;
  padding-left: 20px;
}
.rank-history-columns li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.room-code {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
}
.room-code b {
  display: block;
  font-size: 24px;
  letter-spacing: 2px;
}
.room-state {
  color: var(--accent);
  font-weight: 900;
}
.monitor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.multi-monitor-panel {
  min-height: 760px;
  align-self: stretch;
}
.monitor-grid-large {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  max-height: none;
  gap: 6px;
}
.monitor-card {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
}
.monitor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.monitor-snapshot,
.monitor-empty {
  width: 100%;
  aspect-ratio: 9 / 12;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050914;
}
.monitor-snapshot {
  object-fit: cover;
}
.monitor-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.monitor-card-empty {
  opacity: .78;
}
.monitor-card span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}
.monitor-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.monitor-head .small-button {
  min-height: 24px;
  padding: 0 6px;
  font-size: 11px;
}
.multi-ready-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.multi-rule-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1724;
}
.multi-rule-card h3 {
  margin: 0;
}

@media (max-width: 1500px) {
  .game-layout {
    width: min(1224px, calc(100vw - 20px));
    margin: 0 auto;
  }
  .game-main {
    grid-template-columns: 240px minmax(720px, 720px) 240px;
    grid-template-areas:
      "mode board info"
      "queue board event";
  }
}

@media (min-width: 1501px) {
  .game-layout {
    margin: 0 auto;
    transform: translateX(-260px);
  }
}

@media (max-width: 900px) {
  .mode-grid, .game-main, .game-topbar {
    grid-template-columns: 1fr;
  }
  .game-main {
    grid-template-areas:
      "mode"
      "queue"
      "board"
      "event"
      "info";
  }
  .timer-strip {
    justify-content: space-between;
  }
  .rank-history-columns {
    grid-template-columns: 1fr;
  }
  .board-wrap {
    min-height: auto;
  }
}
