:root {
  --bg: #06111f;
  --bg-deep: #020814;
  --panel: #0b1b2d;
  --panel-2: #0f253d;
  --line: rgba(148, 163, 184, 0.2);
  --text: #eef6ff;
  --muted: #93a8bf;
  --purple: #742fe6;
  --purple-2: #9b5cff;
  --yellow: #ffd43b;
  --green: #31d36b;
  --red: #ff5570;
  --blue: #39a5ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(116, 47, 230, 0.2), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(255, 212, 59, 0.12), transparent 28rem),
    linear-gradient(160deg, var(--bg-deep), var(--bg) 45%, #07182b);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
}

.noscript {
  margin: 1rem auto;
  max-width: 28rem;
  padding: 1rem;
  border: 1px solid var(--red);
  border-radius: 1rem;
  background: rgba(255, 85, 112, 0.1);
  text-align: center;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
}

.desktop-frame {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(280px, 1fr);
  gap: 1rem;
  align-items: start;
}

.desktop-frame.single {
  grid-template-columns: minmax(0, 440px);
  justify-content: center;
}

.side-panel {
  display: grid;
  gap: 1rem;
}

.phone-card,
.info-panel {
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012)),
    rgba(7, 19, 34, 0.94);
  box-shadow: var(--shadow);
}

.phone-card {
  min-height: min(720px, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.info-panel {
  max-width: 680px;
  padding: 1rem;
}

.screen {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.loading-card {
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.brand {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  margin: 0.5rem 0 1rem;
  text-align: center;
}

.brand-logo {
  display: block;
  width: min(230px, 78%);
  height: auto;
  max-height: 118px;
  object-fit: contain;
}

.brand-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 0;
}

.brand-mini img {
  width: 96px;
  max-height: 42px;
  height: auto;
  object-fit: contain;
}

.brand-mini strong,
.logo-fallback {
  color: var(--yellow);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tagline {
  margin: 0;
  color: #dceaff;
  font-size: 0.98rem;
}

.topbar {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) 2.6rem;
  align-items: center;
  gap: 0.5rem;
}

.topbar-title {
  min-width: 0;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.stack {
  display: grid;
  gap: 0.7rem;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.wrap {
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.72rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.headline {
  margin: 0;
  font-size: clamp(1.5rem, 7vw, 2.35rem);
  line-height: 1.02;
}

.yellow {
  color: var(--yellow);
}

.green {
  color: var(--green);
}

.red {
  color: var(--red);
}

.btn {
  min-height: 3rem;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 850;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--purple-2), var(--purple));
  box-shadow: 0 10px 26px rgba(116, 47, 230, 0.34);
}

.btn-ghost {
  border-color: var(--line);
  background: rgba(5, 14, 25, 0.58);
}

.btn-outline {
  border-color: rgba(155, 92, 255, 0.72);
  background: rgba(116, 47, 230, 0.08);
  color: #e4d7ff;
}

.btn-small {
  width: auto;
  min-height: 2.25rem;
  padding: 0.45rem 0.72rem;
  border-radius: 0.72rem;
  font-size: 0.82rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.input,
.select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.82rem;
  outline: none;
  background: rgba(3, 10, 20, 0.7);
  color: var(--text);
}

.input:focus,
.select:focus {
  border-color: var(--purple-2);
  box-shadow: 0 0 0 3px rgba(155, 92, 255, 0.18);
}

.segmented,
.option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chip {
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-weight: 800;
}

.chip.active {
  border-color: var(--purple-2);
  background: linear-gradient(180deg, rgba(155, 92, 255, 0.98), rgba(116, 47, 230, 0.9));
}

.suggestion-list {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.suggestion-chip {
  width: auto;
  min-height: 2.2rem;
  padding: 0.4rem 0.65rem;
  text-align: left;
}

.card {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.035);
}

.code-box {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  padding: 0.8rem;
  border-radius: 1rem;
  background: rgba(116, 47, 230, 0.18);
}

.room-code {
  color: #d8b4fe;
  font-size: 1.45rem;
  font-weight: 950;
  letter-spacing: 0.22em;
}

.player-list {
  display: grid;
  gap: 0.55rem;
}

.player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.62rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(5, 14, 25, 0.5);
}

.avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #273d5e, #10233a);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.48rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
}

.badge.host {
  color: #2a2000;
  background: var(--yellow);
}

.badge.ready {
  color: var(--green);
}

.badge.wait {
  color: var(--yellow);
}

.badge.offline {
  color: var(--red);
}

.timer {
  color: var(--yellow);
  font-size: 1.28rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.word-card {
  min-width: 0;
  min-height: 7rem;
  display: grid;
  place-items: center;
  gap: 0.35rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(116, 47, 230, 0.22), rgba(6, 17, 31, 0.6));
  color: var(--text);
  text-align: center;
}

.word-card strong {
  color: var(--text);
  font-size: 0.82rem;
}

.word-icon {
  font-size: 2rem;
}

.game-layout {
  min-width: 0;
  display: grid;
  gap: 0.75rem;
}

.game-layout.two {
  grid-template-columns: minmax(0, 1fr);
}

.hint-list,
.guess-feed,
.rank-list,
.history-list {
  min-width: 0;
  display: grid;
  gap: 0.45rem;
}

.hint-item,
.guess-item,
.rank-item,
.history-item {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem;
  border-radius: 0.72rem;
  background: rgba(255, 255, 255, 0.04);
}

.hint-item {
  grid-template-columns: auto minmax(0, 1fr);
}

.guess-item.correct {
  border: 1px solid rgba(49, 211, 107, 0.35);
  background: rgba(49, 211, 107, 0.08);
}

.guess-text,
.history-word {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pattern {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: clamp(1.35rem, 8vw, 2rem);
  font-weight: 950;
  letter-spacing: 0.04em;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.stat {
  min-width: 0;
  padding: 0.75rem;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.2rem;
}

.guess-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  margin: auto -1rem -1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(5, 14, 25, 0.96);
  backdrop-filter: blur(12px);
}

.guess-bar .btn {
  width: auto;
  min-width: 5.25rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(92vw, 380px);
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 85, 112, 0.4);
  border-radius: 1rem;
  background: rgba(38, 8, 18, 0.96);
  color: #ffd6df;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.hidden {
  display: none !important;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.04);
}

.switch {
  width: 3rem;
  height: 1.6rem;
  padding: 0.16rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.switch span {
  display: block;
  width: 1.28rem;
  height: 1.28rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}

.switch.on {
  background: var(--green);
}

.switch.on span {
  transform: translateX(1.38rem);
}

.confetti {
  min-height: 6rem;
  display: grid;
  place-items: center;
  text-align: center;
}

.trophy {
  font-size: 3rem;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 0.55rem;
}

.podium-place {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.75rem 0.45rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.04);
}

.podium-place.first {
  min-height: 8.8rem;
  background: linear-gradient(180deg, rgba(255, 212, 59, 0.24), rgba(255, 212, 59, 0.08));
}

.podium-place.second,
.podium-place.third {
  min-height: 7.4rem;
}

.quick-guide {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
}

.quick-step {
  min-width: 0;
  padding: 0.7rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
}

.quick-step strong {
  display: block;
  color: var(--yellow);
  font-size: 1.35rem;
}

@media (min-width: 860px) {
  .app-shell {
    padding: 2rem;
  }

  .game-layout.two {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  }

  .desktop-frame.single {
    grid-template-columns: minmax(0, 440px) minmax(260px, 420px);
  }

  .brand {
    justify-items: start;
    text-align: left;
  }

  .home-screen .brand {
    justify-items: center;
    text-align: center;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 0.5rem;
    align-items: stretch;
  }

  .desktop-frame,
  .desktop-frame.single,
  .phone-card,
  .info-panel {
    width: 100%;
  }

  .desktop-frame {
    grid-template-columns: minmax(0, 1fr);
  }

  .phone-card {
    min-height: calc(100vh - 1rem);
    border-radius: 1.35rem;
  }

  .screen {
    padding: 0.85rem;
  }

  .word-grid,
  .stat-grid {
    gap: 0.55rem;
  }

  .word-card {
    min-height: 6.4rem;
  }

  .guess-bar {
    margin-left: -0.85rem;
    margin-right: -0.85rem;
    margin-bottom: -0.85rem;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .quick-guide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .segmented,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .word-grid {
    grid-template-columns: 1fr;
  }

  .guess-bar {
    grid-template-columns: 1fr;
  }

  .guess-bar .btn {
    width: 100%;
  }
}
