:root {
    --bg: #0f1419;
    --panel: #1a2332;
    --accent: #3d9eff;
    --accent-dim: #2a6cb3;
    --text: #e8eef4;
    --muted: #8fa3b8;
    --hotspot: rgba(61, 158, 255, 0.25);
    --hotspot-border: rgba(61, 158, 255, 0.6);
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

body {
    font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    background: radial-gradient(ellipse at top, #1e2a3d 0%, var(--bg) 55%);
    color: var(--text);
    padding: calc(12px + var(--safe-area-top)) 12px calc(12px + var(--safe-area-bottom));
    -webkit-tap-highlight-color: transparent;
}

.game-area {
    max-width: 720px;
    margin: 0 auto;
    background: var(--panel);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-area.fullscreen {
    max-width: none;
    min-height: 100vh;
    border-radius: 0;
    margin: 0;
}

.game-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.game-header h1 {
    font-size: clamp(1.05rem, 4vw, 1.35rem);
    font-weight: 700;
    color: var(--accent);
}

.control-btn {
    font: inherit;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    cursor: pointer;
    min-height: 44px;
    touch-action: manipulation;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.control-btn.primary {
    background: var(--accent);
    border-color: var(--accent-dim);
    color: #fff;
}

.control-btn.primary:hover {
    filter: brightness(1.08);
}

.control-btn.hidden {
    display: none !important;
}

.narration {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--muted);
    margin-bottom: 10px;
    min-height: 2.8em;
}

.inventory-bar {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 12px;
    min-height: 1.5em;
}

.inventory-bar:empty {
    display: none;
}

.viewport-outer {
    width: 100%;
}

.game-canvas {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0e14;
    border: 2px solid rgba(61, 158, 255, 0.35);
    min-height: min(52vh, 420px);
    aspect-ratio: 4 / 3;
    max-height: 70vh;
}

.game-area.fullscreen .game-canvas {
    max-height: none;
    min-height: 60vh;
    aspect-ratio: auto;
}

.canvas-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    max-width: calc(100% - 16px);
}

.canvas-controls .control-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
    min-height: 40px;
}

.scene-root {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #151c28 0%, #0d1118 100%);
}

.scene-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scene-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% 100%, rgba(61, 158, 255, 0.12), transparent 70%);
}

.hotspot {
    position: absolute;
    border: 2px dashed var(--hotspot-border);
    background: var(--hotspot);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 3px #000;
    transition: background 0.15s, transform 0.1s;
    min-width: 56px;
    min-height: 56px;
    text-align: center;
    padding: 6px;
}

.hotspot:active {
    transform: scale(0.98);
}

.hotspot:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.sub-scene {
    position: absolute;
    inset: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    z-index: 5;
}

.sub-scene.desk {
    background: linear-gradient(160deg, #2a2520 0%, #1a1612 100%);
}

.sub-scene.picture {
    background: linear-gradient(160deg, #1a2230 0%, #0f1419 100%);
}

.sub-scene.safe {
    background: linear-gradient(160deg, #1e1a24 0%, #121018 100%);
}

.note-paper {
    background: #f4e8d4;
    color: #2c2416;
    padding: 20px 24px;
    border-radius: 4px;
    max-width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 1rem;
    line-height: 1.6;
    border: 1px solid #c4b89a;
}

.symbols-big {
    font-size: clamp(2.5rem, 12vw, 4rem);
    letter-spacing: 0.2em;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.safe-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.safe-buttons button {
    font-size: 2rem;
    width: 72px;
    height: 72px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    touch-action: manipulation;
}

.safe-buttons button:active {
    transform: scale(0.95);
}

.safe-status {
    color: var(--muted);
    font-size: 0.9rem;
}

.door-locked {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.35;
    pointer-events: none;
}

.hint-text {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 12px;
    line-height: 1.4;
}

.back-btn {
    margin-top: 10px;
    width: 100%;
}

.pause-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.pause-overlay.hidden {
    display: none !important;
}

.pause-content {
    background: var(--panel);
    padding: 28px 24px;
    border-radius: 16px;
    text-align: center;
    max-width: 320px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.pause-content h2 {
    margin-bottom: 10px;
    color: var(--accent);
}

.pause-content p {
    color: var(--muted);
    margin-bottom: 18px;
    font-size: 0.95rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-box {
    background: var(--panel);
    padding: 28px 24px;
    border-radius: 16px;
    text-align: center;
    max-width: 340px;
    border: 1px solid rgba(61, 158, 255, 0.4);
}

.modal-box h2 {
    margin-bottom: 12px;
    color: var(--accent);
}

.modal-box p {
    color: var(--muted);
    margin-bottom: 20px;
}

#comments-container {
    margin-top: 24px;
}
