:root {
    --font-title: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body: 'Crimson Text', Georgia, 'Times New Roman', serif;
}

html {
    text-rendering: optimizeLegibility;
    overscroll-behavior: none;
}

body {
    overscroll-behavior: none;
}

html, body, button, input, textarea, select {
    font-family: var(--font-body);
    -webkit-text-size-adjust: 100%;
}

html.fonts-loading .room-title,
html.fonts-loading .site-title,
html.fonts-loading .hero-title,
html.fonts-loading h1 {
    opacity: 0;
}

.room-title, .site-title, .hero-title, h1 {
    transition: opacity 180ms ease;
}

html.fonts-ready .room-title,
html.fonts-ready .site-title,
html.fonts-ready .hero-title,
html.fonts-ready h1 {
    opacity: 1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-size: 17px;
    line-height: 1.7;
    color: #1a1a1a;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
}

.bg {
    position: fixed;
    inset: 0;
    background-image: url("/static/bg.png");
    background-size: cover;
    background-position: center;
    filter: saturate(0.9) contrast(1.05);
    transform: scale(1.02);
    z-index: -2;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(0,0,0,0.25), rgba(0,0,0,0.72));
    z-index: -1;
}

.shell {
    max-width: 780px;
    margin: 0 auto;
    padding: 48px 24px;
    padding-top: calc(48px + env(safe-area-inset-top));
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hidden {
    display: none !important;
}

.hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    animation: fadeIn 1s ease;
}

.hero-title {
    font-family: var(--font-title);
    font-size: 44px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    text-shadow: 0 2px 24px rgba(0,0,0,0.4);
}

.hero-tagline {
    font-family: var(--font-body);
    font-size: 17px;
    font-style: italic;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.02em;
    margin-bottom: 14px;
}

.hero-buttons {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
}

.hero-enter {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.45);
    color: rgba(255,255,255,0.8);
    font-family: var(--font-body);
    font-size: 15px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 12px 42px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hero-enter:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.75);
    color: #fff;
}

.hero-daily {
    font-size: 13px;
    padding: 10px 30px;
    letter-spacing: 0.08em;
    border-color: rgba(255,255,255,0.28);
    color: rgba(255,255,255,0.55);
}

.hero-daily:hover {
    border-color: rgba(255,255,255,0.55);
    color: rgba(255,255,255,0.88);
}

.game {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 32px 0;
    animation: fadeIn 0.6s ease;
}

.game-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(250,248,244,0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.16), 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
    min-height: 0;
}

.game-header {
    position: relative;
    padding: 20px 30px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.game-title {
    font-family: var(--font-title);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #2a2a2a;
}

.objective-panel {
    padding: 12px 30px 10px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.objective-title {
    font-family: var(--font-title);
    font-size: clamp(0.9rem, 1.6vw, 1.05rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(0,0,0,0.38);
    opacity: 0.75;
}

.objective-text {
    font-family: var(--font-body);
    font-size: clamp(1.15rem, 2.2vw, 1.35rem);
    line-height: 1.45;
    font-weight: 600;
    color: rgba(0,0,0,0.88);
    opacity: 1;
    margin-top: 0.4rem;
    padding: 0.6rem 0.75rem;
    border-left: 3px solid rgba(0,0,0,0.18);
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
}

.objective-progress {
    font-size: 12px;
    color: rgba(0,0,0,0.5);
    letter-spacing: 0.02em;
    margin-top: 6px;
}

.sound-btn {
    position: absolute;
    top: 16px;
    right: 52px;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: rgba(0,0,0,0.3);
    transition: color 0.2s ease;
    line-height: 1;
    padding: 4px;
}

.sound-btn:hover {
    color: rgba(0,0,0,0.6);
}

.close-btn {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 9999;
    background: rgba(250,248,244,0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    color: rgba(0,0,0,0.5);
    transition: color 0.2s ease, background 0.2s ease;
    line-height: 1;
    padding: 0;
}

.close-btn:hover {
    color: rgba(0,0,0,0.8);
}

.game-ended .game-bottom form,
.game-ended .game-bottom .actions {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.game-ended .share-row {
    pointer-events: auto;
}

.game-ended .transcript {
    opacity: 0.95;
}

.typing-caret::after {
    content: "\2588";
    animation: blink 0.8s step-end infinite;
    color: rgba(0,0,0,0.25);
    font-size: 14px;
    margin-left: 1px;
}

@keyframes blink {
    50% { opacity: 0; }
}

.transcript {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    min-height: 0;
    font-family: var(--font-body);
}

.transcript span,
.transcript-inner span {
    font-family: inherit;
}

.transcript-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 28px 40px;
}

.transcript::-webkit-scrollbar {
    width: 4px;
}

.transcript::-webkit-scrollbar-track {
    background: transparent;
}

.transcript::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
}

.turn {
    padding: 18px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    opacity: 0.92;
    transition: opacity 0.3s ease;
}

.turn:last-child {
    border-bottom: none;
    opacity: 1;
}

.turn-cmd {
    font-family: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(0,0,0,0.62);
    margin-bottom: 10px;
}

.turn-cmd:empty {
    display: none;
}

.turn-out {
    padding: 0;
}

.turn-pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 400;
    line-height: 1.85;
    color: rgba(0,0,0,0.88);
    margin-bottom: 14px;
}

.room-title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 28px;
    line-height: 1.2;
    margin: 10px 0 12px;
    letter-spacing: 0.01em;
    color: rgba(0,0,0,0.9);
    transition: opacity 220ms ease, transform 220ms ease;
}

.room-title.is-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.turn-body-wrap {
    position: relative;
    padding-left: 14px;
    margin-top: 2px;
}

.turn-body-wrap::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: rgba(0,0,0,0.08);
}

.turn-body {
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 400;
    line-height: 1.85;
    color: rgba(0,0,0,0.88);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.game-bottom {
    flex-shrink: 0;
    border-top: 1px solid rgba(0,0,0,0.06);
    padding: 0;
    background: rgba(247,246,244,0.5);
    border-radius: 0 0 14px 14px;
}

.game-bottom-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 28px 18px;
}

#input-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

#command {
    flex: 1;
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 16px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    background: #fff;
    color: #1a1a1a;
    outline: none;
    transition: border-color 0.15s;
}

#command:focus {
    border-color: rgba(0,0,0,0.25);
}

#command::placeholder {
    color: #aaa;
    font-style: italic;
}

#command:disabled {
    opacity: 0.4;
}

#send-btn {
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    background: #2c2c2c;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.15s;
}

#send-btn:hover {
    opacity: 0.85;
}

#send-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.actions {
    display: flex;
    gap: 18px;
    padding-top: 10px;
}

.actions button {
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 13px;
    color: rgba(0,0,0,0.4);
    cursor: pointer;
    padding: 0;
    letter-spacing: 0.01em;
    transition: color 0.15s;
}

.actions button:hover {
    color: rgba(0,0,0,0.7);
}

.share-row {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.share-btn {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.15);
    font-family: var(--font-body);
    font-size: 13px;
    color: #555;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
}

.share-btn:hover {
    border-color: rgba(0,0,0,0.35);
    color: #222;
}

.share-msg {
    font-family: var(--font-body);
    font-size: 13px;
    font-style: italic;
    color: rgba(0,0,0,0.45);
}

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

@media (max-width: 600px) {
    .shell {
        padding: 24px 14px;
    }

    .hero-title {
        font-size: 32px;
    }

    .hero-tagline {
        font-size: 15px;
    }

    .game {
        padding: 16px 0;
    }

    .game-panel {
        border-radius: 12px;
    }

    .game-header {
        padding: 16px 20px 14px;
    }

    .objective-panel {
        padding: 10px 20px 8px;
    }

    .transcript-inner {
        padding: 18px 18px 32px;
    }

    .game-bottom-inner {
        padding: 14px 18px 16px;
    }

    .game-bottom {
        border-radius: 0 0 12px 12px;
    }

    #command {
        font-size: 16px;
    }

    .turn-pre,
    .turn-body {
        font-size: 17px;
        letter-spacing: normal;
        -webkit-text-size-adjust: 100%;
        text-rendering: optimizeLegibility;
    }

    .room-title {
        font-size: 22px;
    }
}

@media (max-width: 520px) {
    .transcript-inner {
        font-size: 18px;
        line-height: 1.55;
    }

    input[type="text"], textarea {
        font-size: 16px;
    }
}

.help-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 50%;
    background: transparent;
    font-family: var(--font-title);
    font-size: 15px;
    font-weight: 700;
    color: rgba(0,0,0,0.4);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.help-btn:hover {
    color: rgba(0,0,0,0.7);
    border-color: rgba(0,0,0,0.3);
}

.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
}
.help-overlay.hidden {
    display: none;
}

.help-modal {
    background: rgba(250,248,244,0.97);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    max-width: 680px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.help-modal-title {
    font-family: var(--font-title);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #1a1a1a;
}

.help-close-btn {
    background: none;
    border: none;
    font-size: 26px;
    color: rgba(0,0,0,0.35);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.help-close-btn:hover {
    color: rgba(0,0,0,0.7);
}

.help-modal-body {
    padding: 8px 28px 24px;
}

.help-section {
    margin-top: 18px;
}

.help-section-title {
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(0,0,0,0.4);
    margin-bottom: 8px;
}

.help-item {
    display: flex;
    gap: 16px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    align-items: baseline;
}
.help-item:last-child {
    border-bottom: none;
}

.help-syntax {
    flex-shrink: 0;
    min-width: 200px;
    font-family: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, monospace;
    font-size: 13px;
    color: #1a1a1a;
}

.help-desc {
    font-family: var(--font-body);
    font-size: 16px;
    color: rgba(0,0,0,0.55);
    line-height: 1.5;
}

@media (max-width: 600px) {
    .help-item {
        flex-direction: column;
        gap: 2px;
    }
    .help-syntax {
        min-width: auto;
    }
}
