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

body {
    font-family: 'Noto Serif KR', serif;
    background: #0a0a0a;
    color: #e5e7eb;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

.container {
    max-width: 1024px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 메인 화면 */
#mainScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    background: linear-gradient(180deg, #0a0a0a 0%, #1a1a1a 100%);
    position: relative;
}

.genre-label {
    font-size: 0.9rem;
    letter-spacing: 0.2em;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.main-title {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    text-align: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.subtitle {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 3rem;
    text-align: center;
}

.main-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

.main-button {
    background: #1a1a1a;
    color: white;
    border: 1px solid #333;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Noto Serif KR', serif;
}

.main-button:hover {
    background: #2a2a2a;
    border-color: #666;
    transform: translateY(-2px);
}

.continue-button {
    opacity: 0.8;
}

.main-footer-left {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.main-footer-left:hover {
    color: rgba(255, 255, 255, 0.8);
}

.main-footer-right {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.main-footer-right:hover {
    color: rgba(255, 255, 255, 0.8);
}

.shin-calligraphy {
    font-family: 'Zhi Mang Xing', cursive !important;
    font-size: 1.15em;
    font-weight: 400;
    font-style: normal;
    display: inline-block;
    margin: 0 0.1em;
    line-height: 1;
    vertical-align: baseline;
    letter-spacing: 0;
    color: inherit;
    position: relative;
    top: 0.05em;
}

/* 게임 화면 */
#gameScreen {
    display: none;
    flex-direction: column;
    height: 100%;
    background: #0a0a0a;
}

/* 헤더 */
.header {
    background: rgba(0,0,0,0.9);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #222;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: #fff;
    opacity: 0.9;
}

.header-info {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.scenario-indicator {
    font-size: 0.875rem;
    color: #888;
    display: none;
}

.turn-display {
    text-align: right;
}

.turn-counter {
    color: #fff;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.turn-bar {
    width: 120px;
    height: 3px;
    background: #222;
    border-radius: 2px;
    overflow: hidden;
}

.turn-progress {
    height: 100%;
    background: #666;
    border-radius: 2px;
    transition: all 0.5s;
    width: 0%;
}

.turn-progress.warning {
    background: #f59e0b;
}

.turn-progress.danger {
    background: #ef4444;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.new-game-btn {
    background: transparent;
    color: #888;
    border: 1px solid #333;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    font-family: 'Noto Serif KR', serif;
}

.new-game-btn:hover {
    color: #fff;
    border-color: #666;
}

/* 스토리 디스플레이 */
.story-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
    padding-bottom: 12rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    min-height: 0;
}

.story-part {
    margin-bottom: 1.5rem;
    animation: fadeIn 0.5s ease-in;
    line-height: 1.8;
}

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

.story-part.narrator {
    color: #e5e7eb;
    font-size: 1.05rem;
}

.story-part.player {
    color: #9ca3af;
    font-style: italic;
    padding-left: 2rem;
    border-left: 2px solid #333;
    margin: 1.5rem 0;
}

/* 특별 효과 */
.story-part.narrator strong {
    color: #fff;
    font-weight: 600;
}

.story-part.narrator em {
    opacity: 0.8;
    font-style: italic;
}

.clue-text {
    color: #f59e0b;
    font-weight: 500;
}

.danger-text {
    color: #ef4444;
    font-weight: 500;
}

/* 액션 입력 */
.action-input-container {
    padding: 1.5rem;
    background: rgba(0,0,0,0.98);
    border-top: 1px solid #222;
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    max-width: 1024px;
    margin: 0 auto;
}

.action-form {
    display: flex;
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.action-input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #333;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: 'Noto Serif KR', serif;
}

.action-input:focus {
    outline: none;
    border-color: #666;
    background: #222;
}

.action-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-submit {
    background: #2a2a2a;
    color: white;
    border: 1px solid #444;
    padding: 0.75rem 2rem;
    border-radius: 0.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Noto Serif KR', serif;
}

.action-submit:hover:not(:disabled) {
    background: #333;
    border-color: #666;
}

.action-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 로딩 */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #333;
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 로딩 화면 */
.loading-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    background: #0a0a0a;
}

.loading-text {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    color: #888;
}

/* 알림 */
.notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    border: 1px solid #333;
    animation: slideUp 0.3s ease-out;
    z-index: 1000;
    font-size: 0.95rem;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.notification.warning {
    border-color: #f59e0b;
    color: #f59e0b;
}

.notification.danger {
    border-color: #ef4444;
    color: #ef4444;
}

.notification.success {
    border-color: #10b981;
    color: #10b981;
}

/* 화면 효과 */
.screen-shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.flash-red {
    animation: flashRed 0.3s;
}

@keyframes flashRed {
    0%, 100% { background: transparent; }
    50% { background: rgba(239, 68, 68, 0.1); }
}

/* 입력창 상단 바 (BGM 버튼 등) */
.action-top-bar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 8px;
}

/* BGM 토글 버튼 */
.bgm-toggle-btn {
    background: transparent;
    border: 1px solid #333;
    color: #9ca3af;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.7rem;
    font-family: 'Noto Serif KR', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.05em;
}

.bgm-toggle-btn:hover {
    border-color: #666;
    color: #e5e7eb;
}

.bgm-toggle-btn.muted {
    color: #555;
    border-color: #222;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .main-title {
        font-size: 2.5rem;
    }

    .genre-label {
        font-size: 0.75rem;
    }

    .main-footer-left,
    .main-footer-right {
        font-size: 0.7rem;
        bottom: 1rem;
    }

    .main-footer-left {
        left: 1rem;
    }

    .main-footer-right {
        right: 1rem;
    }

    .story-container {
        padding: 1.5rem 1rem;
        padding-bottom: 15rem;
    }

    .header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .scenario-indicator {
        display: none !important;
    }

    .action-input-container {
        padding: 1rem;
        background: rgba(0,0,0,1);
    }

    .bgm-toggle-btn {
        padding: 4px 10px;
        font-size: 0.65rem;
    }
}

/* 사용량 배지 (印 인주도장) — 헌법 §12-A 표준. 정본: 2.계약서검토. 25회 대화형. */
/* ⚠️ 폐병원 전용: 게임 헤더(.header — turn-counter·new-game-btn 있음)와 충돌 회피 위해 top:88px로 헤더 아래 배치 */
.usage-badge { position: fixed; top: 88px; right: 24px; z-index: 9999; display: flex; gap: 14px; align-items: center; padding: 14px 18px 14px 14px; background: var(--card, #FBF9F4); border: 1px solid var(--accent, #8B2520); border-radius: var(--radius-xs, 2px); box-shadow: var(--shadow-card, 0 1px 0 rgba(20,17,13,0.04), 0 8px 24px -12px rgba(20,17,13,0.10)); font-family: var(--font-serif, 'Noto Serif KR', 'MaruBuri', serif); color: var(--ink-soft, #3A352D); transition: var(--transition, all 0.25s cubic-bezier(0.2, 0.7, 0.2, 1)); background-image: linear-gradient(180deg, transparent 0%, rgba(20,17,13,0.015) 100%); }
.usage-badge[hidden] { display: none !important; }
.usage-badge__stamp { flex: 0 0 auto; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; background: var(--accent, #8B2520); color: var(--paper, #F4F1EA); border-radius: var(--radius-xs, 2px); transform: rotate(-3deg); box-shadow: inset 0 0 6px rgba(0,0,0,0.22), inset 1px 1px 0 rgba(255,255,255,0.08), 0 2px 4px rgba(139,37,32,0.28); position: relative; }
.usage-badge__stamp::after { content: ''; position: absolute; inset: -2px; border-radius: var(--radius-xs, 2px); background: var(--accent, #8B2520); opacity: 0.10; z-index: -1; filter: blur(2px); }
.usage-badge__stamp-char { font-family: var(--font-serif, 'Noto Serif KR', serif); font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: -1px; text-shadow: 0 1px 1px rgba(0,0,0,0.25); }
.usage-badge__content { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.usage-badge__label { font-size: 12px; color: var(--ink-mute, #6B6358); letter-spacing: 0.08em; font-weight: 500; margin-bottom: 1px; }
.usage-badge__dots { display: flex; gap: 4px; margin: 2px 0 3px; flex-wrap: wrap; max-width: 200px; }
.usage-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent, #8B2520); transition: background 0.4s ease, transform 0.3s ease; }
.usage-badge__dot--used { background: var(--rule-soft, #DDD5C2); }
.usage-badge__remaining { font-size: 13px; color: var(--ink-soft, #3A352D); line-height: 1.2; }
.usage-badge__remaining strong { font-size: 20px; font-weight: 700; color: var(--accent, #8B2520); margin-right: 3px; font-variant-numeric: tabular-nums; }
.usage-badge__reset { font-size: 10.5px; color: var(--ink-light, #9A8F80); letter-spacing: 0.04em; margin-top: 1px; }
.usage-badge--critical .usage-badge__stamp { animation: usage-stamp-pulse 2.2s ease-in-out infinite; }
.usage-badge--critical .usage-badge__dot:not(.usage-badge__dot--used) { background: var(--accent-deep, #6B1C18); }
.usage-badge--critical .usage-badge__remaining strong { color: var(--accent-deep, #6B1C18); }
@keyframes usage-stamp-pulse { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(-3deg) scale(1.06); } }
.usage-badge--exhausted .usage-badge__stamp { opacity: 0.5; animation: none; }
.usage-badge--exhausted .usage-badge__dot { background: var(--rule-soft, #DDD5C2); }
.usage-badge--exhausted .usage-badge__remaining strong { color: var(--ink-light, #9A8F80); }
.usage-badge--warn { border-color: var(--warning, #946A1F); }
.usage-badge--warn .usage-badge__stamp { background: var(--warning, #946A1F); }
.usage-badge--warn .usage-badge__stamp::after { background: var(--warning, #946A1F); }
@media (max-width: 640px) { .usage-badge { top: 76px; right: 12px; padding: 10px 14px 10px 10px; gap: 10px; } .usage-badge__stamp { width: 38px; height: 38px; } .usage-badge__stamp-char { font-size: 19px; } .usage-badge__content { min-width: 120px; } .usage-badge__dot { width: 6px; height: 6px; } .usage-badge__remaining strong { font-size: 17px; } }
@media print { .usage-badge { display: none !important; } }
