:root {
  --bg: #090b12;
  --bg-deep: #0d111a;
  --surface: #111827;
  --surface-2: #161d2b;
  --surface-3: #1d2740;
  --surface-4: #24304d;
  --text: #f3f6ff;
  --muted: #98a3bc;
  --soft: #6b7489;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --violet: #6e5bff;
  --blue: #3c8dff;
  --pink: #ff66c4;
  --success: #39d98a;
  --warning: #ffbe5c;
  --danger: #ff5f82;
  --radius-shell: 30px;
  --radius-card: 26px;
  --radius-control: 18px;
  --radius-chip: 999px;
  --shadow-card: 0 22px 60px rgba(0, 0, 0, 0.34);
  --shadow-glow: 0 0 40px rgba(110, 91, 255, 0.22);
  --shadow-glow-strong: 0 0 56px rgba(110, 91, 255, 0.3);
  --shell-gradient:
    radial-gradient(circle at 12% 14%, rgba(110, 91, 255, 0.18), transparent 24%),
    radial-gradient(circle at 88% 18%, rgba(60, 141, 255, 0.14), transparent 20%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  overflow-x: clip;
  background:
    radial-gradient(circle at top, rgba(110, 91, 255, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: clip;
  overflow-x: hidden;
  color: var(--text);
  font-family: Inter, "SF Pro Display", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at top right, rgba(110, 91, 255, 0.1), transparent 22%),
    radial-gradient(circle at top left, rgba(60, 141, 255, 0.07), transparent 18%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

body.modal-open {
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: -1;
  border-radius: 999px;
  filter: blur(14px);
}

body::before {
  top: 54px;
  right: -52px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(110, 91, 255, 0.14), transparent 72%);
}

body::after {
  bottom: 72px;
  left: -54px;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle, rgba(60, 141, 255, 0.1), transparent 72%);
}

html[data-screen="lobby"] body,
body[data-screen="lobby"] {
  background:
    radial-gradient(circle at top center, rgba(110, 91, 255, 0.18), transparent 26%),
    radial-gradient(circle at top left, rgba(60, 141, 255, 0.1), transparent 18%),
    radial-gradient(circle at bottom center, rgba(255, 102, 196, 0.05), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, #0b0f18 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 442px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: clip;
  padding:
    calc(env(safe-area-inset-top, 0px) + 16px)
    16px
    calc(env(safe-area-inset-bottom, 0px) + 28px);
  display: grid;
  gap: 16px;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 300px;
  pointer-events: none;
  background:
    radial-gradient(circle at 25% 0%, rgba(110, 91, 255, 0.08), transparent 34%),
    radial-gradient(circle at 80% 20%, rgba(60, 141, 255, 0.07), transparent 30%);
  opacity: 0.9;
}

body.app-loading {
  overflow: hidden;
}

body.app-ready .app-shell {
  opacity: 1;
  transform: none;
}

.topbar,
.screen,
.screen-head,
.brand-block,
.identity-box,
.hero-card,
.room-card,
.lobby-subsection,
.room-list,
.answer-grid,
.action-stack {
  display: grid;
}

.topbar {
  gap: 12px;
  min-width: 0;
}

html[data-screen="lobby"] .topbar,
body[data-screen="lobby"] .topbar {
  grid-template-columns: minmax(0, 1fr) 152px;
  align-items: start;
  padding: 20px;
  border-radius: 32px;
  border: 1px solid var(--line);
  background: var(--shell-gradient);
  box-shadow: var(--shadow-card);
}

html:not([data-screen="lobby"]) .topbar,
body:not([data-screen="lobby"]) .topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

.brand-block {
  gap: 6px;
  min-width: 0;
}

.eyebrow,
.screen-kicker,
.identity-box label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.045em;
}

h1 {
  font-size: 32px;
  line-height: 0.92;
  font-weight: 900;
}

h2 {
  font-size: 21px;
  line-height: 1.04;
  font-weight: 800;
}

.topbar-caption,
.hero-caption,
.support-line,
.room-subtitle,
.feedback {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.summary-stage,
.summary-highlight,
.summary-rule-list,
.summary-rule-row,
.room-summary-page,
.room-summary-shell {
  display: grid;
}

.summary-stage {
  gap: 18px;
  background:
    radial-gradient(circle at top right, rgba(110, 91, 255, 0.18), transparent 22%),
    radial-gradient(circle at bottom left, rgba(60, 141, 255, 0.1), transparent 20%),
    linear-gradient(180deg, rgba(31, 39, 66, 0.96), rgba(17, 24, 39, 0.98));
}

.summary-highlight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-highlight {
  gap: 8px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 14, 24, 0.34);
}

.summary-highlight-label {
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.summary-highlight-value {
  font-size: 16px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--text);
}

.summary-rule-list {
  gap: 10px;
}

.summary-rule-row {
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(9, 12, 21, 0.4);
}

.summary-rule-label {
  color: var(--soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.summary-rule-value {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.room-summary-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top center, rgba(110, 91, 255, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(60, 141, 255, 0.1), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, #0b0f18 100%);
}

.room-summary-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 24px 16px 40px;
  gap: 18px;
}

.room-summary-topbar {
  display: grid;
  gap: 6px;
}

.room-summary-meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

html:not([data-screen="lobby"]) .topbar-caption,
body:not([data-screen="lobby"]) .topbar-caption {
  display: none;
}

html:not([data-screen="lobby"]) .eyebrow,
body:not([data-screen="lobby"]) .eyebrow {
  display: none;
}

html:not([data-screen="lobby"]) h1,
body:not([data-screen="lobby"]) h1 {
  font-size: 22px;
  line-height: 0.98;
}

.identity-box {
  gap: 0;
  align-content: start;
  justify-self: end;
  min-width: 0;
  padding-top: 4px;
}

.identity-box label,
.identity-box input {
  display: none;
}

input {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border-radius: 19px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(36, 48, 77, 0.66), rgba(17, 24, 39, 0.92));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  outline: none;
}

input::placeholder {
  color: var(--soft);
}

input:focus {
  border-color: rgba(110, 91, 255, 0.46);
  box-shadow: 0 0 0 4px rgba(110, 91, 255, 0.12);
}

.player-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  max-width: 220px;
  padding: 0;
  color: rgba(206, 214, 232, 0.92);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-badge-heart {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  filter: drop-shadow(0 0 8px rgba(110, 91, 255, 0.26));
}

.player-badge-heart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.player-badge-heart path {
  fill: url(#playerBadgeHeartGradient);
}

.player-badge-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

html:not([data-screen="lobby"]) .identity-box,
body:not([data-screen="lobby"]) .identity-box {
  align-self: start;
  justify-self: end;
  width: auto;
  padding-top: 0;
}

.screen-stack {
  display: grid;
  min-width: 0;
  max-width: 100%;
}

.screen {
  display: none;
  min-width: 0;
  max-width: 100%;
}

.screen.active {
  display: grid;
  gap: 12px;
  animation: screenReveal 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes screenReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.screen-head > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.action-stack {
  gap: 10px;
  min-width: 0;
}

.screen-head .action-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.room-screen {
  gap: 10px;
}

.room-screen .screen-head {
  align-items: center;
}

.room-screen .screen-kicker {
  color: var(--soft);
}

.room-list {
  gap: 12px;
  min-height: 224px;
  min-width: 0;
  max-width: 100%;
}

.room-list.compact {
  min-height: 0;
}

.lobby-subsection {
  gap: 10px;
}

.screen-head.compact {
  grid-template-columns: 1fr;
  align-items: start;
  gap: 4px;
}

.screen-head.compact h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-card,
.room-card {
  position: relative;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012)),
    linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(13, 17, 26, 0.98));
  box-shadow: var(--shadow-card);
  min-width: 0;
  overflow: clip;
}

.hero-card::before,
.room-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.04), transparent 24%, transparent 76%, rgba(110, 91, 255, 0.08));
  opacity: 0.9;
  pointer-events: none;
}

.hero-card > *,
.room-card > * {
  position: relative;
  z-index: 1;
}

.room-card-transition {
  transition:
    height 340ms cubic-bezier(0.22, 1, 0.36, 1),
    padding 340ms cubic-bezier(0.22, 1, 0.36, 1),
    border-width 340ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 300ms ease,
    transform 340ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 300ms ease,
    background 260ms ease,
    box-shadow 260ms ease;
  transform-origin: top center;
  will-change: transform, opacity, height, filter;
}

.room-card-transition > * {
  transition:
    opacity 180ms ease,
    transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.lobby-hero {
  background:
    radial-gradient(circle at 16% 16%, rgba(110, 91, 255, 0.22), transparent 22%),
    radial-gradient(circle at 88% 18%, rgba(60, 141, 255, 0.14), transparent 18%),
    linear-gradient(180deg, rgba(29, 39, 64, 0.98), rgba(17, 24, 39, 0.98));
  box-shadow: var(--shadow-card), var(--shadow-glow-strong);
}

#resumeRoomCard,
.room-card.live {
  background:
    radial-gradient(circle at top right, rgba(110, 91, 255, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(28, 36, 58, 0.98), rgba(16, 22, 37, 0.98));
}

.room-card.upcoming {
  gap: 12px;
  padding: 16px 18px;
  background:
    linear-gradient(180deg, rgba(16, 22, 37, 0.92), rgba(13, 17, 26, 0.96));
  box-shadow: none;
}

.room-card.is-entering {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  filter: blur(8px);
}

.room-card.is-leaving {
  pointer-events: none;
  background:
    radial-gradient(circle at top right, rgba(255, 190, 92, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(33, 39, 54, 0.98), rgba(14, 18, 27, 0.98));
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 190, 92, 0.08) inset;
}

.room-card.is-leaving > * {
  opacity: 0.42;
  transform: translateY(-6px) scale(0.992);
}

.room-card.is-leaving::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255, 190, 92, 0.14), transparent 28%, transparent 72%, rgba(110, 91, 255, 0.12));
  opacity: 1;
  transition: opacity 240ms ease;
  pointer-events: none;
}

.room-card.is-leaving-collapsed::after {
  opacity: 0;
}

.lobby-empty-state {
  animation: lobbyEmptyStateReveal 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes lobbyEmptyStateReveal {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status-row,
.room-meta,
.room-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.status-row {
  justify-content: space-between;
}

.room-title {
  font-size: 20px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.room-card.upcoming .room-title {
  font-size: 17px;
}

.lobby-subsection {
  display: grid;
  gap: 10px;
}

.room-subtitle {
  font-size: 13px;
}

.room-trust-line {
  margin-top: 8px;
  color: rgba(211, 219, 239, 0.84);
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.status-row.compact {
  gap: 8px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.join-rules-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  align-items: end;
  padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  overflow-y: auto;
}

.join-rules-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 14, 0.72);
  backdrop-filter: blur(10px);
}

.join-rules-sheet {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
  width: min(100%, 442px);
  margin: 0 auto;
  max-height: min(760px, calc(100dvh - env(safe-area-inset-top, 0px) - 24px));
  padding: 22px 18px 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top left, rgba(110, 91, 255, 0.18), transparent 24%),
    linear-gradient(180deg, rgba(20, 27, 42, 0.98), rgba(11, 15, 24, 0.98));
  box-shadow: var(--shadow-card), var(--shadow-glow);
  overflow: hidden;
}

.join-rules-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.02;
  font-weight: 850;
  letter-spacing: -0.045em;
}

.join-rules-body {
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.join-rules-subtitle,
.join-rules-note,
.join-rules-item-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.join-rules-chip-row,
.join-rules-list {
  display: grid;
  gap: 10px;
}

.join-rules-chip-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.join-rules-chip-row .chip {
  justify-content: center;
}

.join-rules-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, rgba(28, 36, 58, 0.92), rgba(15, 21, 33, 0.96));
}

.join-rules-item-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.join-rules-actions {
  position: sticky;
  bottom: 0;
  margin: 0 -18px -18px;
  padding: 14px 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
  background:
    linear-gradient(180deg, rgba(11, 15, 24, 0), rgba(11, 15, 24, 0.94) 22%, rgba(11, 15, 24, 0.98) 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

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

.history-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.history-heading h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.06;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.history-stats {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.history-filter-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.history-filter-group::-webkit-scrollbar {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.history-filter-button {
  flex: 0 0 auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03));
  color: var(--muted);
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.history-filter-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.history-filter-button.is-active {
  border-color: rgba(110, 91, 255, 0.28);
  background: rgba(110, 91, 255, 0.14);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(110, 91, 255, 0.14);
}

.history-filter-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.history-sort-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-self: end;
}

.history-sort-control::after {
  content: "";
  position: absolute;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid rgba(243, 246, 255, 0.82);
  border-bottom: 1.5px solid rgba(243, 246, 255, 0.82);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}

.history-sort-control select {
  min-width: 154px;
  width: 154px;
  height: 32px;
  padding: 0 32px 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(36, 48, 77, 0.54), rgba(17, 24, 39, 0.9));
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.history-sort-control select:focus {
  border-color: rgba(110, 91, 255, 0.46);
  box-shadow: 0 0 0 4px rgba(110, 91, 255, 0.12);
}

.history-card,
.history-empty-card {
  display: grid;
  gap: 12px;
  padding: 18px 20px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top left, rgba(110, 91, 255, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(21, 28, 43, 0.96), rgba(12, 17, 28, 0.98));
  box-shadow: var(--shadow-card);
}

.history-card-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.14;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.history-card-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-chip);
  border: 1px solid rgba(110, 91, 255, 0.22);
  background: rgba(110, 91, 255, 0.14);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.chip.muted {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.chip.success {
  border-color: rgba(57, 217, 138, 0.28);
  background: rgba(57, 217, 138, 0.14);
  color: #d9ffe9;
}

.chip.danger {
  border-color: rgba(255, 95, 130, 0.28);
  background: rgba(255, 95, 130, 0.12);
  color: #ffd2db;
}

.chip.warning {
  border-color: rgba(255, 190, 92, 0.26);
  background: rgba(255, 190, 92, 0.12);
  color: #ffe2a8;
}

.primary-button,
.secondary-button,
.answer-option {
  border-radius: var(--radius-control);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  padding: 0 13px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.primary-button {
  border: 0;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--violet), var(--blue));
  box-shadow: 0 14px 32px rgba(110, 91, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(110, 91, 255, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.022));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.secondary-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
}

.primary-button:active,
.secondary-button:active,
.answer-option:active {
  transform: scale(0.988);
}

.primary-button[disabled],
.secondary-button[disabled] {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hero-card .primary-button,
.hero-card .secondary-button,
.room-card .primary-button,
.room-card .secondary-button {
  width: 100%;
  min-height: 50px;
  padding-inline: 18px;
}

.room-card.upcoming .secondary-button {
  min-height: 42px;
}

.screen-head .primary-button,
.screen-head .secondary-button {
  width: auto;
  min-height: 36px;
  padding-inline: 12px;
}

.hero-number {
  font-size: 58px;
  line-height: 0.92;
  font-weight: 900;
  letter-spacing: -0.08em;
}

.hero-number.small {
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

#waitingScreen .hero-card,
#resultScreen .hero-card,
#spectatorScreen .hero-card,
#gameplayScreen .hero-card {
  background:
    radial-gradient(circle at top center, rgba(110, 91, 255, 0.13), transparent 32%),
    linear-gradient(180deg, rgba(29, 39, 64, 0.98), rgba(17, 24, 39, 0.98));
}

#waitingScreen .hero-card {
  min-height: 0;
}

.waiting-stage {
  gap: 18px;
  align-content: start;
  background:
    radial-gradient(circle at 12% 12%, rgba(110, 91, 255, 0.2), transparent 24%),
    radial-gradient(circle at 88% 16%, rgba(60, 141, 255, 0.12), transparent 20%),
    linear-gradient(180deg, rgba(29, 39, 64, 0.98), rgba(17, 24, 39, 0.98));
}

.label {
  color: var(--soft);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.waiting-stage-top {
  justify-content: space-between;
}

.waiting-title-block {
  display: grid;
  gap: 8px;
}

.waiting-room-title {
  font-size: 32px;
  line-height: 0.96;
  font-weight: 900;
  letter-spacing: -0.06em;
  text-wrap: balance;
}

.countdown-board {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(110, 91, 255, 0.16);
  background:
    radial-gradient(circle at top center, rgba(110, 91, 255, 0.12), transparent 46%),
    radial-gradient(circle at bottom center, rgba(60, 141, 255, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(14, 20, 33, 0.72), rgba(16, 22, 37, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 18px 40px rgba(0, 0, 0, 0.18);
}

.countdown-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.countdown-presence {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.countdown-unit {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px 8px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(36, 48, 77, 0.7), rgba(19, 27, 44, 0.86));
  text-align: center;
}

.countdown-value {
  display: block;
  font-size: 38px;
  line-height: 0.88;
  font-weight: 900;
  letter-spacing: -0.08em;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.presence-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.presence-copy {
  display: grid;
  gap: 4px;
}

.presence-title {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.presence-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.presence-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.presence-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(110, 91, 255, 0.82), rgba(60, 141, 255, 0.9));
  box-shadow: 0 0 0 4px rgba(110, 91, 255, 0.08);
  animation: presencePulse 1.8s ease-in-out infinite;
}

.presence-dot:nth-child(2) {
  animation-delay: 0.18s;
}

.presence-dot:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes presencePulse {
  0%, 100% {
    transform: scale(0.94);
    opacity: 0.7;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.waiting-support-line {
  color: var(--soft);
  font-size: 13px;
  line-height: 1.5;
}

.support-line {
  padding-top: 2px;
}

.spectator-card {
  gap: 18px;
  min-height: 240px;
  background:
    radial-gradient(circle at top right, rgba(255, 190, 92, 0.14), transparent 24%),
    radial-gradient(circle at bottom left, rgba(60, 141, 255, 0.1), transparent 28%),
    linear-gradient(180deg, rgba(29, 39, 64, 0.98), rgba(17, 24, 39, 0.98));
}

.gameplay-stage {
  gap: 16px;
  background:
    radial-gradient(circle at top center, rgba(110, 91, 255, 0.18), transparent 38%),
    radial-gradient(circle at bottom center, rgba(60, 141, 255, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(29, 39, 64, 0.98), rgba(17, 24, 39, 0.98));
}

.gameplay-stage-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  align-items: start;
}

.gameplay-status {
  justify-content: flex-start;
}

.timer-stack {
  display: grid;
  gap: 8px;
  justify-items: center;
  align-self: start;
}

.timer-orbit {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
}

.timer-ring,
.timer-core {
  position: absolute;
  border-radius: 999px;
}

.timer-ring {
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 44%, transparent 45%),
    conic-gradient(from 180deg, rgba(255, 190, 92, 0.95), rgba(110, 91, 255, 0.88), rgba(60, 141, 255, 0.92), rgba(255, 190, 92, 0.95));
  box-shadow: var(--shadow-glow);
  animation: timerOrbitSpin 8s linear infinite;
}

.timer-orbit[data-state="paused"] .timer-ring {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 44%, transparent 45%),
    conic-gradient(from 180deg, rgba(255, 190, 92, 0.86), rgba(255, 190, 92, 0.34), rgba(110, 91, 255, 0.34), rgba(255, 190, 92, 0.86));
  animation-duration: 14s;
}

.timer-orbit[data-state="danger"] .timer-ring {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 44%, transparent 45%),
    conic-gradient(from 180deg, rgba(255, 95, 130, 0.96), rgba(255, 190, 92, 0.92), rgba(255, 95, 130, 0.96));
  box-shadow: 0 0 44px rgba(255, 95, 130, 0.24);
  animation-duration: 3.4s;
}

.timer-core {
  inset: 12px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(14, 20, 33, 0.98), rgba(18, 26, 42, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

@keyframes timerOrbitSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.timer-value {
  position: relative;
  z-index: 1;
}

.timer-value {
  font-size: 24px;
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: -0.07em;
  font-variant-numeric: tabular-nums;
}

.timer-caption {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
}

.task-prompt {
  font-size: 28px;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.05em;
  text-wrap: balance;
}

#gameplayScreen .task-prompt {
  text-align: center;
  max-width: 11ch;
  margin-inline: auto;
}

.answer-grid {
  gap: 10px;
}

.answer-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(36, 48, 77, 0.9), rgba(24, 33, 55, 0.96));
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  position: relative;
  overflow: clip;
}

.answer-option::after {
  content: "";
  position: absolute;
  inset: auto 14% -18px;
  height: 28px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(110, 91, 255, 0.14), transparent 72%);
  pointer-events: none;
}

.answer-option:hover {
  transform: translateY(-1px);
  border-color: rgba(110, 91, 255, 0.28);
  box-shadow: var(--shadow-glow);
}

.answer-option[disabled] {
  opacity: 0.66;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.feedback {
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02));
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
}

.feedback.success {
  color: #b7ffd8;
}

.feedback.warning {
  color: #ffe0a1;
}

.feedback.danger {
  color: #ffb1c0;
}

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

.spectator-card,
.result-card {
  position: relative;
}

.stage-emblem {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 68px;
  height: 68px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  opacity: 0.88;
}

.stage-emblem::before,
.stage-emblem::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.stage-emblem-spectator::before {
  inset: 17px;
  border: 1px solid rgba(110, 91, 255, 0.4);
}

.stage-emblem-spectator::after {
  inset: 24px;
  background: radial-gradient(circle, rgba(110, 91, 255, 0.72), rgba(60, 141, 255, 0.72));
  box-shadow: 0 0 24px rgba(110, 91, 255, 0.24);
}

.stage-emblem-result::before {
  inset: 16px 16px 20px;
  background: linear-gradient(180deg, rgba(110, 91, 255, 0.82), rgba(60, 141, 255, 0.82));
  clip-path: polygon(50% 0%, 62% 28%, 100% 30%, 72% 50%, 80% 86%, 50% 66%, 20% 86%, 28% 50%, 0% 30%, 38% 28%);
}

.stage-emblem-result::after {
  inset: auto 24px 10px;
  height: 12px;
  background: rgba(255, 255, 255, 0.12);
}

#resultScreen .hero-card {
  gap: 14px;
  background:
    radial-gradient(circle at top center, rgba(110, 91, 255, 0.2), transparent 34%),
    radial-gradient(circle at bottom center, rgba(60, 141, 255, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(29, 39, 64, 0.98), rgba(17, 24, 39, 0.98));
  min-height: 280px;
  align-content: start;
}

#resultOutcomeChip {
  justify-self: start;
}

#resultWinner {
  font-size: 32px;
  line-height: 1.06;
  max-width: 12ch;
}

#resultScreen .action-stack {
  margin-top: 8px;
}

@media (max-width: 560px) {
  .app-shell {
    max-width: 100%;
    padding:
      calc(env(safe-area-inset-top, 0px) + 14px)
      14px
      calc(env(safe-area-inset-bottom, 0px) + 24px);
  }

  body[data-screen="lobby"] .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding: 18px;
  }

  .hero-card,
  .room-card {
    padding: 18px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 20px;
  }

  .hero-number {
    font-size: 52px;
  }

  .waiting-room-title {
    font-size: 28px;
  }

  .countdown-grid {
    gap: 8px;
  }

  .countdown-unit {
    padding: 12px 6px 10px;
    border-radius: 18px;
  }

  .countdown-value {
    font-size: 32px;
  }

  .gameplay-stage-top {
    grid-template-columns: minmax(0, 1fr) 90px;
  }

  .timer-orbit {
    width: 90px;
    height: 90px;
  }

  .timer-value {
    font-size: 22px;
  }

  .stage-emblem {
    width: 62px;
    height: 62px;
  }

  #resultWinner {
    font-size: 26px;
  }

  .join-rules-sheet {
    border-radius: 24px;
  }

  .join-rules-chip-row {
    grid-template-columns: 1fr;
  }

  .summary-highlight-grid {
    grid-template-columns: 1fr;
  }

  .room-summary-shell {
    padding: 20px 14px 32px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 12px;
  }

  .hero-card,
  .room-card,
  body[data-screen="lobby"] .topbar {
    padding: 16px;
    border-radius: 24px;
  }

  .timer-orbit {
    width: 82px;
    height: 82px;
  }

  .timer-core {
    inset: 10px;
  }

  .timer-value {
    font-size: 20px;
  }

  .task-prompt {
    font-size: 24px;
  }

  .countdown-heading {
    align-items: start;
  }

  .countdown-presence {
    max-width: 100%;
  }

  .answer-option {
    min-height: 64px;
    padding-inline: 16px;
    font-size: 16px;
  }

  .hero-number.small {
    font-size: 24px;
  }

  .summary-highlight,
  .summary-rule-row {
    padding: 14px;
  }
}
