:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: #090a0d;
  color: #f7f8fb;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #090a0d;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 75% -20%, rgba(69, 118, 255, 0.2), transparent 34rem),
    linear-gradient(180deg, #101116 0%, #090a0d 44%, #08090b 100%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.16;
}

.ambient-one {
  top: 20%;
  left: -12rem;
  background: #7748ff;
}

.ambient-two {
  right: -12rem;
  bottom: -5rem;
  background: #2d70ff;
}

.login-screen {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 20px;
}

body.auth-pending .login-screen {
  visibility: hidden;
}

.login-card {
  width: min(100%, 410px);
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 24px;
  background: rgba(19, 21, 28, 0.92);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(20px);
}

.login-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 27px;
}

.login-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 0;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #467aff, #6654ed);
  box-shadow: 0 12px 32px rgba(61, 104, 255, 0.3);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}

.language-switcher {
  position: relative;
  z-index: 30;
}

.language-toggle {
  display: flex;
  min-width: 164px;
  height: 42px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(7, 8, 12, 0.72);
  color: #eff1f7;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease;
}

.language-toggle:hover,
.language-toggle:focus-visible,
.language-toggle[aria-expanded="true"] {
  border-color: rgba(103, 139, 255, 0.55);
  background: rgba(34, 38, 51, 0.95);
  outline: none;
}

.language-flag {
  display: inline-grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
  font-size: 20px;
  line-height: 1;
}

.language-current {
  overflow: hidden;
  flex: 1 1 auto;
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-code,
.language-option small {
  color: #a8afc2;
  font-size: 10px;
  font-weight: 800;
}

.language-chevron {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 2px solid #777f93;
  border-bottom: 2px solid #777f93;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
}

.language-toggle[aria-expanded="true"] .language-chevron {
  transform: rotate(225deg) translate(-1px, -1px);
}

.language-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 17px;
  background: #282a2e;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.46);
}

.language-option {
  display: grid;
  width: 100%;
  min-height: 54px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #f6f7fb;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  text-align: left;
}

.language-option:hover,
.language-option:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.language-option[aria-selected="true"] {
  border-color: #5e79e7;
  background: rgba(77, 101, 190, 0.34);
}

.language-option[aria-selected="true"] small {
  color: #d7deff;
}

.login-card h1 {
  margin: 0;
  color: #f7f8fb;
  font-size: 31px;
  letter-spacing: -0.04em;
}

.login-intro {
  margin: 10px 0 20px;
  color: #8f94a2;
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(7, 8, 12, 0.62);
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #777d8c;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.auth-tab.is-active {
  background: rgba(82, 113, 235, 0.22);
  box-shadow: inset 0 0 0 1px rgba(112, 139, 255, 0.2);
  color: #f4f6ff;
}

.auth-tab:focus-visible {
  outline: 2px solid #6689ff;
  outline-offset: 2px;
}

.auth-form {
  margin-top: 6px;
}

.login-field {
  display: grid;
  gap: 8px;
  margin-top: 17px;
  color: #b7bbc7;
  font-size: 12px;
  font-weight: 700;
}

.login-field input {
  width: 100%;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  outline: none;
  background: rgba(7, 8, 12, 0.7);
  color: #f7f8fb;
  font: inherit;
  font-size: 14px;
  padding: 0 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.login-field input:focus {
  border-color: #6689ff;
  box-shadow: 0 0 0 3px rgba(74, 116, 255, 0.14);
}

.login-field input::placeholder {
  color: #555a68;
}

.login-message {
  min-height: 20px;
  margin: 12px 0 2px;
  color: #ff7c83;
  font-size: 12px;
  line-height: 1.6;
}

.login-submit {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, #477cff, #6355ec);
  box-shadow: 0 10px 28px rgba(62, 97, 229, 0.28);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.login-submit:hover,
.login-submit:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.login-submit:disabled {
  cursor: wait;
  filter: saturate(0.4);
  opacity: 0.65;
}

.login-note {
  display: block;
  margin-top: 17px;
  color: #666b79;
  font-size: 10px;
  line-height: 1.65;
  text-align: center;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.hall-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.hall-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 9px;
}

.language-toggle-compact {
  min-width: 138px;
  height: 42px;
  background: rgba(255, 255, 255, 0.04);
}

.hall-balance {
  display: flex;
  min-height: 42px;
  min-width: 132px;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 9px;
  padding: 5px 14px;
  border: 1px solid rgba(103, 139, 255, 0.32);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(79, 116, 238, 0.15), rgba(93, 70, 196, 0.09)),
    rgba(255, 255, 255, 0.035);
  box-shadow: 0 10px 30px rgba(18, 37, 93, 0.18), inset 0 1px rgba(255, 255, 255, 0.035);
}

.hall-balance-mark {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: rgba(83, 125, 255, 0.18);
  color: #aebfff;
  font-size: 13px;
  font-weight: 850;
}

.hall-balance-copy {
  display: grid;
  gap: 1px;
  line-height: 1.1;
  white-space: nowrap;
}

.hall-balance-copy small {
  color: #858b9d;
  font-size: 9px;
  font-weight: 650;
}

#realtimeStatus[data-state="open"] { color: #62dca4; }
#realtimeStatus[data-state="closed"],
#realtimeStatus[data-state="reconnecting"] { color: #e3b962; }

.hall-balance-copy strong {
  color: #f4f7ff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.member-menu {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.member-avatar {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: rgba(83, 125, 255, 0.18);
  color: #aebfff;
  font-size: 11px;
  font-weight: 850;
}

.member-summary {
  display: grid;
  min-width: 74px;
  gap: 1px;
}

.member-summary strong {
  overflow: hidden;
  max-width: 110px;
  color: #eef0f6;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-summary small {
  color: #737887;
  font-size: 9px;
}

.logout-button {
  height: 29px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #aeb3bf;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 0 10px;
}

.logout-button:hover,
.logout-button:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  outline: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 11px;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #467aff, #6654ed);
  box-shadow: 0 9px 28px rgba(61, 104, 255, 0.27);
  color: white;
  font-size: 13px;
  font-weight: 900;
}

.game-count {
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: #9699a5;
  font-size: 12px;
}

.game-count strong {
  color: #f6f7fb;
  font-size: 13px;
}

.hero {
  padding: 54px 0 27px;
}

.eyebrow {
  margin: 0 0 14px;
  color: #6689ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 820;
  letter-spacing: -0.055em;
  line-height: 1.04;
}

.hero > p:last-child {
  margin: 14px 0 0;
  color: #888c98;
  font-size: 14px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 20px 14px;
}

.game-card {
  min-width: 0;
  color: inherit;
  text-decoration: none;
  outline: none;
}

.cover-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 235 / 320;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: #17191f;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.game-cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease, filter 180ms ease;
}

.cover-wrap::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 55%, rgba(4, 5, 8, 0.3));
  pointer-events: none;
}

.play-badge {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: rgba(65, 112, 255, 0.94);
  box-shadow: 0 12px 35px rgba(31, 67, 190, 0.55);
  opacity: 0;
  transform: translate(-50%, -44%) scale(0.88);
  transition: opacity 180ms ease, transform 180ms ease;
}

.play-badge svg {
  width: 20px;
  fill: white;
}

.card-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px 0;
}

.game-title {
  display: block;
  overflow: hidden;
  color: #f2f3f7;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-provider {
  display: block;
  margin-top: 3px;
  color: #6f737e;
  font-size: 9px;
}

.game-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #737782;
  font-size: 9px;
  white-space: nowrap;
}

.game-status {
  padding-top: 2px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-dot.online {
  background: #35d98a;
  box-shadow: 0 0 0 4px rgba(53, 217, 138, 0.08);
}

.status-dot.starting {
  background: #f2ad4e;
  box-shadow: 0 0 0 4px rgba(242, 173, 78, 0.08);
}

.game-card:hover .cover-wrap,
.game-card:focus-visible .cover-wrap {
  border-color: rgba(100, 139, 255, 0.75);
  box-shadow: 0 21px 46px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(70, 113, 255, 0.12);
  transform: translateY(-5px);
}

.game-card:hover .game-cover,
.game-card:focus-visible .game-cover {
  filter: brightness(0.74);
  transform: scale(1.035);
}

.game-card:hover .play-badge,
.game-card:focus-visible .play-badge {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

body.player-open {
  overflow: hidden;
}

body.direct-game-pending {
  overflow: hidden;
  background: #000;
}

body.direct-game-pending .ambient,
body.direct-game-pending .login-screen,
body.direct-game-pending .page-shell {
  visibility: hidden !important;
}

body.direct-game-pending .game-player[hidden] {
  display: grid !important;
}

.game-player {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  background: #050608;
}

.game-player[hidden] {
  display: none;
}

.player-stage {
  position: relative;
  min-height: 0;
  background: #000;
}

.player-stage iframe {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.player-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  pointer-events: none;
  color: #858995;
  font-size: 12px;
}

.player-loading i {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: #5d82ff;
  border-radius: 50%;
  animation: loading-spin 800ms linear infinite;
}

.game-player.is-loaded .player-loading {
  display: none;
}

@keyframes loading-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 820px) {
  .game-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 17px 12px;
  }
}

@media (max-width: 590px) {
  .login-screen {
    padding: 20px 14px;
  }

  .login-card {
    padding: 29px 23px;
    border-radius: 20px;
  }

  .page-shell {
    width: min(100% - 20px, 430px);
    padding-top: 16px;
  }

  .hall-header {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 10px;
  }

  .hall-balance {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .hero {
    padding: 36px 2px 22px;
  }

  .hall-actions {
    gap: 6px;
  }

  .language-toggle-compact {
    min-width: 68px;
    padding: 0 8px;
  }

  .language-toggle-compact .language-current,
  .language-toggle-compact .language-chevron {
    display: none;
  }

  .language-menu {
    width: min(280px, calc(100vw - 28px));
  }

  .game-count {
    display: none;
  }

  .member-menu {
    gap: 7px;
  }

  .member-summary {
    min-width: 60px;
  }

  .member-summary strong {
    max-width: 72px;
  }

  .hero h1 {
    font-size: 29px;
  }

  .game-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 8px;
  }

  .cover-wrap {
    border-radius: 11px;
  }

  .card-meta {
    align-items: center;
    padding: 7px 1px 0;
  }

  .game-title {
    font-size: 10px;
  }

  .game-provider,
  .game-status span {
    display: none;
  }

  .game-status {
    padding: 0 2px 0 0;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
