*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family: 'Exo 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: #f1f5f9;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

body.qd-page {
    background: #0a1626;
    min-height: 100vh;
    min-height: 100dvh;
}

body.qd-page--room {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.qd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border: 1.5px solid transparent;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease,
        transform 0.1s ease, color 0.18s ease, box-shadow 0.2s ease;
    text-decoration: none;
    color: inherit;
    background: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.qd-btn:focus-visible {
    outline: 2px solid var(--qd-accent);
    outline-offset: 3px;
}

.qd-btn:active {
    transform: scale(0.98);
}

.qd-btn:disabled,
.qd-btn[disabled] {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

.qd-btn--lg {
    padding: 15px 34px;
    font-size: 17px;
    border-radius: 14px;
}

.qd-btn--primary {
    background: linear-gradient(135deg, var(--qd-accent) 0%, var(--qd-accent-2) 100%);
    color: #071827;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.qd-btn--primary:hover:not(:disabled) {
    filter: brightness(1.08);
}

.qd-btn--ghost {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--qd-panel-line);
    color: var(--qd-text);
}

.qd-btn--ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--qd-accent-border);
}

.qd-btn--share {
    background: var(--qd-share-bg);
    border-color: var(--qd-share-border);
    color: var(--qd-share-text);
}

.qd-btn--share:hover:not(:disabled) {
    background: var(--qd-share-bg-h);
    border-color: var(--qd-share-border-h);
}

.qd-btn--green {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #04241a;
}

.qd-btn--green:hover:not(:disabled) {
    filter: brightness(1.08);
}

.qd-btn--red {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
    color: #fff;
}

.qd-btn--red:hover:not(:disabled) {
    filter: brightness(1.08);
}

.qd-btn--scan {
    width: 100%;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--qd-panel-line);
    color: var(--qd-text);
    justify-content: center;
}

.qd-btn--scan:hover:not(:disabled) {
    background: var(--qd-accent-soft);
    border-color: var(--qd-accent-border);
}

.qd-btn__icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.qd-link {
    display: inline-block;
    padding: 4px 6px;
    background: none;
    border: none;
    color: var(--qd-accent);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.18s ease;
}

.qd-link:hover {
    color: #bae6fd;
}

/* ============================================================
   ИНПУТ
   ============================================================ */

.qd-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 16px;
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 12px;
    color: var(--qd-text);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 0.18s ease;
}

.qd-input::placeholder {
    color: var(--qd-muted);
    opacity: 0.7;
}

.qd-input:focus {
    border-color: var(--qd-accent);
}

.qd-key-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.qd-key-input {
    width: 100%;
    color: transparent;
    caret-color: var(--qd-text);
    text-align: center;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.qd-key-input::placeholder {
    color: var(--qd-muted);
    opacity: 0.7;
    letter-spacing: 0;
    font-weight: 400;
    text-align: center;
}

.qd-key-mirror {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    pointer-events: none;
    overflow: hidden;
    white-space: nowrap;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--qd-text);
    z-index: 1;
}

.qd-key-mirror span {
    display: inline-block;
    animation: qdKeyPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes qdKeyPop {
    0% {
        transform: scale(0.4);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qd-key-mirror span {
        animation: none;
    }
}

/* ============================================================
   МОДАЛКИ
   ============================================================ */

.qd-modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.qd-modal[hidden] {
    display: none;
}

.qd-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 18, 0.7);
}

.qd-modal__panel {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 28px 24px 22px;
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    text-align: center;
    animation: qdModalIn 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.qd-modal__panel--sm {
    max-width: 380px;
}

.qd-modal__panel--qr {
    max-width: 520px;
    padding: 20px;
}

@keyframes qdModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.qd-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--qd-muted);
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.qd-modal__close svg {
    width: 16px;
    height: 16px;
}

.qd-modal__close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.qd-modal__title {
    margin: 0 0 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--qd-text);
}

.qd-modal__text {
    margin: 0 0 20px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--qd-muted);
}

.qd-modal__text b {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.qd-modal__icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--qd-accent-soft);
    border: 1.5px solid var(--qd-accent-border);
}

.qd-modal__icon svg {
    width: 26px;
    height: 26px;
    color: var(--qd-accent);
}

.qd-modal__icon--info {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.45);
}

.qd-modal__icon--info svg {
    color: #38bdf8;
}

.qd-modal__icon--warn {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.45);
}

.qd-modal__icon--warn svg {
    color: #fbbf24;
}

.qd-modal__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.qd-modal__actions .qd-btn {
    flex: 1 1 auto;
    min-width: 130px;
}

/* ============================================================
   PAUSED MODAL
   ============================================================ */

.qd-paused-modal .qd-modal__panel {
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
}

.qd-paused-modal .qd-modal__title {
    color: var(--qd-text);
}

.qd-paused-modal .qd-modal__text {
    color: var(--qd-muted);
    margin-bottom: 0;
}

.qd-paused-modal .qd-modal__text b {
    color: var(--qd-text);
}

.qd-paused-modal .qd-modal__icon--warn {
    background: var(--qd-accent-soft);
    border-color: var(--qd-accent-border);
}

.qd-paused-modal .qd-modal__icon--warn svg {
    color: var(--qd-accent);
}

.qd-paused__key-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--qd-panel-line);
}

.qd-paused__key-label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--qd-muted);
}

.qd-paused__key {
    font-size: clamp(1.2rem, 5vw, 2.2rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.02em;
    color: #fff;
    text-shadow:
        -1.5px -1.5px 0 #0a0a0a,
        1.5px -1.5px 0 #0a0a0a,
        -1.5px 1.5px 0 #0a0a0a,
        1.5px 1.5px 0 #0a0a0a,
        0 -1.5px 0 #0a0a0a,
        0 1.5px 0 #0a0a0a,
        -1.5px 0 0 #0a0a0a,
        1.5px 0 0 #0a0a0a,
        0 4px 14px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    max-width: 100%;
}

.qd-paused__exit {
    margin-top: 18px;
    width: 100%;
}

.qd-c-red {
    color: #ff5c5c;
    font-weight: 700;
}

.qd-c-blue {
    color: #5c9eff;
    font-weight: 700;
}

/* ============================================================
   TOAST
   ============================================================ */

.qd-toast-container {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    padding: 0 12px;
    max-width: 100%;
}

.qd-toast {
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-16px);
    transition: opacity 0.28s ease, transform 0.28s ease;
    max-width: 420px;
    text-align: center;
    pointer-events: auto;
}

.qd-toast.is-shown {
    opacity: 1;
    transform: translateY(0);
}

.qd-toast.is-error {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

.qd-toast.is-warn {
    background: linear-gradient(135deg, #f59e0b, #b45309);
}

.qd-toast.is-info {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

/* ============================================================
   WELCOME PAGE
   ============================================================ */

.qd-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.qd-bg canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.qd-welcome {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px 22px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    max-width: 720px;
    margin: 0 auto;
}

.qd-welcome__header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.qd-welcome__title {
    margin: 0;
    font-size: clamp(1.6rem, 4.6vw, 2.6rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--qd-text);
    transform: rotate(-2.2deg);
    transform-origin: 50% 50%;
    animation: qdTitlePulse 3.6s ease-in-out infinite;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-text-stroke: 3px #000;
    paint-order: stroke fill;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.qd-theme-picker {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

.qd-theme-btn {
    width: 46px;
    height: 46px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(19, 39, 65, 0.85);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 11px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.1s ease, box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.qd-theme-btn:hover {
    border-color: var(--qd-accent-border);
    background: var(--qd-accent-soft);
}

.qd-theme-btn:active {
    transform: scale(0.95);
}

.qd-theme-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35);
}

.qd-theme-btn.active {
    border-color: var(--qd-accent);
    background: var(--qd-accent-soft);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.qd-theme-btn svg {
    width: 26px;
    height: 26px;
    display: block;
    pointer-events: none;
}

@keyframes qdTitlePulse {

    0%,
    100% {
        transform: rotate(-2.2deg) scale(1);
    }

    50% {
        transform: rotate(-2.2deg) scale(1.035);
    }
}

.qd-welcome__kicker {
    font-family: 'Exo 2', system-ui, sans-serif;
    font-size: clamp(2.2rem, 6.5vw, 4rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    text-align: center;
    margin: 0;
    color: var(--qd-kicker);
    -webkit-text-stroke: 5px #000;
    paint-order: stroke fill;
    text-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    user-select: none;
    pointer-events: none;
}

.qd-waiting__kicker {
    font-family: 'Exo 2', system-ui, sans-serif;
    font-size: clamp(2rem, 7.5vw, 3.4rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: center;
    color: var(--qd-kicker);
    -webkit-text-stroke: 4.5px #000;
    paint-order: stroke fill;
    text-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
    user-select: none;
    pointer-events: none;
    flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
    .qd-welcome__title {
        animation: none;
    }
}

.qd-welcome__params {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.95rem;
    color: var(--qd-muted);
    -webkit-text-stroke: 2px #0a0a0a;
    paint-order: stroke fill;
}

.qd-welcome__param {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}

.qd-welcome__param-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--qd-text);
    -webkit-text-stroke: 2px #0a0a0a;
    paint-order: stroke fill;
}

.qd-welcome__param-label {
    font-size: 0.85rem;
    color: var(--qd-muted);
    -webkit-text-stroke: 2px #0a0a0a;
    paint-order: stroke fill;
}

.qd-welcome__divider {
    width: 1px;
    height: 22px;
    background: var(--qd-panel-line);
    -webkit-text-stroke: 0;
}

.qd-welcome__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    width: 100%;
}

.qd-welcome__block {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 16px;
    text-align: left;
}

.qd-welcome__block--create {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    min-width: 0;
}

.qd-welcome__block--create .qd-btn--primary {
    width: 100%;
    padding: 15px 22px;
    font-size: 16px;
    border-radius: 12px;
}

.qd-welcome__rooms {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    min-width: 0;
    max-height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 22px;
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(141, 192, 242, 0.4) transparent;
}

.qd-welcome__rooms::-webkit-scrollbar {
    width: 6px;
}

.qd-welcome__rooms::-webkit-scrollbar-track {
    background: transparent;
}

.qd-welcome__rooms::-webkit-scrollbar-thumb {
    background: rgba(141, 192, 242, 0.4);
    border-radius: 3px;
}

.qd-rooms-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.qd-rooms-group__title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qd-muted);
    padding: 0 4px;
}

.qd-rooms-group__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.qd-myroom {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
    background: var(--qd-accent-soft);
    border: 1px solid var(--qd-accent-border);
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.3;
    text-decoration: none;
    color: var(--qd-accent);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.qd-myroom:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: rgba(56, 189, 248, 0.65);
    color: #bae6fd;
}

.qd-myroom:focus-visible {
    outline: 2px solid var(--qd-accent);
    outline-offset: 2px;
}

.qd-myroom__name {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qd-myroom:hover .qd-myroom__name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.qd-myroom__key {
    flex: 0 0 auto;
    display: inline-block;
    padding: 2px 8px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.15);
    border-radius: 6px;
    color: #0a0a0a;
    font-weight: 700;
    font-size: 0.82em;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
}

.qd-welcome__block--join {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qd-welcome__label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--qd-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.qd-join-row {
    display: flex;
    gap: 8px;
}

.qd-welcome__hint {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--qd-muted);
    opacity: 0.8;
}

@media (max-width: 620px) {
    .qd-welcome {
        padding: 12px 16px 40px;
        gap: 18px;
    }

    .qd-welcome__actions {
        grid-template-columns: 1fr;
    }

    .qd-welcome__title {
        -webkit-text-stroke: 2px #000;
    }

    .qd-welcome__kicker {
        font-size: clamp(1.7rem, 9vw, 2.4rem);
        -webkit-text-stroke: 4px #000;
    }

    .qd-waiting__kicker {
        font-size: clamp(1.8rem, 8.5vw, 2.4rem);
        -webkit-text-stroke: 3.5px #000;
    }

    .qd-waiting {
        gap: 10px;
        padding: 12px;
    }

    .qd-waiting__card {
        max-height: calc(100dvh - 80px);
    }

    .qd-welcome.has-rooms {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "header header"
            "create rooms"
            "join   join"
            "footer footer";
        align-items: stretch;
        gap: 12px;
        padding: 20px 12px 60px;
    }

    .qd-welcome.has-rooms .qd-welcome__header {
        grid-area: header;
    }

    .qd-welcome.has-rooms .qd-welcome__actions {
        display: contents;
    }

    .qd-welcome.has-rooms .qd-welcome__block--create {
        grid-area: create;
    }

    .qd-welcome.has-rooms .qd-welcome__block--join {
        grid-area: join;
    }

    .qd-welcome.has-rooms .qd-welcome__rooms {
        grid-area: rooms;
        max-height: 60dvh;
        gap: 10px;
        padding: 14px 12px;
    }

    .qd-rooms-group__title {
        font-size: 0.65rem;
        letter-spacing: 0.06em;
    }

    .qd-rooms-group__list {
        gap: 6px;
    }

    .qd-myroom {
        padding: 8px 10px;
        font-size: 0.78rem;
        gap: 6px;
    }

    .qd-myroom__key {
        padding: 1px 6px;
        font-size: 0.75em;
    }

    .qd-welcome.has-rooms .qd-welcome__block--create {
        padding: 16px 14px;
        gap: 10px;
    }

    .qd-welcome.has-rooms .qd-welcome__block--create .qd-btn--primary {
        padding: 12px 14px;
        font-size: 14px;
    }

    .qd-welcome.has-rooms .qd-theme-btn {
        width: 38px;
        height: 38px;
    }

    .qd-welcome.has-rooms .qd-theme-btn svg {
        width: 22px;
        height: 22px;
    }

    .qd-welcome.has-rooms .qd-myroom {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .qd-welcome.has-rooms .qd-myroom__key {
        align-self: flex-start;
        max-width: 100%;
        overflow: hidden;
    }
}

/* ============================================================
   QR MODAL
   ============================================================ */

.qd-qr-modal__stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    margin-bottom: 16px;
}

.qd-qr-modal__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.qd-qr-modal__video[hidden] {
    display: none;
}

.qd-qr-modal__placeholder {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--qd-muted);
}

.qd-qr-modal__placeholder[hidden] {
    display: none;
}

.qd-qr-modal__placeholder svg {
    width: 60px;
    height: 60px;
    opacity: 0.45;
}

.qd-qr-modal__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.qd-qr-modal__links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.qd-qr-modal__links-sep {
    color: var(--qd-muted);
    opacity: 0.5;
    user-select: none;
}

.qd-qr-modal__status {
    margin: 12px 0 0;
    min-height: 18px;
    font-size: 0.85rem;
    color: var(--qd-muted);
    text-align: center;
}

.qd-qr-modal__status.is-error {
    color: #f87171;
}

.qd-qr-modal__status.is-warn {
    color: #fbbf24;
}

/* ============================================================
   ROOM PAGE
   ============================================================ */

.qd-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.qd-hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: linear-gradient(180deg, rgba(6, 14, 26, 0.85) 0%, rgba(6, 14, 26, 0) 100%);
    pointer-events: none;
}

.qd-hud>* {
    pointer-events: auto;
}

.qd-hud__left {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.qd-hud__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--qd-text);
    line-height: 1.2;
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.qd-hud.hud-truncate .qd-hud__title {
    overflow: hidden;
    text-overflow: ellipsis;
}

.qd-hud__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--qd-muted);
    opacity: 0.9;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
    white-space: nowrap;
    margin-top: 0;
}

.qd-hud__meta-divider {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--qd-muted);
    opacity: 0.6;
}

.qd-hud__right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.qd-hud__badge {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    padding: 5px 12px;
    background: rgba(6, 14, 26, 0.75);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    color: var(--qd-text);
    letter-spacing: 0.02em;
}

.qd-hud__badge-value {
    color: var(--qd-accent);
}

.qd-hud__badge-sep {
    opacity: 0.4;
}

.qd-hud__badge-total {
    color: var(--qd-muted);
}

.qd-hud__exit {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--qd-panel-line);
    background: rgba(6, 14, 26, 0.75);
    color: var(--qd-text);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.qd-hud__exit svg {
    width: 18px;
    height: 18px;
}

.qd-hud__exit:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fecaca;
}

/* ============================================================
   WAITING OVERLAY
   ============================================================ */

.qd-waiting {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    pointer-events: none;
}

.qd-waiting[hidden] {
    display: none;
}

.qd-waiting__card {
    width: 100%;
    max-width: min(420px, 60vw);
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 28px 24px;
    background: var(--qd-panel);
    border: 1.5px solid var(--qd-panel-line);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
}

.qd-waiting__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--qd-muted);
}

.qd-waiting__key {
    font-size: clamp(1.4rem, 5vw, 2.6rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
    line-height: 1.05;
    text-shadow:
        -1.5px -1.5px 0 #0a0a0a,
        1.5px -1.5px 0 #0a0a0a,
        -1.5px 1.5px 0 #0a0a0a,
        1.5px 1.5px 0 #0a0a0a,
        0 -1.5px 0 #0a0a0a,
        0 1.5px 0 #0a0a0a,
        -1.5px 0 0 #0a0a0a,
        1.5px 0 0 #0a0a0a,
        0 4px 14px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    max-width: 100%;
}

.qd-waiting__qr {
    padding: 12px;
    background: #ffffff;
    border-radius: 14px;
    line-height: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.qd-waiting__qr img {
    display: block;
    width: 200px;
    height: auto;
    aspect-ratio: 1 / 1;
    max-width: 100%;
    object-fit: contain;
}

.qd-waiting__copy {
    display: inline-block;
    padding: 6px 10px;
    background: none;
    border: none;
    color: var(--qd-accent);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.18s ease;
}

.qd-waiting__copy:hover {
    color: #bae6fd;
}

.qd-waiting__copy[hidden] {
    display: none;
}

.qd-waiting__footer {
    width: 100%;
    padding-top: 12px;
    border-top: 1px solid var(--qd-panel-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.qd-waiting__footer:empty,
.qd-waiting__footer>[hidden]:only-child {
    padding-top: 0;
    border-top: none;
}

.qd-waiting__player-hint {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--qd-muted);
    text-align: center;
    max-width: 320px;
}

.qd-waiting__player-hint[hidden] {
    display: none;
}

.qd-waiting__idle {
    font-size: 12.5px;
    color: var(--qd-muted);
    text-align: center;
    width: 100%;
}

.qd-waiting__idle[hidden] {
    display: none;
}

.qd-waiting__idle b {
    color: var(--qd-text);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.qd-waiting__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 260px;
    margin-top: 4px;
}

.qd-waiting__actions .qd-btn {
    width: 100%;
}

.qd-waiting__actions .qd-btn--exit {
    font-size: 14px;
    padding: 10px 18px;
}

.qd-btn--lg[hidden] {
    display: none;
}

/* ============================================================
   FINISHED BAR
   ============================================================ */

.qd-finished-bar {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: calc(100vw - 24px);
}

.qd-finished-bar[hidden] {
    display: none;
}

/* ============================================================
   NOT FOUND
   ============================================================ */

.qd-notfound {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 22px;
    text-align: center;
}

.qd-notfound__icon {
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--qd-panel-line);
    color: var(--qd-muted);
    margin-bottom: 6px;
}

.qd-notfound__icon svg {
    width: 38px;
    height: 38px;
}

.qd-notfound__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--qd-text);
}

.qd-notfound__text {
    margin: 0 0 8px;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--qd-muted);
    max-width: 380px;
}

.qd-offer-timer {
    margin: 0 0 18px;
}

.qd-offer-timer__bar {
    height: 6px;
    background: rgba(10, 25, 45, 0.65);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.qd-offer-timer__fill {
    height: 100%;
    width: 100%;
    background: #4ade80;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.qd-offer-timer__text {
    font-size: 12.5px;
    color: var(--qd-muted);
    text-align: center;
}

.qd-offer-timer__text b {
    color: var(--qd-text);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   LOADER
   ============================================================ */

.qd-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    background: var(--qd-loader, #5fb6df);
}

.qd-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.qd-loader__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.qd-loader__dots {
    display: flex;
    gap: 6px;
}

.qd-loader__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    animation: qdLoaderBounce 1.2s ease-in-out infinite;
}

.qd-loader__dot:nth-child(2) {
    animation-delay: 0.15s;
}

.qd-loader__dot:nth-child(3) {
    animation-delay: 0.3s;
}

.qd-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 20px calc(14px + env(safe-area-inset-bottom));
    font-size: 0.78rem;
    color: var(--qd-muted);
    opacity: 0.75;
    text-align: center;
    pointer-events: none;
}

.qd-footer__link {
    color: var(--qd-accent);
    text-decoration: none;
    font-weight: 600;
    pointer-events: auto;
    transition: color 0.18s ease;
}

.qd-footer__link:hover {
    color: #bae6fd;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.qd-footer__sep {
    color: var(--qd-muted);
    opacity: 0.5;
    user-select: none;
}

.qd-footer__text {
    color: var(--qd-muted);
}

@keyframes qdLoaderBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.55;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.qd-loader__text {
    font-family: 'Exo 2', system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

@media (prefers-reduced-motion: reduce) {
    .qd-loader__dot {
        animation: none;
        opacity: 0.8;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 700px) {
    .qd-hud {
        padding: 6px 12px;
        gap: 8px;
    }

    .qd-hud__left {
        gap: 8px;
    }

    .qd-hud__title {
        font-size: 13px;
    }

    .qd-hud__meta {
        font-size: 11px;
        gap: 6px;
    }

    .qd-hud__meta-divider {
        display: none;
    }

    .qd-hud__badge {
        padding: 3px 8px;
        font-size: 11px;
    }

    .qd-hud__exit {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 520px) {
    .qd-hud {
        padding: 10px 12px;
        gap: 8px;
    }

    .qd-hud__title {
        font-size: 13px;
    }

    .qd-hud__meta {
        font-size: 11px;
        gap: 6px;
    }

    .qd-hud__badge {
        padding: 4px 10px;
        font-size: 12px;
    }

    .qd-hud__exit {
        width: 34px;
        height: 34px;
    }

    .qd-hud__exit svg {
        width: 16px;
        height: 16px;
    }

    .qd-modal__actions .qd-btn {
        flex: 1 1 100%;
    }

    #qdOfferModal .qd-modal__actions {
        flex-wrap: nowrap;
    }

    #qdOfferModal .qd-modal__actions .qd-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 12px 10px;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .qd-finished-bar {
        bottom: 18px;
    }
}

@media (max-width: 620px) {
    .qd-waiting {
        padding: 10px;
    }

    .qd-waiting__card {
        padding: 16px 14px;
        border-radius: 16px;
        gap: 10px;
    }

    .qd-waiting__qr {
        padding: 8px;
        border-radius: 10px;
    }

    .qd-waiting__qr img {
        width: 42vw;
        max-width: 150px;
    }

    .qd-waiting__key {
        font-size: clamp(1rem, 4.5vw, 1.4rem);
    }

    .qd-waiting__label {
        font-size: 11px;
        letter-spacing: 0.08em;
    }

    .qd-waiting__player-hint {
        font-size: 12.5px;
        max-width: 100%;
    }

    .qd-waiting__idle {
        font-size: 11.5px;
    }

    .qd-waiting__actions {
        max-width: 100%;
    }

    .qd-waiting__actions .qd-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .qd-waiting__actions .qd-btn--exit {
        font-size: 12.5px;
        padding: 8px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .qd-modal__panel {
        animation: none;
    }

    .qd-btn:active {
        transform: none;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .qd-modal {
        align-items: flex-start;
        padding: 8px 12px;
    }

    .qd-modal__panel {
        max-height: calc(100dvh - 16px);
        padding: 14px 16px 12px;
        border-radius: 14px;
    }

    .qd-modal__panel--qr {
        padding: 12px;
    }

    .qd-modal__title {
        font-size: 1rem;
        margin-bottom: 6px;
    }

    .qd-modal__text {
        font-size: 0.82rem;
        margin-bottom: 12px;
    }

    .qd-modal__icon {
        width: 40px;
        height: 40px;
        margin-bottom: 8px;
    }

    .qd-modal__icon svg {
        width: 20px;
        height: 20px;
    }

    .qd-modal__actions {
        gap: 8px;
    }

    .qd-modal__actions .qd-btn {
        padding: 10px 14px;
        font-size: 0.88rem;
        min-width: 0;
    }

    .qd-paused__key-wrap {
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .qd-paused__key {
        font-size: 1.2rem;
    }

    .qd-offer-timer {
        margin-bottom: 10px;
    }

    .qd-qr-modal__stage {
        max-height: 40dvh;
        aspect-ratio: auto;
    }

    .qd-waiting {
        align-items: center;
        justify-content: flex-start;
        padding: 8px 12px;
    }

    .qd-waiting__card {
        max-height: calc(100dvh - 16px);
        padding: 14px 16px;
        border-radius: 14px;
        gap: 8px;
    }

    .qd-waiting__qr img {
        width: 140px;
    }

    .qd-waiting__key {
        font-size: clamp(1.2rem, 6vw, 1.6rem);
    }

    .qd-waiting__actions .qd-btn {
        padding: 9px 14px;
        font-size: 0.85rem;
    }

    .qd-finished-bar {
        bottom: 10px;
        max-width: calc(65vw - 16px);
    }

    .qd-finished-bar .qd-btn--lg {
        padding: 10px 24px;
        font-size: 0.9rem;
    }

    .qd-hud {
        padding: 6px 10px;
    }

    .qd-hud__title {
        font-size: 12px;
    }

    .qd-hud__meta {
        font-size: 10px;
        margin-top: 2px;
    }

    .qd-hud__badge {
        padding: 3px 8px;
        font-size: 11px;
    }

    .qd-hud__exit {
        width: 30px;
        height: 30px;
    }
}

/* ============================================================
   SHARE RESULT
   ============================================================ */
.qd-flash {
    position: fixed;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 950;
}

.qd-flash.is-on {
    animation: qdFlash 0.55s ease-out;
}

@keyframes qdFlash {
    0% {
        opacity: 0;
    }

    12% {
        opacity: 0.95;
    }

    100% {
        opacity: 0;
    }
}

.qd-modal__panel--share {
    max-width: 560px;
}

.qd-share__preview {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 0 14px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    transform: rotate(-1.5deg);
    animation: qdShareIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes qdShareIn {
    from {
        opacity: 0;
        transform: scale(0.8) rotate(-7deg);
    }

    to {
        opacity: 1;
        transform: scale(1) rotate(-1.5deg);
    }
}

@media (max-width: 520px) {
    .qd-finished-bar {
        flex-direction: column;
        left: calc(17.5vw + 8px);
        right: calc(17.5vw + 8px);
        transform: none;
        width: auto;
    }

    .qd-finished-bar .qd-btn {
        width: 100%;
    }
}

/* ============================================================
   RESULT PAGE
   ============================================================ */
.qdr {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 16px 60px;
    text-align: center;
    pointer-events: none;
}

.qdr a {
    pointer-events: auto;
}

.qdr__kicker {
    font-size: clamp(2rem, 7vw, 3.4rem);
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1;
    color: var(--qd-accent);
    -webkit-text-stroke: 4px #000;
    paint-order: stroke fill;
}

.qdr__title {
    margin: 0;
    max-width: 720px;
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 800;
    color: #fff;
    -webkit-text-stroke: 3px #000;
    paint-order: stroke fill;
    overflow-wrap: anywhere;
}

.qdr__headline {
    font-size: clamp(1.6rem, 6vw, 2.6rem);
    font-weight: 800;
    color: #fff;
    -webkit-text-stroke: 4px #000;
    paint-order: stroke fill;
}

.qdr__photo {
    margin: 6px 0;
    width: min(78vw, 340px);
    transform: rotate(-5deg);
    filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.5));
    animation: qdrDrop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.qdr__photo img {
    display: block;
    width: 100%;
    height: auto;
}

@keyframes qdrDrop {
    from {
        opacity: 0;
        transform: translateY(-60px) rotate(-14deg) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) rotate(-5deg) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {

    .qdr__photo,
    .qd-share__preview {
        animation: none;
    }
}

.qd-btn[hidden] {
    display: none;
}

.qd-share__nets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 12px;
}

.qd-share__nets[hidden] {
    display: none;
}

.qd-share__net {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 11px 10px;
    border: 1.5px solid var(--qd-panel-line);
    border-left-width: 4px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--qd-text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.qd-share__net:hover {
    background: rgba(255, 255, 255, 0.12);
}

.qd-share__net[data-net="telegram"] {
    border-left-color: #2aabee;
}

.qd-share__net[data-net="viber"] {
    border-left-color: #7360f2;
}

.qd-share__net[data-net="vk"] {
    border-left-color: #0077ff;
}

.qd-share__net[data-net="ok"] {
    border-left-color: #ee8208;
}

.qd-share__nets.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.qdr .qd-footer {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    opacity: 0.9;
}


.qd-welcome__block--create,
#qdCreateBtn {
    position: relative;
}

.qd-btnblock {
    position: absolute;
    pointer-events: none;
    z-index: 4;
}

.qd-fxskin,
.qd-fxskin .qd-btn__label {
    background: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: transparent !important;
    filter: none !important;
}

.qd-fxhit {
    position: absolute;
    z-index: 5;
    cursor: pointer;
}

.qd-theme-picker {
    isolation: isolate;
}

.qd-theme-btn {
    position: relative;
}

.qd-btnfx {
    position: absolute;
    pointer-events: none;
    z-index: 3;
}

.qd-clay {
    background: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
    filter: none !important;
}

.qd-clay .qd-btn__label {
    color: transparent !important;
}

.qd-clay--icon>svg {
    visibility: hidden;
}