/* ==========================================================================
   Kahoolius Design System
   Apple-inspired surfaces + saturated Kahoot answer controls
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius-xs: 12px;
  --radius-sm: 16px;
  --radius-md: 22px;
  --radius-lg: 28px;
  --radius-xl: 36px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --answer-red: #ff375f;
  --answer-blue: #0a84ff;
  --answer-yellow: #ffb800;
  --answer-green: #30d158;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f7;
  --bg-deep: #e9e9ef;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-solid: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.48);
  --surface-hover: rgba(255, 255, 255, 0.94);
  --field: rgba(118, 118, 128, 0.08);
  --field-focus: rgba(255, 255, 255, 0.92);
  --text: #111114;
  --text-secondary: #6e6e73;
  --text-tertiary: #8e8e93;
  --line: rgba(17, 17, 20, 0.075);
  --line-strong: rgba(17, 17, 20, 0.13);
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-contrast: #ffffff;
  --danger: #ff3b30;
  --success: #248a3d;
  --warning: #a05a00;
  --shadow-sm: 0 1px 2px rgba(17, 17, 20, 0.04), 0 4px 14px rgba(17, 17, 20, 0.04);
  --shadow-md: 0 2px 6px rgba(17, 17, 20, 0.035), 0 18px 50px rgba(17, 17, 20, 0.09);
  --shadow-lg: 0 2px 10px rgba(17, 17, 20, 0.04), 0 32px 90px rgba(17, 17, 20, 0.14);
  --glass-blur: blur(28px) saturate(175%);
  --orb-a: rgba(0, 113, 227, 0.14);
  --orb-b: rgba(255, 55, 95, 0.11);
  --orb-c: rgba(48, 209, 88, 0.09);
  --scrollbar: rgba(17, 17, 20, 0.18);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --bg-deep: #050506;
  --surface: rgba(29, 29, 34, 0.68);
  --surface-solid: #17171b;
  --surface-soft: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(44, 44, 50, 0.9);
  --field: rgba(255, 255, 255, 0.065);
  --field-focus: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #77777d;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --primary: #0a84ff;
  --primary-hover: #369cff;
  --primary-contrast: #ffffff;
  --danger: #ff453a;
  --success: #30d158;
  --warning: #ffd60a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 6px 18px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.3), 0 24px 70px rgba(0, 0, 0, 0.46);
  --shadow-lg: 0 2px 10px rgba(0, 0, 0, 0.35), 0 40px 120px rgba(0, 0, 0, 0.62);
  --glass-blur: blur(30px) saturate(150%);
  --orb-a: rgba(10, 132, 255, 0.2);
  --orb-b: rgba(255, 55, 95, 0.13);
  --orb-c: rgba(48, 209, 88, 0.08);
  --scrollbar: rgba(255, 255, 255, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  isolation: isolate;
}

body.page-ambient::before,
body.page-ambient::after {
  content: "";
  position: fixed;
  z-index: -2;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(10px);
}

body.page-ambient::before {
  width: min(66vw, 900px);
  aspect-ratio: 1;
  left: -24vw;
  top: -28vw;
  background: radial-gradient(circle, var(--orb-a), transparent 68%);
}

body.page-ambient::after {
  width: min(58vw, 800px);
  aspect-ratio: 1;
  right: -20vw;
  bottom: -28vw;
  background:
    radial-gradient(circle, var(--orb-b), transparent 66%),
    radial-gradient(circle at 20% 15%, var(--orb-c), transparent 45%);
}

body.page-ambient {
  background-image:
    radial-gradient(ellipse at 50% -20%, rgba(255, 255, 255, 0.42), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  background-attachment: fixed;
}

html[data-theme="dark"] body.page-ambient {
  background-image:
    radial-gradient(ellipse at 50% -25%, rgba(255, 255, 255, 0.055), transparent 52%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}

::selection {
  background: color-mix(in srgb, var(--primary) 24%, transparent);
}

button,
input,
textarea,
select {
  font: inherit;
}

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

button,
a {
  touch-action: manipulation;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

[hidden] {
  display: none !important;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* --------------------------------------------------------------------------
   Typography and layout
   -------------------------------------------------------------------------- */

.font-display {
  font-family: var(--font-sans);
  letter-spacing: -0.045em;
  line-height: 1.04;
  font-weight: 750;
}

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

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

.shell {
  width: min(1200px, calc(100% - 40px));
  margin-inline: auto;
}

.shell-wide {
  width: min(1480px, calc(100% - 40px));
  margin-inline: auto;
}

@media (max-width: 640px) {
  .shell,
  .shell-wide {
    width: calc(100% - 28px);
  }
}

/* --------------------------------------------------------------------------
   Brand
   -------------------------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 760;
  font-size: 1.1rem;
  letter-spacing: -0.035em;
  text-decoration: none;
  line-height: 1;
}

.brand:hover {
  color: var(--text);
}

.logo-mark {
  width: 30px;
  height: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 5px;
  border-radius: 9px;
  background: var(--surface-solid);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.06),
    0 5px 16px rgba(0, 0, 0, 0.1);
  flex: 0 0 auto;
}

html[data-theme="dark"] .logo-mark {
  background: #f5f5f7;
}

.logo-mark span {
  border-radius: 3px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.14);
}

.logo-mark span:nth-child(1) { background: #ff375f; }
.logo-mark span:nth-child(2) { background: #0a84ff; }
.logo-mark span:nth-child(3) { background: #ffb800; }
.logo-mark span:nth-child(4) { background: #30d158; }

.logo-mark.lg {
  width: 48px;
  height: 48px;
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
}

/* --------------------------------------------------------------------------
   Navigation
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 12px;
  z-index: 50;
  width: min(1200px, calc(100% - 40px));
  margin: 12px auto 0;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
  .topbar {
    width: calc(100% - 24px);
    top: 8px;
    margin-top: 8px;
    min-height: 56px;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  min-height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  font-size: 0.94rem;
  line-height: 1;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
  transition:
    transform 0.18s var(--ease-out),
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease;
}

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

.btn:active {
  transform: translateY(0) scale(0.985);
}

.btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  color: var(--primary-contrast);
  background: linear-gradient(180deg, var(--primary-hover), var(--primary));
  border-color: color-mix(in srgb, var(--primary) 55%, #000);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 8px 24px -10px color-mix(in srgb, var(--primary) 72%, transparent);
}

.btn-primary:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    0 12px 30px -10px color-mix(in srgb, var(--primary) 78%, transparent);
}

.btn-dark {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
  box-shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.65);
}

html[data-theme="dark"] .btn-dark {
  background: #f5f5f7;
  color: #111114;
}

.btn-soft {
  background: var(--surface-soft);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-soft:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
}

.btn-glass {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-color: var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.btn-danger-soft {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-color: color-mix(in srgb, var(--danger) 18%, transparent);
}

.btn-danger-soft:hover {
  background: color-mix(in srgb, var(--danger) 13%, transparent);
}

.btn-lg {
  min-height: 54px;
  padding-inline: 24px;
  border-radius: 17px;
  font-size: 1.02rem;
}

.btn-sm {
  min-height: 36px;
  padding-inline: 13px;
  border-radius: 11px;
  font-size: 0.82rem;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 13px;
}

.btn-icon.btn-sm {
  width: 34px;
  height: 34px;
}

.btn-block {
  width: 100%;
}

.btn .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  stroke-width: 2;
}

/* --------------------------------------------------------------------------
   Surfaces
   -------------------------------------------------------------------------- */

.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-md);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.panel-solid {
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.soft-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.hairline {
  border-top: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.badge-live {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  border-color: color-mix(in srgb, var(--success) 16%, transparent);
}

.badge-blue {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-color: color-mix(in srgb, var(--primary) 16%, transparent);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--field);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Form controls
   -------------------------------------------------------------------------- */

.label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  padding: 13px 15px;
  font-size: 0.98rem;
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
}

.textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.48;
}

.select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--line-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  background: var(--field-focus);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
}

.input-lg {
  min-height: 54px;
  font-size: 1.05rem;
  border-radius: 16px;
}

.field-hint {
  margin-top: 7px;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--text-tertiary);
}

.checkbox {
  appearance: none;
  width: 24px;
  height: 24px;
  margin: 0;
  border-radius: 8px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-solid);
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: all 0.16s ease;
  flex: 0 0 auto;
}

.checkbox::before {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px) scale(0);
  transform-origin: center;
  transition: transform 0.16s var(--ease-spring);
}

.checkbox:checked {
  background: var(--answer-green);
  border-color: var(--answer-green);
}

.checkbox:checked::before {
  transform: rotate(-45deg) translateY(-1px) scale(1);
}

.radio {
  appearance: none;
  width: 24px;
  height: 24px;
  margin: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-solid);
  display: grid;
  place-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: all 0.16s ease;
}

.radio::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  transform: scale(0);
  transition: transform 0.16s var(--ease-spring);
}

.radio:checked {
  background: var(--answer-green);
  border-color: var(--answer-green);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--answer-green) 11%, transparent);
}

.radio:checked::before {
  transform: scale(1);
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 13px;
  background: var(--field);
  border: 1px solid var(--line);
}

.segment {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.segment:hover {
  color: var(--text);
}

.segment.active {
  color: var(--text);
  background: var(--surface-solid);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] .segment.active {
  background: rgba(255, 255, 255, 0.13);
}

/* --------------------------------------------------------------------------
   Toast and dialog
   -------------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 550;
  line-height: 1.4;
  pointer-events: auto;
  animation: toast-in 0.4s var(--ease-spring) both;
}

.toast.leaving {
  animation: toast-out 0.25s ease both;
}

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--primary);
}

.toast.success .toast-icon { background: var(--answer-green); }
.toast.error .toast-icon { background: var(--danger); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fade-in 0.2s ease both;
}

.dialog {
  width: min(430px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.35s var(--ease-spring) both;
}

/* --------------------------------------------------------------------------
   Loading
   -------------------------------------------------------------------------- */

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid color-mix(in srgb, currentColor 18%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
}

.loading-block {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--text-secondary);
  gap: 14px;
}

.skeleton {
  background: linear-gradient(
    100deg,
    var(--field) 20%,
    color-mix(in srgb, var(--field) 35%, var(--surface-solid)) 45%,
    var(--field) 70%
  );
  background-size: 240% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 16px;
}

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */

.dashboard-hero {
  padding: clamp(52px, 8vw, 104px) 0 clamp(38px, 5vw, 56px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 40px;
  align-items: end;
}

@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

.hero-title {
  font-size: clamp(3.1rem, 7.2vw, 6.2rem);
  max-width: 12ch;
  margin-bottom: 20px;
}

.hero-title .accent {
  background: linear-gradient(105deg, #ff375f 8%, #ff9500 33%, #30d158 64%, #0a84ff 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-copy {
  max-width: 52ch;
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-card {
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 550;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-title {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  font-weight: 730;
  letter-spacing: -0.035em;
  margin: 0;
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  padding-bottom: 72px;
}

@media (max-width: 1020px) {
  .quiz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .quiz-grid { grid-template-columns: 1fr; gap: 16px; }
}

.quiz-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 25px;
  overflow: hidden;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.35s var(--ease-out),
    box-shadow 0.35s var(--ease-out),
    border-color 0.25s ease;
}

.quiz-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}

.quiz-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.4), transparent 40%),
    linear-gradient(135deg, var(--cover-a, #0a84ff), var(--cover-b, #5e5ce6));
  overflow: hidden;
}

.quiz-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.65s var(--ease-out);
}

.quiz-card:hover .quiz-cover img {
  transform: scale(1.035);
}

.quiz-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 44%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.18));
  pointer-events: none;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.94);
}

.cover-fallback .logo-mark {
  width: 58px;
  height: 58px;
  padding: 10px;
  border-radius: 18px;
  opacity: 0.94;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
}

.cover-meta {
  position: absolute;
  z-index: 2;
  left: 14px;
  top: 14px;
  display: flex;
  gap: 6px;
}

.cover-meta .badge {
  background: rgba(17, 17, 20, 0.36);
  border-color: rgba(255, 255, 255, 0.18);
  color: white;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.quiz-card-body {
  padding: 18px 18px 16px;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.quiz-card-title {
  font-size: 1.11rem;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.quiz-card-desc {
  color: var(--text-secondary);
  font-size: 0.83rem;
  line-height: 1.45;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}

.quiz-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.quiz-meta {
  display: flex;
  gap: 10px;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 550;
}

.quiz-actions {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 4;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s var(--ease-out);
}

.quiz-card:hover .quiz-actions,
.quiz-card:focus-within .quiz-actions {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: none) {
  .quiz-actions { opacity: 1; transform: none; }
}

.quiz-actions .btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.empty-state {
  grid-column: 1 / -1;
  padding: clamp(38px, 7vw, 74px) 24px;
  border-radius: 30px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-soft);
  text-align: center;
}

.empty-orbit {
  width: 110px;
  height: 110px;
  margin: 0 auto 24px;
  position: relative;
  display: grid;
  place-items: center;
}

.empty-orbit::before,
.empty-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  animation: orbit-pulse 3s ease-in-out infinite;
}

.empty-orbit::before { inset: 0; }
.empty-orbit::after { inset: 18px; animation-delay: 0.5s; }

.empty-orbit .logo-mark {
  width: 54px;
  height: 54px;
  padding: 9px;
  border-radius: 17px;
}

/* --------------------------------------------------------------------------
   Editor
   -------------------------------------------------------------------------- */

.editor-shell {
  padding: 34px 0 110px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 334px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1000px) {
  .editor-layout { grid-template-columns: 1fr; }
}

.editor-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.editor-sidebar {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 1000px) {
  .editor-sidebar { position: static; order: -1; }
}

.editor-header {
  padding: 26px 0 20px;
}

.editor-heading {
  font-size: clamp(2rem, 4vw, 3.1rem);
  letter-spacing: -0.05em;
  font-weight: 760;
  line-height: 1.04;
  margin: 8px 0 8px;
}

.editor-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  overflow: hidden;
}

.editor-card-head {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.editor-card-body {
  padding: 22px;
}

.editor-section-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 20px;
}

@media (max-width: 680px) {
  .meta-grid { grid-template-columns: 1fr; }
}

.cover-drop {
  aspect-ratio: 16 / 10;
  border-radius: 17px;
  border: 1px dashed var(--line-strong);
  background: var(--field);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  color: var(--text-tertiary);
  text-align: center;
  transition: all 0.2s ease;
}

.cover-drop:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, var(--field));
}

.cover-drop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-drop-overlay {
  position: absolute;
  inset: auto 8px 8px;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.cover-drop-overlay .btn {
  min-height: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  background: rgba(17, 17, 20, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 0.72rem;
}

.cover-upload-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  color: var(--text-secondary);
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-card {
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  overflow: hidden;
  animation: fade-up 0.4s var(--ease-out) both;
}

.question-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.question-index {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85rem;
  font-weight: 750;
  flex: 0 0 auto;
}

html[data-theme="dark"] .question-index {
  background: #f5f5f7;
  color: #111114;
}

.question-card-body {
  padding: 18px;
}

.question-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 16px;
}

@media (max-width: 700px) {
  .question-top-grid { grid-template-columns: 1fr; }
}

.question-image-drop {
  aspect-ratio: 1.35;
  border-radius: 17px;
  border: 1px dashed var(--line-strong);
  background: var(--field);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  color: var(--text-tertiary);
  transition: all 0.2s ease;
}

.question-image-drop:hover {
  border-color: var(--primary);
}

.question-image-drop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.question-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  align-items: flex-end;
}

.question-controls .control {
  min-width: 130px;
}

.question-controls .control-grow {
  flex: 1;
  min-width: 220px;
}

.answer-editor-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 17px;
}

.answer-editor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 14px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  transition: border-color 0.18s ease, background 0.18s ease;
}

.answer-editor-row:focus-within {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.answer-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: 0 0 auto;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.answer-editor-row .input {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 4px;
  min-width: 0;
}

.answer-editor-row .input:focus {
  box-shadow: none;
  background: transparent;
}

.correct-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  font-weight: 650;
  user-select: none;
  flex: 0 0 auto;
}

.correct-toggle input {
  width: 20px;
  height: 20px;
}

.answer-remove {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: all 0.16s ease;
}

.answer-remove:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.add-answer-btn {
  margin-top: 10px;
  color: var(--primary);
  font-weight: 650;
  font-size: 0.8rem;
  border: 0;
  background: transparent;
  padding: 8px 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.drag-handle {
  color: var(--text-tertiary);
  display: grid;
  place-items: center;
  cursor: grab;
  width: 26px;
  flex: 0 0 auto;
}

.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 12px 11px 18px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  margin-top: 4px;
}

.sidebar-summary {
  display: grid;
  gap: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.summary-row strong {
  color: var(--text);
  font-weight: 650;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  color: var(--text-tertiary);
  font-weight: 550;
}

.save-state .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.save-state.dirty .dot { background: #ff9f0a; }
.save-state.saved .dot { background: var(--answer-green); }

/* --------------------------------------------------------------------------
   Join page
   -------------------------------------------------------------------------- */

.join-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.join-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0;
}

.join-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 20px 70px;
}

.join-card {
  width: min(480px, 100%);
  padding: clamp(26px, 5vw, 42px);
  border-radius: 34px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, white 40%, var(--line));
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  animation: scale-in 0.55s var(--ease-spring) both;
  position: relative;
  overflow: hidden;
}

.join-card::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -100px;
  top: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%);
  pointer-events: none;
}

.join-title {
  font-size: clamp(2.1rem, 6vw, 3rem);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 1.03;
  margin: 18px 0 8px;
}

.join-subtitle {
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.5;
  margin-bottom: 26px;
}

.pin-boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(5px, 1.4vw, 9px);
  margin-bottom: 20px;
}

.pin-box {
  width: 100%;
  aspect-ratio: 0.86;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--text);
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  font-weight: 730;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: all 0.16s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  min-width: 0;
}

.pin-box:focus {
  border-color: var(--primary);
  background: var(--field-focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
}

.pin-box.filled {
  background: var(--surface-solid);
  border-color: var(--line-strong);
}

.join-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 13px;
  border-radius: 12px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 14%, transparent);
  font-size: 0.82rem;
  line-height: 1.4;
  margin-bottom: 16px;
  animation: shake 0.4s ease both;
}

.pin-boxes.shake {
  animation: shake 0.4s ease both;
}

.join-footer {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  margin-top: 20px;
}

/* --------------------------------------------------------------------------
   Game surfaces
   -------------------------------------------------------------------------- */

.game-page {
  min-height: 100svh;
  background:
    radial-gradient(circle at 12% 6%, var(--orb-a), transparent 30%),
    radial-gradient(circle at 88% 92%, var(--orb-b), transparent 34%),
    linear-gradient(160deg, #0a0a0d, #101015 55%, #08080a);
  color: #f5f5f7;
}

html[data-theme="dark"] .game-page {
  background-color: #050506;
}

.game-page .glass-game {
  background: rgba(28, 28, 34, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
}

.game-page .muted { color: rgba(235, 235, 245, 0.58); }
.game-page .text-secondary-game { color: rgba(235, 235, 245, 0.62); }

.host-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 18px clamp(16px, 2.5vw, 36px) 22px;
  gap: 18px;
  max-width: 1680px;
  margin: 0 auto;
}

.host-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 48px;
}

.game-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f5f5f7;
  font-weight: 720;
  letter-spacing: -0.03em;
  font-size: 0.95rem;
}

.game-brand .logo-mark {
  width: 27px;
  height: 27px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
}

.host-header-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.game-chip {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: rgba(245, 245, 247, 0.78);
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.game-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.12);
}

.game-chip.offline .dot {
  background: #ff453a;
  box-shadow: 0 0 0 4px rgba(255, 69, 58, 0.12);
}

.host-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.host-view {
  width: 100%;
  animation: fade-up 0.55s var(--ease-out) both;
}

/* Lobby */

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr);
  gap: 22px;
  align-items: stretch;
}

@media (max-width: 980px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

.lobby-hero-card {
  position: relative;
  overflow: hidden;
  border-radius: 34px;
  padding: clamp(28px, 4vw, 52px);
  background:
    radial-gradient(circle at 88% 6%, rgba(10, 132, 255, 0.32), transparent 36%),
    radial-gradient(circle at 12% 100%, rgba(255, 55, 95, 0.2), transparent 38%),
    rgba(27, 27, 32, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.38);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 34px;
}

.lobby-hero-card::after {
  content: "";
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  right: -130px;
  bottom: -180px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 42px rgba(255, 255, 255, 0.025),
    0 0 0 84px rgba(255, 255, 255, 0.018);
}

.lobby-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.lobby-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(235, 235, 245, 0.55);
}

.lobby-question-title {
  font-size: clamp(1.55rem, 2.5vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
  font-weight: 740;
  margin: 8px 0 0;
  max-width: 20ch;
}

.lobby-pin-label {
  margin-top: 30px;
  font-size: 0.72rem;
  color: rgba(235, 235, 245, 0.58);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 650;
}

.pin-display {
  display: flex;
  gap: clamp(6px, 1.2vw, 12px);
  margin-top: 12px;
  flex-wrap: wrap;
}

.pin-digit {
  min-width: clamp(42px, 5.4vw, 60px);
  height: clamp(58px, 7.6vw, 84px);
  padding: 0 6px;
  border-radius: clamp(12px, 1.6vw, 19px);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.9);
  color: #111114;
  font-size: clamp(1.8rem, 3.7vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
  box-shadow:
    inset 0 1px 0 white,
    inset 0 -5px 0 rgba(0, 0, 0, 0.1),
    0 16px 34px rgba(0, 0, 0, 0.18);
  animation: pin-pop 0.6s var(--ease-spring) both;
}

.pin-digit:nth-child(2) { animation-delay: 0.04s; }
.pin-digit:nth-child(3) { animation-delay: 0.08s; }
.pin-digit:nth-child(4) { animation-delay: 0.12s; }
.pin-digit:nth-child(5) { animation-delay: 0.16s; }
.pin-digit:nth-child(6) { animation-delay: 0.2s; }

.lobby-access {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(20px, 3vw, 44px);
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.lobby-access-main {
  flex: 1 1 320px;
  min-width: 0;
  max-width: 520px;
}

.lobby-link-block {
  min-width: 0;
  margin-top: 26px;
}

.lobby-link-label {
  margin-bottom: 8px;
  font-size: 0.7rem;
  color: rgba(235, 235, 245, 0.52);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 650;
}

.join-url {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 56px;
  padding: 0 17px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(235, 235, 245, 0.82);
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
  font-weight: 620;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.join-url:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.join-url span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  margin-left: auto;
}

.qr-card {
  background: #fff;
  padding: 14px;
  border-radius: 26px;
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
}

.qr-card canvas,
.qr-card img {
  display: block;
  width: clamp(220px, 22vw, 320px) !important;
  height: clamp(220px, 22vw, 320px) !important;
  border-radius: 12px;
}

.qr-caption {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(235, 235, 245, 0.52);
}

.qr-fallback {
  width: clamp(220px, 22vw, 320px);
  height: clamp(220px, 22vw, 320px);
  display: grid;
  place-items: center;
  padding: 18px;
  color: #6e6e73;
  font: 600 12px -apple-system, BlinkMacSystemFont, sans-serif;
  text-align: center;
}

.lobby-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.players-panel {
  flex: 1;
  min-height: 300px;
  border-radius: 30px;
  background: rgba(28, 28, 34, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
}

.players-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 19px 21px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.players-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 27px;
  height: 27px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(48, 209, 88, 0.15);
  color: #6ee7a0;
  font-size: 0.78rem;
  font-weight: 700;
}

.player-badges {
  padding: 18px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 9px;
  overflow-y: auto;
  max-height: 43vh;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  max-width: 100%;
  padding: 3px 12px 3px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f5f5f7;
  font-size: 0.82rem;
  font-weight: 600;
  animation: badge-pop 0.44s var(--ease-spring) both;
}

.player-badge .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.95), rgba(94, 92, 230, 0.95));
  color: white;
  font-size: 0.72rem;
  font-weight: 750;
  flex: 0 0 auto;
}

.player-badge:nth-child(4n+2) .avatar { background: linear-gradient(135deg, #ff375f, #ff9f0a); }
.player-badge:nth-child(4n+3) .avatar { background: linear-gradient(135deg, #30d158, #00c7be); }
.player-badge:nth-child(4n+4) .avatar { background: linear-gradient(135deg, #ffb800, #ff9500); }

.players-empty {
  padding: 34px 24px;
  text-align: center;
  color: rgba(235, 235, 245, 0.45);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: auto;
}

.lobby-cta-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px 15px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-cta-panel .muted {
  font-size: 0.76rem;
  line-height: 1.35;
}

.start-btn {
  min-height: 50px;
  padding-inline: 25px;
  border-radius: 15px;
  background: #f5f5f7;
  color: #111114;
  border: 0;
  font-weight: 700;
  font-size: 0.94rem;
  box-shadow:
    inset 0 1px 0 white,
    inset 0 -3px 0 rgba(0, 0, 0, 0.14),
    0 12px 30px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s var(--ease-out), opacity 0.18s ease;
}

.start-btn:hover {
  transform: translateY(-2px);
}

.start-btn:active {
  transform: translateY(0) scale(0.985);
}

.start-btn:disabled {
  opacity: 0.32;
  transform: none;
}

/* Question */

.host-question-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100svh - 130px);
}

.question-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.question-progress-label {
  color: rgba(235, 235, 245, 0.56);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.progress-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.progress-dot {
  width: 16px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: all 0.3s ease;
}

.progress-dot.done { background: rgba(255, 255, 255, 0.42); }
.progress-dot.current { width: 28px; background: #f5f5f7; }

.timer-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
}

.timer-number {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.9);
  color: #111114;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transition: background 0.25s ease;
}

.timer-number.urgent {
  background: #ff453a;
  color: white;
  animation: timer-pulse 0.9s ease infinite;
}

.timer-track {
  width: clamp(130px, 20vw, 280px);
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #30d158, #6ee7a0);
  transform-origin: left center;
  transition: transform 0.18s linear, background 0.3s ease;
  box-shadow: 0 0 18px rgba(48, 209, 88, 0.32);
}

.timer-fill.urgent {
  background: linear-gradient(90deg, #ff9f0a, #ff453a);
  box-shadow: 0 0 18px rgba(255, 69, 58, 0.3);
}

.host-question-card {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: clamp(22px, 3vw, 42px);
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(26px);
  backdrop-filter: blur(26px);
  position: relative;
  overflow: hidden;
}

.host-question-card.has-image {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

@media (max-width: 900px) {
  .host-question-card.has-image { grid-template-columns: 1fr; }
}

.host-question-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 0%, rgba(10, 132, 255, 0.09), transparent 32%),
    radial-gradient(circle at 0% 100%, rgba(255, 55, 95, 0.055), transparent 35%);
  pointer-events: none;
}

.host-question-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.host-question-image {
  position: relative;
  z-index: 1;
  border-radius: 24px;
  overflow: hidden;
  min-height: 220px;
  max-height: 47vh;
  background: rgba(0, 0, 0, 0.24);
}

.host-question-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.host-question-text {
  font-size: clamp(2.1rem, 4.5vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.052em;
  font-weight: 730;
  margin: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.host-answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin-top: clamp(22px, 4vh, 42px);
}

@media (max-width: 660px) {
  .host-answer-grid { grid-template-columns: 1fr; }
}

.answer-preview {
  min-height: 72px;
  border-radius: 19px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  font-size: clamp(0.92rem, 1.25vw, 1.12rem);
  font-weight: 640;
  line-height: 1.23;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -4px 0 rgba(0, 0, 0, 0.14),
    0 12px 28px -16px rgba(0, 0, 0, 0.6);
  overflow-wrap: anywhere;
}

.answer-preview.yellow {
  color: #281f00;
}

.answer-preview .shape {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  opacity: 0.95;
}

.answer-preview.red { background: linear-gradient(145deg, #ff6076, #ff375f 50%, #e81f47); }
.answer-preview.blue { background: linear-gradient(145deg, #45a2ff, #0a84ff 50%, #0064d6); }
.answer-preview.yellow { background: linear-gradient(145deg, #ffd35c, #ffb800 50%, #e9a300); }
.answer-preview.green { background: linear-gradient(145deg, #68eb86, #30d158 50%, #1eae43); }

.host-question-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.answered-meter {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(235, 235, 245, 0.6);
  font-size: 0.82rem;
  font-weight: 550;
}

.answered-meter .avatars {
  display: flex;
}

.answered-meter .mini-avatar {
  width: 27px;
  height: 27px;
  margin-left: -7px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  border: 2px solid #0e0e12;
  font-size: 0.62rem;
  color: white;
  font-weight: 700;
}

.answered-meter .mini-avatar:first-child { margin-left: 0; }

/* Reveal */

.reveal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 1000px) {
  .reveal-grid { grid-template-columns: 1fr; }
}

.reveal-card {
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  padding: clamp(20px, 2.7vw, 32px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.reveal-question {
  font-size: clamp(1.45rem, 2.4vw, 2.25rem);
  line-height: 1.14;
  letter-spacing: -0.04em;
  font-weight: 720;
  margin: 8px 0 20px;
  overflow-wrap: anywhere;
}

.distribution-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: auto;
}

.distribution-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.distribution-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  color: rgba(235, 235, 245, 0.72);
  font-weight: 550;
}

.distribution-label .correct-label {
  color: #6ee7a0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.distribution-track {
  height: 36px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.055);
  overflow: hidden;
  position: relative;
}

.distribution-fill {
  height: 100%;
  min-width: 3px;
  border-radius: 11px;
  width: var(--bar-width, 0%);
  transition: width 1s var(--ease-out);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.13);
}

.distribution-fill.red { background: linear-gradient(90deg, #ff375f, #ff6076); }
.distribution-fill.blue { background: linear-gradient(90deg, #0a84ff, #45a2ff); }
.distribution-fill.yellow { background: linear-gradient(90deg, #e9a300, #ffca38); }
.distribution-fill.green { background: linear-gradient(90deg, #1eae43, #68eb86); }
.distribution-fill.correct { outline: 2px solid rgba(110, 231, 160, 0.8); outline-offset: -2px; }

.distribution-count {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.76rem;
  font-weight: 750;
  color: white;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.reveal-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.leaderboard-card {
  display: flex;
  flex-direction: column;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  padding: 22px;
  min-width: 0;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 7px 11px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.055);
  animation: slide-in 0.5s var(--ease-out) both;
}

.leaderboard-row:nth-child(2) { animation-delay: 0.06s; }
.leaderboard-row:nth-child(3) { animation-delay: 0.12s; }
.leaderboard-row:nth-child(4) { animation-delay: 0.18s; }
.leaderboard-row:nth-child(5) { animation-delay: 0.24s; }
.leaderboard-row.top-1 { background: linear-gradient(100deg, rgba(255, 184, 0, 0.18), rgba(255, 255, 255, 0.045)); border-color: rgba(255, 184, 0, 0.22); }

.leaderboard-rank {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 750;
  flex: 0 0 auto;
}

.leaderboard-row.top-1 .leaderboard-rank { background: #ffb800; color: #231a00; }
.leaderboard-row.top-2 .leaderboard-rank { background: rgba(235, 235, 245, 0.8); color: #111114; }
.leaderboard-row.top-3 .leaderboard-rank { background: #b97948; color: white; }

.leaderboard-name {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-size: 0.87rem;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  color: rgba(235, 235, 245, 0.88);
}

.reveal-actions {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Podium */

.podium-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: clamp(4px, 2vh, 24px);
}

.podium-title {
  font-size: clamp(2.4rem, 5.5vw, 5rem);
  font-weight: 780;
  letter-spacing: -0.06em;
  text-align: center;
  margin: 0 0 8px;
  background: linear-gradient(105deg, #f5f5f7 10%, #ffd35c 45%, #ff9500 65%, #f5f5f7 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.podium-subtitle {
  color: rgba(235, 235, 245, 0.56);
  font-size: 0.9rem;
  margin-bottom: clamp(28px, 5vh, 60px);
  text-align: center;
}

.podium-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.22fr) minmax(0, 1fr);
  align-items: end;
  gap: clamp(8px, 1.4vw, 18px);
  width: min(920px, 100%);
  padding: 0 10px;
}

.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.podium-person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 14px;
  width: 100%;
  animation: fade-up 0.7s var(--ease-out) both;
}

.podium-col:nth-child(2) .podium-person { animation-delay: 0.16s; }
.podium-col:nth-child(3) .podium-person { animation-delay: 0.28s; }

.podium-avatar {
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 760;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
}

.podium-col.first .podium-avatar {
  width: clamp(74px, 9vw, 108px);
  height: clamp(74px, 9vw, 108px);
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  background: linear-gradient(135deg, #ffd35c, #ff9f0a);
  color: #2a1d00;
}

.podium-col.second .podium-avatar {
  width: clamp(58px, 7vw, 82px);
  height: clamp(58px, 7vw, 82px);
  font-size: clamp(1.2rem, 2.3vw, 1.7rem);
  background: linear-gradient(135deg, #e9e9ef, #9b9ba2);
  color: #202024;
}

.podium-col.third .podium-avatar {
  width: clamp(54px, 6.5vw, 76px);
  height: clamp(54px, 6.5vw, 76px);
  font-size: clamp(1.1rem, 2.1vw, 1.5rem);
  background: linear-gradient(135deg, #d59a6c, #9b5d36);
}

.podium-name {
  font-size: clamp(0.82rem, 1.5vw, 1.05rem);
  font-weight: 680;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  color: rgba(235, 235, 245, 0.53);
  font-size: clamp(0.65rem, 1.1vw, 0.78rem);
  font-variant-numeric: tabular-nums;
}

.podium-block {
  width: 100%;
  border-radius: 20px 20px 12px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15px;
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  font-weight: 800;
  animation: podium-rise 0.9s var(--ease-out) both;
  position: relative;
  overflow: hidden;
}

.podium-block::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 48%);
  pointer-events: none;
}

.podium-col.first .podium-block {
  height: clamp(150px, 24vh, 240px);
  background: linear-gradient(180deg, rgba(255, 184, 0, 0.34), rgba(255, 184, 0, 0.1));
  border: 1px solid rgba(255, 184, 0, 0.3);
  color: #ffd35c;
  animation-delay: 0.08s;
}

.podium-col.second .podium-block {
  height: clamp(105px, 17vh, 175px);
  background: linear-gradient(180deg, rgba(235, 235, 245, 0.18), rgba(235, 235, 245, 0.055));
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(245, 245, 247, 0.8);
  animation-delay: 0.16s;
}

.podium-col.third .podium-block {
  height: clamp(80px, 13vh, 130px);
  background: linear-gradient(180deg, rgba(190, 126, 78, 0.25), rgba(190, 126, 78, 0.07));
  border: 1px solid rgba(190, 126, 78, 0.22);
  color: #d9a174;
  animation-delay: 0.24s;
}

.podium-footer {
  margin-top: 32px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -8vh;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall var(--duration, 4s) linear var(--delay, 0s) infinite;
}

/* --------------------------------------------------------------------------
   Player
   -------------------------------------------------------------------------- */

.player-shell {
  min-height: 100svh;
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 4px 2px;
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: white;
  font-size: 0.8rem;
  font-weight: 760;
  flex: 0 0 auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.player-name {
  font-size: 0.86rem;
  font-weight: 650;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-hud {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hud-pill {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  font-weight: 650;
  color: rgba(235, 235, 245, 0.78);
  font-variant-numeric: tabular-nums;
}

.player-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.player-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fade-up 0.4s var(--ease-out) both;
}

.player-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
}

.player-lobby-pulse {
  width: clamp(110px, 28vw, 160px);
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: 30px;
  background: radial-gradient(circle, rgba(10, 132, 255, 0.3), transparent 68%);
}

.player-lobby-pulse::before,
.player-lobby-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(10, 132, 255, 0.32);
  animation: lobby-ring 2.8s ease-out infinite;
}

.player-lobby-pulse::after {
  animation-delay: 1.4s;
}

.player-lobby-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  font-size: 1.85rem;
  font-weight: 760;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.player-waiting-title {
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  font-weight: 750;
  letter-spacing: -0.045em;
  margin: 0 0 8px;
}

.player-waiting-copy {
  color: rgba(235, 235, 245, 0.56);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 34ch;
}

.waiting-dots {
  display: inline-flex;
  gap: 5px;
  margin-top: 18px;
}

.waiting-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(235, 235, 245, 0.48);
  animation: dot-bounce 1.3s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) { animation-delay: 0.14s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.28s; }

.question-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 3px;
}

.player-question-head {
  padding: 14px 3px 12px;
}

.player-question-text {
  font-size: clamp(1.4rem, 4.8vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.043em;
  font-weight: 710;
  text-wrap: balance;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.player-question-image {
  margin: 12px 0 2px;
  border-radius: 18px;
  overflow: hidden;
  max-height: 22vh;
  background: rgba(0, 0, 0, 0.22);
}

.player-question-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 22vh;
  object-fit: contain;
}

.player-timer {
  margin-top: 12px;
}

.player-timer-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.player-timer-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #30d158, #6ee7a0);
  transform-origin: left center;
  transition: transform 0.15s linear, background 0.25s ease;
}

.player-timer-fill.urgent {
  background: linear-gradient(90deg, #ff9f0a, #ff453a);
}

.player-answer-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 12px;
}

.player-answer-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(126px, 1fr);
  gap: 10px;
  min-height: 290px;
}

.player-answer-grid.two-answers {
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(120px, 1fr);
  min-height: 0;
}

.answer-tile {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: clamp(20px, 3vw, 28px);
  min-height: 124px;
  padding: clamp(16px, 3vw, 24px);
  display: flex;
  align-items: center;
  gap: clamp(11px, 2vw, 17px);
  text-align: left;
  color: #fff;
  font-family: var(--font-sans);
  font-size: clamp(1.06rem, 3.1vw, 1.48rem);
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.018em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -6px 0 rgba(0, 0, 0, 0.16),
    0 16px 34px -18px rgba(0, 0, 0, 0.7);
  transition:
    transform 0.17s var(--ease-out),
    filter 0.17s ease,
    box-shadow 0.17s ease,
    opacity 0.25s ease;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.answer-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.2), transparent 38%);
  pointer-events: none;
}

.answer-tile:hover {
  transform: translateY(-2px);
  filter: brightness(1.04) saturate(1.03);
}

.answer-tile:active {
  transform: translateY(3px) scale(0.985);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.16),
    0 6px 12px -8px rgba(0, 0, 0, 0.6);
}

.answer-tile:focus-visible {
  outline: 3px solid white;
  outline-offset: 3px;
}

.answer-tile.red { background: radial-gradient(circle at 15% 0%, #ff7c8e, transparent 38%), linear-gradient(145deg, #ff4f6d, #ff375f 54%, #d91d45); }
.answer-tile.blue { background: radial-gradient(circle at 15% 0%, #6bb6ff, transparent 38%), linear-gradient(145deg, #3198ff, #0a84ff 54%, #0064d8); }
.answer-tile.yellow { color: #281e00; background: radial-gradient(circle at 15% 0%, #ffe289, transparent 38%), linear-gradient(145deg, #ffd04f, #ffb800 54%, #dd9900); }
.answer-tile.green { background: radial-gradient(circle at 15% 0%, #8bf2a2, transparent 38%), linear-gradient(145deg, #55e276, #30d158 54%, #1cae42); }

.answer-tile .answer-shape {
  width: clamp(34px, 7vw, 48px);
  height: clamp(34px, 7vw, 48px);
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.15));
  opacity: 0.94;
}

.answer-tile .answer-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  position: relative;
  z-index: 1;
}

.answer-tile .selection-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.2s var(--ease-spring);
}

.answer-tile.yellow .selection-mark {
  border-color: rgba(40, 30, 0, 0.35);
}

.answer-tile.is-selected .selection-mark {
  opacity: 1;
  transform: scale(1);
  background: currentColor;
}

.answer-tile.is-selected .selection-mark svg {
  color: #fff;
}

.answer-tile.yellow.is-selected .selection-mark svg {
  color: #281e00;
}

.answer-tile.is-selected {
  outline: 4px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
  transform: scale(0.985);
}

.answer-tile.is-dimmed {
  opacity: 0.34;
  filter: saturate(0.45);
}

.answer-tile.is-correct {
  outline: 4px solid #7bf09b;
  outline-offset: 2px;
  box-shadow:
    0 0 0 8px rgba(48, 209, 88, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -6px 0 rgba(0, 0, 0, 0.16),
    0 18px 40px -18px rgba(0, 0, 0, 0.7);
  opacity: 1;
  filter: none;
}

.answer-tile.is-wrong {
  opacity: 0.42;
  filter: saturate(0.55);
}

.answer-tile.is-locked {
  cursor: default;
}

.multi-actions {
  padding-top: 12px;
}

.multi-hint {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(235, 235, 245, 0.48);
  margin-top: 8px;
}

.sent-waiting {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 22px;
  gap: 4px;
}

.sent-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(48, 209, 88, 0.15);
  color: #6ee7a0;
  margin-bottom: 18px;
  animation: scale-in 0.4s var(--ease-spring) both;
  box-shadow: 0 0 0 12px rgba(48, 209, 88, 0.045);
}

.sent-title {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 730;
  letter-spacing: -0.04em;
  margin: 0 0 6px;
}

.sent-copy {
  color: rgba(235, 235, 245, 0.54);
  font-size: 0.88rem;
}

.sent-answer {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  color: rgba(235, 235, 245, 0.8);
}

.sent-answer .color-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: 0 0 auto;
}

/* Player feedback */

.feedback-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vh, 34px) 4px;
}

.feedback-card {
  width: min(560px, 100%);
  border-radius: 32px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  animation: scale-in 0.55s var(--ease-spring) both;
}

.feedback-hero {
  position: relative;
  padding: clamp(28px, 6vw, 44px) 28px clamp(24px, 4vw, 32px);
  text-align: center;
  overflow: hidden;
}

.feedback-hero::before {
  content: "";
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  top: -135px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--feedback-glow, rgba(48, 209, 88, 0.4)), transparent 70%);
}

.feedback-hero.correct {
  --feedback-glow: rgba(48, 209, 88, 0.45);
  background: linear-gradient(180deg, rgba(48, 209, 88, 0.16), transparent);
}

.feedback-hero.incorrect {
  --feedback-glow: rgba(255, 69, 58, 0.38);
  background: linear-gradient(180deg, rgba(255, 69, 58, 0.14), transparent);
}

.feedback-hero.timeout {
  --feedback-glow: rgba(255, 159, 10, 0.35);
  background: linear-gradient(180deg, rgba(255, 159, 10, 0.13), transparent);
}

.feedback-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  position: relative;
  z-index: 1;
  color: white;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.feedback-hero.correct .feedback-icon { background: linear-gradient(135deg, #68eb86, #1eae43); }
.feedback-hero.incorrect .feedback-icon { background: linear-gradient(135deg, #ff6961, #d70015); }
.feedback-hero.timeout .feedback-icon { background: linear-gradient(135deg, #ffd60a, #ff9f0a); color: #2a1d00; }

.feedback-title {
  font-size: clamp(2rem, 7vw, 3.2rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1;
  margin: 0 0 8px;
  position: relative;
  z-index: 1;
}

.feedback-subtitle {
  font-size: 0.88rem;
  color: rgba(235, 235, 245, 0.58);
  margin: 0;
  position: relative;
  z-index: 1;
}

.feedback-body {
  padding: 22px 22px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.points-earned {
  text-align: center;
  margin-bottom: 20px;
}

.points-value {
  font-size: clamp(2.1rem, 7vw, 3rem);
  font-weight: 780;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.points-value.positive { color: #6ee7a0; }
.points-value.zero { color: rgba(235, 235, 245, 0.55); }

.points-label {
  font-size: 0.72rem;
  color: rgba(235, 235, 245, 0.44);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 650;
}

.feedback-rank-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 15px 17px;
  display: flex;
  align-items: center;
  gap: 13px;
}

.rank-number {
  min-width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.09);
  font-size: 1.22rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.rank-meta {
  flex: 1;
  min-width: 0;
}

.rank-copy {
  font-size: 0.95rem;
  font-weight: 650;
  margin-bottom: 2px;
}

.rank-copy strong {
  font-weight: 760;
}

.rank-detail {
  font-size: 0.75rem;
  color: rgba(235, 235, 245, 0.47);
  display: flex;
  align-items: center;
  gap: 5px;
}

.rank-trend {
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 8px;
}

.rank-trend.up {
  color: #6ee7a0;
  background: rgba(48, 209, 88, 0.1);
}

.rank-trend.down {
  color: #ff9f9a;
  background: rgba(255, 69, 58, 0.1);
}

.rank-trend.same {
  color: rgba(235, 235, 245, 0.5);
  background: rgba(255, 255, 255, 0.06);
}

.correct-solutions {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.correct-solutions-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: rgba(235, 235, 245, 0.42);
  font-weight: 650;
  margin-bottom: 8px;
}

.correct-solution-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.solution-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(48, 209, 88, 0.1);
  border: 1px solid rgba(48, 209, 88, 0.18);
  color: #a8f4bd;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
}

.solution-chip .color-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: 0 0 auto;
}

.feedback-footer {
  margin-top: 20px;
  text-align: center;
}

/* Player podium */

.player-final {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 12px;
  position: relative;
}

.final-kicker {
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(235, 235, 245, 0.42);
  margin-bottom: 18px;
}

.final-medal {
  width: clamp(92px, 24vw, 126px);
  height: clamp(92px, 24vw, 126px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(2rem, 8vw, 3.1rem);
  font-weight: 800;
  margin-bottom: 22px;
  position: relative;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.final-medal.gold {
  background: linear-gradient(135deg, #ffe28a, #ffb800 60%, #d68a00);
  color: #2a1d00;
  border-color: rgba(255, 241, 185, 0.65);
  box-shadow:
    0 0 0 12px rgba(255, 184, 0, 0.07),
    0 28px 70px rgba(0, 0, 0, 0.38);
}

.final-medal.silver {
  background: linear-gradient(135deg, #ffffff, #b9b9c1 55%, #777780);
  color: #202024;
  border-color: rgba(255, 255, 255, 0.55);
}

.final-medal.bronze {
  background: linear-gradient(135deg, #e8b083, #b96f3e 60%, #8b4d27);
  color: white;
  border-color: rgba(255, 219, 190, 0.35);
}

.final-title {
  font-size: clamp(2rem, 7.5vw, 3.3rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  margin: 0 0 8px;
}

.final-subtitle {
  color: rgba(235, 235, 245, 0.54);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.final-score-card {
  display: flex;
  gap: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  overflow: hidden;
  margin-bottom: 23px;
}

.final-score-cell {
  min-width: 118px;
  padding: 16px 22px;
}

.final-score-cell + .final-score-cell {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.final-score-value {
  font-size: 1.55rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.final-score-label {
  font-size: 0.65rem;
  color: rgba(235, 235, 245, 0.42);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 650;
  margin-top: 3px;
}

.final-top-list {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 auto 28px;
}

.final-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  font-size: 0.8rem;
}

.final-top-row.you {
  background: rgba(10, 132, 255, 0.13);
  border: 1px solid rgba(10, 132, 255, 0.2);
}

.final-top-rank {
  width: 22px;
  color: rgba(235, 235, 245, 0.45);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.final-top-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.final-top-score {
  color: rgba(235, 235, 245, 0.6);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
}

/* Connection overlay */

.connection-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 5, 6, 0.72);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  animation: fade-in 0.2s ease both;
}

.connection-card {
  width: min(390px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: #17171b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.connection-card h2 {
  font-size: 1.5rem;
  letter-spacing: -0.035em;
  margin: 18px 0 8px;
}

.connection-card p {
  color: rgba(235, 235, 245, 0.52);
  font-size: 0.86rem;
  line-height: 1.5;
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Utilities & animations
   -------------------------------------------------------------------------- */

.text-balance { text-wrap: balance; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-select { user-select: none; -webkit-user-select: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}
@keyframes shimmer {
  to { background-position: -140% 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes pin-pop {
  from { opacity: 0; transform: translateY(18px) scale(0.8) rotate(-4deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes badge-pop {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes orbit-pulse {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.08); opacity: 0.25; }
}
@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes podium-rise {
  from { opacity: 0; transform: translateY(52px) scaleY(0.8); transform-origin: bottom; }
  to { opacity: 1; transform: translateY(0) scaleY(1); transform-origin: bottom; }
}
@keyframes lobby-ring {
  0% { transform: scale(0.62); opacity: 0; }
  38% { opacity: 0.85; }
  100% { transform: scale(1.28); opacity: 0; }
}
@keyframes dot-bounce {
  0%, 75%, 100% { transform: translateY(0); opacity: 0.45; }
  35% { transform: translateY(-5px); opacity: 1; }
}
@keyframes confetti-fall {
  0% { opacity: 0; transform: translate3d(0, -10vh, 0) rotateZ(0deg); }
  8% { opacity: 1; }
  100% { opacity: 0.9; transform: translate3d(var(--drift, 30px), 112vh, 0) rotateZ(var(--spin, 540deg)); }
}

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

@media (max-width: 700px) {
  .host-shell { padding: 12px 12px 16px; gap: 12px; }
  .host-topbar { min-height: 40px; }
  .game-brand span.brand-text { display: none; }
  .host-question-view { min-height: calc(100svh - 104px); gap: 12px; }
  .host-question-card { border-radius: 26px; padding: 20px; }
  .host-question-text { font-size: clamp(1.85rem, 8vw, 3rem); }
  .answer-preview { min-height: 60px; border-radius: 16px; }
  .timer-track { width: 100px; }
  .timer-number { width: 44px; height: 44px; font-size: 1rem; }
  .question-hud { gap: 10px; }
  .progress-dots { display: none; }
  .host-question-footer .btn { min-height: 42px; }
  .player-answer-grid { grid-auto-rows: minmax(112px, 1fr); min-height: 248px; }
  .answer-tile { min-height: 108px; border-radius: 21px; }
  .lobby-hero-card { border-radius: 28px; }
  .reveal-card, .leaderboard-card { border-radius: 24px; }
  .podium-stage { gap: 5px; }
  .podium-block { border-radius: 14px 14px 8px 8px; }
}

@media (max-width: 400px) {
  .pin-boxes { gap: 4px; }
  .pin-box { border-radius: 11px; }
  .player-shell { padding-inline: 10px; }
  .answer-tile { padding: 14px; gap: 10px; }
  .answer-tile .answer-shape { width: 30px; height: 30px; }
}

/* Editor interaction refinements */
.question-card-head .btn-icon:hover {
  background: var(--field);
}

.question-card.is-invalid {
  border-color: color-mix(in srgb, var(--danger) 48%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 10%, transparent), var(--shadow-md);
}

.save-state {
  transition: color 0.2s ease;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s var(--ease-out), opacity 0.18s ease;
}

.game-chip {
  text-decoration: none;
}

.game-page a:hover {
  color: #fff;
}

/* Layout and rendering refinements */
.pin-display {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
  max-width: 500px;
  gap: clamp(4px, 0.8vw, 9px);
}

.pin-digit {
  min-width: 0;
  width: 100%;
}

.quiz-cover img {
  position: relative;
  z-index: 1;
}

.cover-fallback {
  z-index: 0;
}

.btn-ghost:hover {
  background: var(--field);
}

.hud-pill.urgent {
  color: #ffb340;
  border-color: rgba(255, 159, 10, 0.2);
  background: rgba(255, 159, 10, 0.1);
}

@media (max-width: 700px) {
  .pin-digit {
    height: clamp(54px, 14vw, 68px);
    font-size: clamp(1.6rem, 7.5vw, 2.3rem);
    border-radius: 13px;
  }

  .lobby-hero-card {
    padding: 24px 20px;
  }
}

/* The editor already has persistent actions in the top bar; keep the bottom bar in flow. */
.save-bar {
  position: relative;
  bottom: auto;
}

.host-question-image img {
  object-fit: cover;
}

.distribution-fill {
  min-width: 0;
}

.rank-trend {
  min-width: 34px;
  text-align: center;
  font-size: 0.82rem;
  padding-inline: 8px;
}

.rank-copy {
  font-size: 0.9rem;
}

.rank-detail {
  line-height: 1.4;
}

@media (max-width: 370px) {
  .rank-number {
    min-width: 44px;
    height: 44px;
    font-size: 1.02rem;
  }
  .feedback-rank-card {
    gap: 9px;
    padding: 13px;
  }
}

/* Long answer labels: give the text room on small screens. */
.answer-tile {
  padding: clamp(14px, 2.5vw, 24px);
  font-size: clamp(0.95rem, 3.4vw, 1.48rem);
}

.answer-tile .answer-shape {
  width: clamp(26px, 7vw, 48px);
  height: clamp(26px, 7vw, 48px);
}

.answer-tile .selection-mark {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.host-question-image img {
  object-fit: contain;
}

.start-btn {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .lobby-access {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .lobby-access-main {
    max-width: none;
  }

  .lobby-link-block {
    margin-top: 20px;
  }

  .join-url {
    min-height: 52px;
    padding-inline: 14px;
    font-size: 0.88rem;
  }

  .qr-panel {
    margin: 0 auto;
  }

  .qr-card {
    padding: 11px;
    border-radius: 20px;
  }

  .qr-card canvas,
  .qr-card img,
  .qr-fallback {
    width: min(62vw, 240px) !important;
    height: min(62vw, 240px) !important;
  }

  .qr-fallback {
    font-size: 11px;
  }
}

@media (max-width: 1000px) {
  .editor-sidebar {
    order: 0;
  }
}

.answer-tile.is-selected .selection-mark {
  background: rgba(0, 0, 0, 0.26);
  border-color: rgba(255, 255, 255, 0.92);
}

.answer-tile.is-selected .selection-mark svg {
  color: #fff;
}

.answer-tile.yellow.is-selected .selection-mark {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(40, 30, 0, 0.48);
}

.answer-tile.yellow.is-selected .selection-mark svg {
  color: #281e00;
}

/* --------------------------------------------------------------------------
   Collaborative editing
   -------------------------------------------------------------------------- */

.badge .dot,
.editor-live-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent);
}

.presence-stack {
  display: flex;
  align-items: center;
  min-height: 28px;
}

.presence-stack:empty {
  display: none;
}

.presence-avatar {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-left: -6px;
  border: 2px solid var(--surface-solid);
  color: white;
  font-size: 0.64rem;
  font-weight: 750;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  position: relative;
  transition: transform 0.18s var(--ease-spring);
}

.presence-avatar:first-child {
  margin-left: 0;
}

.presence-avatar:hover {
  transform: translateY(-2px) scale(1.06);
  z-index: 2;
}

.presence-avatar.is-you {
  box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 4px var(--primary);
}

.presence-more {
  width: 29px;
  height: 29px;
  margin-left: -6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface-solid);
  background: var(--field);
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-weight: 750;
}

.collab-bar .presence-stack {
  margin-left: 4px;
}

.collab-bar {
  gap: 12px;
}

.collab-info-card .btn {
  margin-top: 2px;
}

.share-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 6px;
}

.share-link-box .input {
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
}

.share-note {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-tertiary);
  margin: 0;
}

.name-gate-card {
  width: min(440px, 100%);
  padding: 30px;
  border-radius: 30px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.4s var(--ease-spring) both;
}

.name-gate-card h2 {
  font-size: 1.65rem;
  font-weight: 750;
  letter-spacing: -0.045em;
  margin: 16px 0 7px;
}

.name-gate-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 22px;
}

@media (max-width: 640px) {
  #sync-state {
    display: none;
  }

  .collab-bar {
    flex-wrap: wrap;
  }

  .collab-bar .presence-stack {
    margin-left: 0;
  }

  .topbar #presence-top .presence-avatar:nth-child(n+3) {
    display: none;
  }

  .topbar #presence-top .presence-more {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Estimation questions
   -------------------------------------------------------------------------- */

.segmented {
  flex-wrap: wrap;
}

.answer-static-label {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
}

.estimate-config {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.estimate-config-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.estimate-scale-preview {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.estimate-scale-preview strong {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.035em;
}

.estimate-scale-preview > span {
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.estimate-fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 760px) {
  .estimate-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .estimate-unit-field {
    grid-column: 1 / -1;
  }
}

.estimate-fields .label {
  font-size: 0.7rem;
  margin-bottom: 5px;
}

.estimate-fields .input {
  padding: 10px 11px;
  font-size: 0.86rem;
  border-radius: 11px;
}

.estimate-config .field-hint {
  margin-top: 13px;
  margin-bottom: 0;
}

.player-estimate-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
}

.estimate-readout {
  text-align: center;
  padding: 10px 0 4px;
}

.estimate-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(235, 235, 245, 0.42);
  margin-bottom: 8px;
}

.estimate-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-size: clamp(3.3rem, 17vw, 6rem);
  font-weight: 780;
  letter-spacing: -0.07em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 8px 36px rgba(10, 132, 255, 0.16);
}

.estimate-unit {
  font-size: clamp(1.05rem, 4.5vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: rgba(235, 235, 245, 0.5);
}

.estimate-value-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  cursor: text;
  border-radius: 18px;
}

.estimate-value-button:hover {
  color: #fff;
}

.estimate-value-button:focus-visible {
  outline: 3px solid rgba(10, 132, 255, 0.8);
  outline-offset: 8px;
}

.estimate-edit-hint {
  margin-top: 7px;
  color: rgba(235, 235, 245, 0.38);
  font-size: 0.7rem;
}

.estimate-exact-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  margin: 0 auto;
}

.estimate-exact-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
}

.estimate-exact-input {
  width: min(240px, 62vw);
  padding: 4px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f7;
  font-family: inherit;
  font-size: clamp(2.3rem, 12vw, 3.6rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1.1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.estimate-exact-input::-webkit-outer-spin-button,
.estimate-exact-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.estimate-exact-input:focus {
  border-color: #0a84ff;
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.18);
}

.estimate-exact-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.estimate-slider-card {
  padding: 26px 20px 17px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.estimate-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  outline: none;
  background: linear-gradient(90deg, #0a84ff 0%, #30d158 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.estimate-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  margin-top: -12px;
  border-radius: 50%;
  border: 4px solid #f5f5f7;
  background: #0a84ff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38), 0 0 0 8px rgba(10, 132, 255, 0.1);
  cursor: grab;
  transition: transform 0.15s var(--ease-spring);
}

.estimate-slider::-webkit-slider-thumb:active {
  transform: scale(1.08);
  cursor: grabbing;
}

.estimate-slider::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 4px solid #f5f5f7;
  background: #0a84ff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38), 0 0 0 8px rgba(10, 132, 255, 0.1);
  cursor: grab;
}

.estimate-bounds {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 15px;
  font-size: 0.72rem;
  color: rgba(235, 235, 245, 0.45);
  font-variant-numeric: tabular-nums;
}

.feedback-hero.estimate {
  --feedback-glow: rgba(255, 184, 0, 0.36);
  background: linear-gradient(180deg, rgba(255, 184, 0, 0.13), transparent);
}

.feedback-hero.estimate .feedback-icon {
  background: linear-gradient(135deg, #ffd35c, #ff9f0a);
  color: #2a1d00;
}

.estimate-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  margin-top: 16px;
}

.estimate-result-cell {
  padding: 15px 16px;
  min-width: 0;
}

.estimate-result-cell + .estimate-result-cell {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.estimate-result-cell > span {
  display: block;
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(235, 235, 245, 0.42);
  margin-bottom: 5px;
}

.estimate-result-cell strong {
  display: block;
  font-size: 1.02rem;
  font-weight: 720;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.estimate-result-cell.solution strong {
  color: #8bf0a4;
}

.estimate-deviation {
  text-align: center;
  font-size: 0.74rem;
  color: rgba(235, 235, 245, 0.48);
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.sent-answer.sent-estimate {
  color: #a9cfff;
}

.host-estimate-preview {
  margin-top: clamp(22px, 4vh, 42px);
  padding: clamp(18px, 2.5vw, 28px);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.12), rgba(48, 209, 88, 0.06));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.host-estimate-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  font-weight: 650;
  color: rgba(235, 235, 245, 0.72);
}

.host-estimate-track {
  position: relative;
  height: 14px;
  margin: 24px 0 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0a84ff, #30d158);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.host-estimate-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f5f5f7;
  color: #0a84ff;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35), 0 0 0 8px rgba(10, 132, 255, 0.08);
}

.host-estimate-range {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: rgba(235, 235, 245, 0.48);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.host-estimate-caption {
  color: rgba(235, 235, 245, 0.38);
  font-size: 0.72rem;
}

.host-estimate-solution {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  margin: 0 0 16px;
  border-radius: 14px;
  background: rgba(48, 209, 88, 0.08);
  border: 1px solid rgba(48, 209, 88, 0.18);
}

.host-estimate-solution strong {
  color: #8bf0a4;
  font-size: clamp(1.2rem, 2.4vw, 1.7rem);
  font-weight: 760;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.estimate-histogram {
  gap: 8px;
}

.estimate-histogram .distribution-label {
  font-size: 0.72rem;
}

.estimate-histogram .distribution-track {
  height: 22px;
}

.estimate-histogram .distribution-count {
  font-size: 0.68rem;
}

@media (max-width: 700px) {
  .estimate-result-cell {
    padding: 13px;
  }
  .estimate-result-cell strong {
    font-size: 0.92rem;
  }
}

/* Keep large estimated values readable on narrow screens. */
.estimate-big {
  flex-wrap: wrap;
  font-size: clamp(2.5rem, 14vw, 5.5rem);
}

.estimate-unit {
  flex-basis: 100%;
  text-align: center;
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Library tools and active rounds
   -------------------------------------------------------------------------- */

.library-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 24px;
}

.library-search {
  position: relative;
  flex: 1 1 280px;
  max-width: 520px;
  min-width: 0;
}

.library-search-input {
  min-height: 50px;
  padding-left: 44px;
  padding-right: 46px;
  border-radius: 15px;
  background: var(--surface-solid);
}

.library-search-input::-webkit-search-cancel-button,
.library-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.library-search-icon {
  position: absolute;
  z-index: 1;
  left: 16px;
  top: 50%;
  width: 17px;
  height: 17px;
  color: var(--text-tertiary);
  transform: translateY(-50%);
  pointer-events: none;
}

.library-search-clear {
  position: absolute;
  z-index: 1;
  right: 9px;
  top: 50%;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--field);
  color: var(--text-secondary);
  transform: translateY(-50%);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.library-search-clear[hidden] {
  display: none;
}

.library-search-clear:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.library-search-clear svg {
  width: 14px;
  height: 14px;
}

.library-sort {
  flex: 0 1 270px;
  min-width: 220px;
}

.library-sort .select {
  min-height: 50px;
  border-radius: 15px;
  background-color: var(--surface-solid);
  font-size: 0.86rem;
  font-weight: 600;
}

.library-count {
  margin-left: auto;
  min-height: 20px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 550;
  white-space: nowrap;
}

.active-rounds {
  margin: 0 0 26px;
  padding: 20px;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.active-rounds-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.active-rounds-title {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-weight: 730;
  letter-spacing: -0.03em;
}

.active-rounds-copy {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.4;
}

.active-rounds-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.active-round {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
}

.active-round-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  color: var(--success);
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}

.round-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 14%, transparent);
}

.active-round-main {
  flex: 1 1 220px;
  min-width: 0;
}

.active-round-title {
  font-size: 0.96rem;
  font-weight: 680;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.active-round-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.active-round-meta strong {
  color: var(--text-secondary);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.active-round-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-left: auto;
}

.cover-meta .badge-live {
  color: #30d158;
  background: rgba(17, 17, 20, 0.46);
  border-color: rgba(48, 209, 88, 0.32);
}

.cover-meta .badge-live .round-dot {
  width: 5px;
  height: 5px;
  background: currentColor;
  box-shadow: none;
}

@media (max-width: 760px) {
  .library-tools {
    align-items: stretch;
  }

  .library-search {
    flex-basis: 100%;
    max-width: none;
  }

  .library-sort {
    flex: 1 1 100%;
    min-width: 0;
  }

  .library-sort .select {
    width: 100%;
  }

  .library-count {
    width: 100%;
    margin-left: 0;
  }

  .active-rounds {
    padding: 16px;
    border-radius: 22px;
  }

  .active-rounds-head {
    flex-direction: column;
  }

  #end-all-rounds {
    width: 100%;
    justify-content: center;
  }

  .active-round {
    align-items: flex-start;
    gap: 10px;
  }

  .active-round-state {
    width: 100%;
  }

  .active-round-actions {
    width: 100%;
    margin-left: 0;
  }

  .active-round-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Long questions, centered images and multiple-answer markers
   -------------------------------------------------------------------------- */

.host-question-image,
.player-question-image {
  display: flex;
  align-items: center;
  justify-content: center;
}

.host-question-image img {
  object-position: center center;
  margin: auto;
}

.player-question-image {
  height: min(20vh, 190px);
  max-height: none;
  flex: 0 1 auto;
}

.player-question-image img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center center;
  margin: auto;
}

.question-hud-left {
  flex-wrap: wrap;
  row-gap: 6px;
}

.question-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 184, 0, 0.13);
  border: 1px solid rgba(255, 184, 0, 0.26);
  color: #ffd35c;
  font-size: 0.68rem;
  font-weight: 720;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.player-mode-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 7px 0 4px;
  padding: 7px 10px;
  border-radius: 11px;
  background: rgba(255, 184, 0, 0.12);
  border: 1px solid rgba(255, 184, 0, 0.24);
  color: #ffd35c;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
}

.player-mode-banner svg {
  flex: 0 0 auto;
}

.answer-tile.is-multi .selection-mark {
  border-radius: 7px;
}

body.host-question-mode,
body.player-question-mode {
  height: 100svh;
  overflow: hidden;
}

body.host-question-mode .host-shell {
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}

body.host-question-mode .host-main {
  min-height: 0;
  overflow: hidden;
}

body.host-question-mode .host-question-view {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.host-question-mode .host-question-card {
  grid-template-rows: minmax(0, 1fr);
}

body.host-question-mode .host-question-content {
  min-height: 0;
  overflow: hidden;
}

body.host-question-mode .host-question-text,
body.host-question-mode .host-answer-grid {
  flex: 0 0 auto;
}

body.host-question-mode .host-question-image {
  min-height: 0;
  max-height: 100%;
}

.host-question-content.is-cramped .host-answer-grid {
  gap: 7px;
  margin-top: 12px;
}

.host-question-content.is-cramped .answer-preview {
  min-height: 48px;
  padding: 8px 11px;
  font-size: clamp(0.76rem, 1.1vw, 0.94rem);
}

body.player-question-mode .player-shell {
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}

body.player-question-mode .player-main {
  min-height: 0;
  overflow: hidden;
}

body.player-question-mode .player-view {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

body.player-question-mode .player-question-head {
  flex: 0 1 auto;
  max-height: min(48vh, 470px);
  min-height: 0;
  overflow: hidden;
}

body.player-question-mode .player-question-text {
  flex: 0 0 auto;
}

body.player-question-mode .player-answer-area {
  min-height: 0;
}

body.player-question-mode .player-answer-grid {
  min-height: 0;
  grid-auto-rows: minmax(92px, 1fr);
}

.player-view.is-cramped .player-question-image,
.player-question-head.is-cramped .player-question-image {
  height: min(15vh, 140px);
  margin-top: 8px;
  margin-bottom: 0;
}

.player-view.is-cramped .player-answer-grid {
  gap: 6px;
  grid-auto-rows: minmax(80px, 1fr);
}

.player-view.is-cramped .answer-tile {
  min-height: 0;
  padding: 9px 11px;
  gap: 8px;
  font-size: clamp(0.8rem, 2.5vw, 1.02rem);
}

.player-view.is-cramped .answer-tile .answer-shape {
  width: 24px;
  height: 24px;
}

.player-view.is-cramped .multi-hint {
  margin-top: 4px;
  font-size: 0.68rem;
}

.player-view.is-cramped .player-estimate-area {
  gap: 6px;
  padding-top: 0;
}

@media (max-width: 900px) {
  body.host-question-mode .host-question-card.has-image {
    grid-template-rows: minmax(0, 1fr) minmax(0, 0.7fr);
  }
}

@media (max-height: 650px) {
  body.player-question-mode .player-shell {
    padding-top: 6px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 7px;
  }

  body.player-question-mode .player-topbar {
    min-height: 36px;
  }

  body.player-question-mode .player-question-head {
    max-height: 40vh;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  body.player-question-mode .player-answer-grid {
    grid-auto-rows: minmax(62px, 1fr);
  }

  body.player-question-mode .answer-tile {
    min-height: 0;
    border-radius: 17px;
  }

  body.host-question-mode .host-shell {
    padding-top: 8px;
    padding-bottom: 8px;
    gap: 9px;
  }

  body.host-question-mode .host-question-view {
    gap: 9px;
  }
}

/* Custom touch handling around the native estimate slider. */
.estimate-slider-shell {
  position: relative;
}

.estimate-slider {
  display: block;
  pointer-events: none;
  touch-action: none;
}

.estimate-slider:focus-visible {
  outline: 3px solid rgba(10, 132, 255, 0.8);
  outline-offset: 7px;
}

.estimate-slider-hit {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 50%;
  height: 48px;
  border-radius: 999px;
  transform: translateY(-50%);
  touch-action: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.host-estimate-solution-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.host-estimate-solution-item.tolerance {
  align-items: flex-end;
  text-align: right;
}

.host-estimate-solution-item .eyebrow {
  font-size: 0.64rem;
}

.host-estimate-solution .range {
  font-size: clamp(0.95rem, 1.8vw, 1.25rem);
  white-space: nowrap;
}

.estimate-tolerance-hint {
  margin: -2px 0 10px;
  text-align: center;
  color: rgba(235, 235, 245, 0.46);
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Compact vertical histogram for the host estimate reveal. */
.estimate-hist-chart {
  margin-top: 14px;
  padding: 12px 14px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.065);
}

.estimate-hist-bars {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: clamp(150px, 25vh, 220px);
}

.estimate-hist-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.estimate-hist-count {
  min-height: 15px;
  color: rgba(235, 235, 245, 0.62);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.estimate-hist-track {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.estimate-hist-fill {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #45a2ff, #0a84ff);
  transition: height 0.45s var(--ease-out);
}

.estimate-hist-fill.in-range {
  background: linear-gradient(180deg, #8bf0a4, #30d158);
  box-shadow: 0 0 18px rgba(48, 209, 88, 0.18);
}

.estimate-hist-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: rgba(235, 235, 245, 0.38);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .estimate-hist-bars {
    gap: 3px;
    height: 140px;
  }

  .estimate-hist-count {
    font-size: 0.58rem;
  }
}

/* --------------------------------------------------------------------------
   Accounts, login and administration
   -------------------------------------------------------------------------- */

.join-code-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0 0 20px;
  padding: 15px 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.join-code-label {
  color: var(--text-tertiary);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.join-code-card strong {
  color: var(--text);
  font-size: 1.7rem;
  font-weight: 780;
  letter-spacing: 0.14em;
  line-height: 1.15;
  text-transform: lowercase;
}

.join-code-card > span:last-child {
  color: var(--text-secondary);
  font-size: 0.73rem;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 28px 18px;
}

.auth-shell {
  width: min(468px, 100%);
  animation: fade-up 0.55s var(--ease-out) both;
}

.auth-card {
  padding: clamp(28px, 6vw, 42px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text);
  margin-bottom: 34px;
}

.auth-wordmark {
  font-size: 1.55rem;
  font-weight: 780;
  letter-spacing: -0.055em;
}

.auth-heading {
  text-align: center;
  margin-bottom: 26px;
}

.auth-heading h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 7vw, 2.65rem);
  font-weight: 760;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

.auth-heading p {
  max-width: 35ch;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.auth-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.auth-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}

.auth-error,
.auth-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.auth-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 18%, transparent);
}

.auth-notice {
  color: var(--text-secondary);
  background: var(--field);
  border: 1px solid var(--line);
}

.auth-footnote {
  margin: 22px 0 0;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  line-height: 1.5;
}

.auth-contact-hint {
  margin: 7px 0 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.5;
}

.password-field {
  position: relative;
}

.password-field .input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--text);
  background: var(--field);
}

/* User menu */

.user-menu {
  position: relative;
  flex: 0 0 auto;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 4px 8px 4px 4px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: var(--field);
  border-color: var(--line);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 760;
  color: #fff;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  border: 1px solid color-mix(in srgb, #fff 30%, transparent);
}

.user-avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 0.92rem;
}

.user-menu-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.12;
  min-width: 0;
}

.user-menu-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 700;
}

.user-menu-role {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 0.62rem;
  font-weight: 600;
}

.user-menu-chevron {
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  transition: transform 0.18s ease;
}

.user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
  transform: rotate(180deg);
}

.user-menu-popover {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 120;
  width: 258px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  animation: scale-in 0.2s var(--ease-out) both;
}

.user-menu-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px 12px;
}

.user-menu-head-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 720;
}

.user-menu-head-role {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
}

.user-menu-item {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.user-menu-item:hover {
  background: var(--field);
}

.user-menu-item svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--text-secondary);
}

.user-menu-item-danger {
  color: var(--danger);
}

.user-menu-item-danger svg {
  color: var(--danger);
}

.user-menu-form {
  margin: 0;
  padding: 0;
}

.impersonation-note {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0 4px 7px;
  padding: 9px 10px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--text-secondary);
  font-size: 0.68rem;
  line-height: 1.4;
}

.user-menu-compact .user-menu-trigger {
  min-height: 34px;
  height: 34px;
  padding: 2px;
  border-radius: 50%;
}

.user-menu-compact .user-menu-label,
.user-menu-compact .user-menu-chevron {
  display: none;
}

.user-menu-dark .user-menu-trigger {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.09);
  color: rgba(245, 245, 247, 0.8);
}

.user-menu-dark .user-menu-trigger:hover,
.user-menu-dark .user-menu-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.11);
}

.user-menu-dark .user-menu-popover {
  background: #17171b;
  border-color: rgba(255, 255, 255, 0.12);
}

/* Profile */

.profile-shell {
  padding-bottom: 72px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: clamp(28px, 6vw, 54px) 0 30px;
}

.profile-avatar-wrap .profile-avatar,
.profile-avatar {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 2rem;
  color: #fff;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  border: 3px solid var(--surface-solid);
  box-shadow: var(--shadow-md);
}

.profile-hero h1 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 760;
  letter-spacing: -0.06em;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  color: var(--text-tertiary);
  font-size: 0.76rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--surface-soft);
  cursor: pointer;
}

.avatar-upload:hover {
  border-color: var(--primary);
}

.avatar-upload strong,
.avatar-upload small {
  display: block;
}

.avatar-upload strong {
  font-size: 0.82rem;
}

.avatar-upload small {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.7rem;
}

.avatar-upload input[type="file"] {
  display: none;
}

.field-hint {
  margin: 7px 0 0;
  color: var(--text-tertiary);
  font-size: 0.7rem;
  line-height: 1.45;
}

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--warning) 24%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--warning) 9%, transparent);
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* Quiz history */

.history-shell {
  padding-bottom: 72px;
}

.history-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(30px, 6vw, 56px) 0 26px;
}

.history-hero h1 {
  margin: 5px 0 9px;
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  font-weight: 760;
  letter-spacing: -0.06em;
  line-height: 1.02;
}

.history-hero p {
  max-width: 58ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.history-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.history-hero-mark {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}

.history-hero-mark svg {
  width: 36px;
  height: 36px;
}

.history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.history-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface-soft);
}

.history-stat span {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-stat strong {
  margin: 3px 0 1px;
  font-size: 1.65rem;
  font-weight: 760;
  letter-spacing: -0.05em;
}

.history-stat small {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-empty {
  padding: clamp(38px, 8vw, 72px) 24px;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--surface-soft);
  text-align: center;
}

.history-empty-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 18px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
}

.history-empty-icon svg {
  width: 28px;
  height: 28px;
}

.history-empty h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 730;
  letter-spacing: -0.04em;
}

.history-empty p {
  max-width: 42ch;
  margin: 0 auto 20px;
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.55;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-round {
  padding: clamp(18px, 3vw, 24px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface-solid) 76%, transparent);
  box-shadow: var(--shadow-sm);
}

.history-round-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.history-round-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.history-round-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
}

.history-round-icon svg {
  width: 19px;
  height: 19px;
}

.history-round h2 {
  margin: 1px 0 3px;
  font-size: 1.02rem;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.history-round-title-wrap p {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 0.7rem;
}

.history-winner {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  text-align: right;
}

.history-winner-label {
  color: var(--text-tertiary);
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-winner strong {
  font-size: 0.86rem;
}

.history-winner > span:last-child {
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 650;
}

.history-podium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.history-podium-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
}

.history-podium-rank {
  grid-row: 1 / 3;
  align-self: center;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--surface-soft);
  font-size: 0.7rem;
  font-weight: 750;
}

.history-podium-card.rank-1 .history-podium-rank {
  color: #5c4800;
  background: #ffd35c;
}

.history-podium-card.rank-2 .history-podium-rank {
  color: #3d3d42;
  background: #e5e5ea;
}

.history-podium-card.rank-3 .history-podium-rank {
  color: #5a2c16;
  background: #d89467;
}

.history-podium-card strong {
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-podium-card > span:last-child {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.history-details {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 11px;
}

.history-details summary {
  width: fit-content;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 650;
  list-style-position: inside;
}

.history-details summary:hover {
  color: var(--text);
}

.history-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.history-table th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-tertiary);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.history-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}

.history-table tbody tr:first-child td {
  border-top: 0;
}

.history-rank {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.history-points {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

@media (max-width: 700px) {
  .history-hero-mark {
    display: none;
  }

  .history-stats {
    grid-template-columns: 1fr 1fr;
  }

  .history-round-head {
    flex-direction: column;
    gap: 10px;
  }

  .history-winner {
    align-items: flex-start;
    padding-left: 50px;
    text-align: left;
  }
}

/* Administration */

.admin-shell {
  padding-bottom: 72px;
}

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(30px, 6vw, 56px) 0 26px;
}

.admin-hero h1 {
  margin: 5px 0 9px;
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  font-weight: 760;
  letter-spacing: -0.06em;
  line-height: 1.02;
}

.admin-hero p {
  max-width: 52ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.admin-hero-mark {
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}

.admin-hero-mark svg {
  width: 36px;
  height: 36px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface-soft);
}

.admin-stat span {
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-stat strong {
  margin: 3px 0 1px;
  font-size: 1.75rem;
  font-weight: 760;
  letter-spacing: -0.05em;
}

.admin-stat small {
  color: var(--text-tertiary);
  font-size: 0.68rem;
}

.admin-panel {
  margin-top: 22px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 25px;
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.admin-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-panel-head h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  font-weight: 730;
  letter-spacing: -0.04em;
}

.admin-count {
  color: var(--text-tertiary);
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.admin-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.admin-tools .library-search {
  flex: 1 1 230px;
  min-width: 0;
}

.admin-tools .select {
  width: auto;
  min-width: 145px;
}

.admin-create-form {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) minmax(150px, 1fr) minmax(140px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-create-submit .btn {
  min-height: 42px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-soft);
}

.admin-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.79rem;
}

.admin-table th {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--text-tertiary);
  font-size: 0.63rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-table td {
  padding: 12px 13px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tbody tr:first-child td {
  border-top: 0;
}

.admin-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 3%, transparent);
}

.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 165px;
}

.admin-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.admin-user-meta {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 0.66rem;
}

.admin-self-badge {
  margin-left: 3px;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--field);
  color: var(--text-tertiary);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
}

.role-badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 0.66rem;
  font-weight: 700;
  white-space: nowrap;
}

.role-owner {
  color: #fff;
  background: linear-gradient(135deg, #5e5ce6, #bf5af2);
  box-shadow: 0 4px 12px -6px rgba(94, 92, 230, 0.7);
}

.role-admin {
  color: #8a4b00;
  background: color-mix(in srgb, #ffb800 20%, transparent);
}

html[data-theme="dark"] .role-admin {
  color: #ffd35c;
}

.role-user {
  color: var(--text-secondary);
  background: var(--field);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
}

.status-badge > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.status-badge.is-active > span {
  background: var(--answer-green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--answer-green) 13%, transparent);
}

.status-badge.is-inactive {
  color: var(--danger);
}

.status-badge.is-inactive > span {
  background: var(--danger);
}

.admin-number {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.admin-muted {
  color: var(--text-tertiary);
  font-size: 0.72rem;
  white-space: nowrap;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1px;
}

.admin-row-actions form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

.admin-row-actions .btn {
  min-height: 30px;
  padding-inline: 8px;
  font-size: 0.7rem;
}

.admin-content-title {
  color: var(--text);
  font-weight: 650;
}

.admin-content-title:hover {
  color: var(--primary);
}

.admin-empty {
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  text-align: center;
}

#reset-password-modal .dialog {
  width: min(440px, 100%);
}

@media (max-width: 900px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .admin-create-form {
    grid-template-columns: 1fr 1fr;
  }

  .admin-create-submit {
    grid-column: 1 / -1;
  }

  .admin-create-submit .btn {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .topbar-actions {
    gap: 4px;
  }

  .user-menu-label {
    display: none;
  }

  .admin-stats {
    grid-template-columns: 1fr 1fr;
  }

  .admin-hero-mark {
    display: none;
  }

  .admin-create-form {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .profile-avatar-wrap .profile-avatar,
  .profile-avatar {
    width: 70px;
    height: 70px;
    font-size: 1.55rem;
  }

  .impersonation-banner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 460px) {
  .auth-page {
    padding: 16px 12px;
  }

  .auth-card {
    padding: 24px 19px;
    border-radius: 24px;
  }

  .admin-hero h1 {
    font-size: 2.15rem;
  }

  .admin-tools .select {
    flex: 1 1 140px;
    width: 100%;
  }
}
