:root {
    --bg: #071426;
    --bg-2: #0d2440;
    --card: #102946;
    --card-2: #143456;
    --line: rgba(210, 232, 255, 0.16);
    --text: #f7fbff;
    --muted: #a9bdd1;
    --blue: #56c7ff;
    --green: #63e68a;
    --yellow: #ffd66b;
    --red: #ff6b6b;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
    --radius: 20px;
}

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

html,
body {
    width: 100%;
    min-width: 320px;
    min-height: 100%;
    overflow-x: hidden;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 16px 16px, rgba(86, 199, 255, 0.12) 0 2px, transparent 3px),
        linear-gradient(145deg, #061225 0%, #0b1f39 48%, #112c4a 100%);
    background-size: 32px 32px, auto;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

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

button,
.btn,
.code-button {
    touch-action: manipulation;
}

input,
select,
textarea {
    width: 100%;
    min-height: 50px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

textarea {
    min-height: 88px;
    padding-top: 12px;
    resize: vertical;
}

select {
    color-scheme: dark;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(86, 199, 255, 0.16);
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 750;
}

.form-helper {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

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

h1 {
    margin-bottom: 10px;
    font-size: clamp(2.1rem, 7vw, 4.5rem);
    line-height: 1;
    letter-spacing: -0.055em;
}

h2 {
    margin-bottom: 10px;
    font-size: clamp(1.35rem, 4vw, 2.1rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

h3 {
    margin-bottom: 8px;
    font-size: 1.05rem;
}

p {
    line-height: 1.55;
}

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

.site-shell {
    min-height: 100dvh;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
}

.top-brand {
    width: min(100% - 24px, 920px);
    min-height: 52px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.top-brand a {
    color: var(--text);
    font-size: 1.18rem;
    font-weight: 950;
    letter-spacing: -0.035em;
}

.top-brand span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 850;
}

.page-shell {
    width: min(100% - 32px, 920px);
    margin-inline: auto;
}

.home-shell {
    padding: 4px 0 28px;
}

.page-stack {
    display: grid;
    gap: 18px;
    padding: 28px 0 34px;
}

.center-wrap {
    width: min(100% - 32px, 520px);
    min-height: 58dvh;
    margin-inline: auto;
    display: grid;
    place-items: center;
    padding: 18px 0 34px;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
}

.site-footer a {
    color: var(--muted);
    font-weight: 750;
    font-size: 0.95rem;
}

.site-footer a:hover {
    color: var(--text);
}

.site-footer {
    width: min(100% - 32px, 920px);
    margin: 22px auto 0;
    padding: 18px 0 max(6px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    text-align: center;
}

.site-footer p {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.card,
.glass-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(20, 52, 86, 0.96), rgba(13, 36, 64, 0.96));
    box-shadow: var(--shadow);
}

.home-hero {
    display: grid;
    justify-items: center;
    text-align: center;
    padding: 4px 0 12px;
}

.concept-line {
    margin-bottom: 8px;
    color: var(--text);
    font-size: clamp(1.08rem, 3vw, 1.35rem);
    font-weight: 750;
}

.helper-line {
    margin-bottom: 0;
    color: var(--muted);
}

.home-hero h1 {
    font-size: clamp(48px, 11vw, 86px);
}

.play-panel {
    width: min(100%, 620px);
    margin: 0 auto;
    padding: clamp(18px, 4vw, 28px);
}

.play-form,
.compact-form,
.join-room-form,
.join-card form {
    display: grid;
    gap: 12px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.mini-card,
.join-card,
.text-card,
.page-title-card {
    padding: clamp(18px, 4vw, 26px);
}

.mini-card p,
.page-title-card p,
.text-card p {
    color: var(--muted);
}

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

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-row input {
    width: 18px;
    min-height: 18px;
    accent-color: var(--green);
}

.btn,
.code-button {
    display: inline-flex;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 0 18px;
    color: #06213a;
    background: #eef7ff;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.16s ease, opacity 0.16s ease;
}

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

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn.primary {
    background: linear-gradient(135deg, var(--green), var(--blue));
}

.btn.secondary {
    background: linear-gradient(135deg, var(--yellow), var(--green));
}

.btn.outline,
.btn.tertiary {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
}

.btn.small {
    min-height: 42px;
    padding-inline: 14px;
}

.btn.wide {
    width: 100%;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.info-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.07);
}

.info-card span,
.steps-list li::marker {
    color: var(--green);
    font-weight: 900;
}

.info-card p {
    margin-bottom: 0;
    color: var(--muted);
}

.page-title-card {
    text-align: left;
}

.page-title-card h1 {
    font-size: clamp(2.25rem, 7vw, 4rem);
}

.page-title-card .btn {
    width: fit-content;
    margin-top: 6px;
}

.leader-list,
.room-list,
.players-list,
.scoreboard,
.plain-list,
.steps-list {
    display: grid;
    gap: 10px;
}

.leader-row,
.room-chip,
.player-chip,
.score-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.07);
}

.leader-row small,
.room-chip em,
.score-row small,
.player-chip small {
    color: var(--muted);
    font-style: normal;
}

.room-chip strong,
.leader-row strong,
.player-chip strong,
.score-row strong {
    overflow-wrap: anywhere;
}

.plain-list,
.steps-list {
    margin: 0;
    padding-left: 22px;
    color: var(--muted);
}

.plain-list a,
.contact-link {
    color: var(--blue);
    font-weight: 800;
}

.room-app {
    width: min(100% - 32px, 1180px);
    margin-inline: auto;
    padding: 0 0 24px;
}

.room-top {
    position: sticky;
    top: 4px;
    z-index: 4;
    display: grid;
    grid-template-columns: auto repeat(4, minmax(84px, auto)) auto;
    align-items: center;
    gap: 8px;
    padding: 8px;
}

.room-title {
    display: grid;
    gap: 2px;
}

.room-code-card {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 6px 6px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.07);
}

.room-stat {
    display: grid;
    gap: 2px;
    min-height: 44px;
    align-content: center;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
}

.room-stat strong {
    font-size: 0.92rem;
}

.room-stat small {
    font-size: 0.72rem;
}

.code-button {
    min-height: 40px;
    border-radius: 10px;
    background: var(--blue);
}

.connection-state {
    color: var(--muted);
    font-weight: 800;
}

.status-banner {
    margin: 8px 0;
    padding: 10px 12px;
    color: var(--muted);
}

.status-banner strong {
    color: var(--text);
}

.room-tabs {
    display: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0;
}

.room-tab-button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    font-weight: 900;
}

.room-tab-button.active {
    color: #06213a;
    background: linear-gradient(135deg, var(--green), var(--blue));
}

.room-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(220px, 0.75fr);
    gap: 12px;
    align-items: start;
}

.game-card {
    grid-row: span 3;
}

.side-card,
.game-card {
    padding: 16px;
}

.game-card {
    min-height: 440px;
}

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

.section-head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.player-chip.offline {
    opacity: 0.62;
}

.badge {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--blue);
    background: rgba(86, 199, 255, 0.12);
    font-size: 0.76rem;
    font-weight: 850;
}

.badge.gold {
    color: var(--yellow);
    background: rgba(255, 214, 107, 0.13);
}

.badge.ok {
    color: var(--green);
    background: rgba(99, 230, 138, 0.12);
}

.phase-panel,
.phase-head {
    display: grid;
    gap: 12px;
}

.phase-head h1,
.phase-head h2 {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 3rem);
}

.timer-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.timer-badge {
    display: inline-grid;
    min-width: 66px;
    min-height: 46px;
    place-items: center;
    border-radius: 14px;
    color: #06213a;
    background: var(--yellow);
    font-size: 1.32rem;
    font-weight: 950;
}

.timer-badge.panic {
    background: var(--red);
    animation: pulse 0.7s infinite alternate;
}

.pattern,
.secret-word {
    width: 100%;
    padding: clamp(18px, 4vw, 26px);
    border-radius: 18px;
    text-align: center;
    overflow-wrap: anywhere;
}

.pattern {
    color: var(--text);
    background: rgba(86, 199, 255, 0.12);
    font-size: clamp(1.75rem, 8vw, 3.8rem);
    font-weight: 950;
    letter-spacing: 0.1em;
}

.secret-word {
    color: #06213a;
    background: linear-gradient(135deg, var(--green), var(--blue));
    font-size: clamp(1.7rem, 6vw, 2.8rem);
    font-weight: 950;
}

.option-grid,
.hint-grid,
.final-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

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

.word-option,
.hint-card,
.feed-line,
.correct-card,
.final-stat {
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
}

.suggested-hint-card {
    position: relative;
    display: grid;
    gap: 8px;
    width: 100%;
    min-height: 82px;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.suggested-hint-card:focus-visible {
    outline: 3px solid rgba(86, 199, 255, 0.34);
    outline-offset: 2px;
}

.suggested-hint-text,
.submitted-hint-text {
    font-weight: 850;
    overflow-wrap: anywhere;
}

.hint-use-meta {
    display: inline-flex;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    color: #06213a;
    background: var(--blue);
    font-size: 0.8rem;
    font-weight: 900;
}

.submitted-hint-card {
    display: grid;
    gap: 8px;
}

.hint-use-feedback {
    position: absolute;
    right: 10px;
    bottom: 10px;
    min-width: 96px;
    padding: 4px 8px;
    border-radius: 999px;
    color: #06213a;
    background: var(--green);
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    pointer-events: none;
}

.suggested-hint-card.used .hint-use-feedback {
    opacity: 1;
    transform: translateY(0);
}

.hint-use-helper {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 750;
}

.word-option {
    min-height: 92px;
    cursor: pointer;
    text-align: left;
}

.word-option strong {
    display: block;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.hint-form,
.guess-form {
    display: grid;
    gap: 10px;
}

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

#hint-form-zone,
#guess-form-zone,
#join-form-zone,
#suggested-hints-zone,
#submitted-hints-zone,
#guess-feed-zone {
    min-height: 1px;
}

.guess-form {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.feed-list {
    display: grid;
    gap: 8px;
    max-height: 270px;
    overflow: auto;
}

.feed-line {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    color: var(--muted);
}

.feed-line.correct {
    color: var(--green);
    border-color: rgba(99, 230, 138, 0.34);
}

.stack-actions {
    display: grid;
    gap: 10px;
}

.room-error,
.room-join-panel {
    align-content: center;
    min-height: 320px;
}

.loading-orb {
    width: 56px;
    height: 56px;
    margin: 42px auto 14px;
    border: 5px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 20;
    transform: translateX(-50%);
    width: min(100% - 28px, 520px);
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    background: #071426;
    box-shadow: var(--shadow);
}

@keyframes pulse {
    to { box-shadow: 0 0 0 5px rgba(255, 107, 107, 0.18); }
}

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

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

@media (max-width: 900px) {
    .quick-actions,
    .two-col {
        grid-template-columns: 1fr;
    }

    .room-grid {
        display: block;
    }

    .room-top {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .room-code-card {
        justify-content: space-between;
    }

    .connection-state {
        grid-column: 1 / -1;
        text-align: center;
    }

    .room-tabs {
        display: grid;
        position: sticky;
        top: 0;
        z-index: 3;
    }

    .room-panel {
        display: none;
    }

    .room-panel.active {
        display: block;
    }
}

@media (max-width: 640px) {
    .page-shell,
    .site-footer,
    .room-app,
    .center-wrap {
        width: min(100% - 24px, 920px);
    }

    .home-shell {
        padding-top: 2px;
    }

    .home-hero h1 {
        font-size: clamp(2.8rem, 12vw, 3.6rem);
        margin-bottom: 6px;
    }

    .home-hero .helper-line {
        font-size: 0.94rem;
    }

    .concept-line {
        margin-bottom: 4px;
    }

    .card,
    .glass-card {
        border-radius: 16px;
    }

    .play-panel,
    .mini-card,
    .join-card,
    .text-card,
    .page-title-card,
    .side-card,
    .game-card {
        padding: 16px;
    }

    .play-panel {
        padding: 14px;
    }

    .quick-actions {
        gap: 10px;
        margin-top: 10px;
    }

    .mini-card p,
    .mini-card textarea,
    .mini-card .check-row {
        display: none;
    }

    .split,
    .option-grid,
    .hint-grid,
    .final-grid,
    .hint-form,
    .guess-form {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-top: 10px;
    }

    .info-card {
        padding: 10px;
    }

    .info-card p {
        display: none;
    }

    .room-top {
        gap: 6px;
        padding: 7px;
    }

    .room-stat,
    .room-code-card {
        min-height: 40px;
        padding: 5px 7px;
    }

    .role-stat {
        grid-column: span 2;
    }

    .status-banner {
        font-size: 0.88rem;
    }

    .page-title-card h1,
    .join-card h1 {
        font-size: clamp(2rem, 10vw, 2.6rem);
    }

    .leader-row,
    .room-chip,
    .player-chip,
    .score-row {
        grid-template-columns: 1fr;
    }

    .pattern {
        letter-spacing: 0.06em;
        padding: 14px;
        font-size: clamp(1.5rem, 10vw, 2.7rem);
    }

    .phase-panel,
    .phase-head {
        gap: 10px;
    }

    .secret-word {
        padding: 14px;
    }

    .site-footer nav {
        gap: 10px 12px;
    }
}
