:root {
    --primary-color: #ff5a5f;
    --secondary-color: #008489;
    --accent-color: #ffeb3b;
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.3);
    --text-white: #ffffff;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Inter', 'Segoe UI', Roboto, -apple-system, sans-serif;
}

#container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

#webcam, #output_canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: rotateY(180deg);
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

/* --- スタート画面 --- */
#start-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.7)), url('https://images.unsplash.com/photo-1518780664697-55e3ad937233?auto=format&fit=crop&q=80&w=1000') center/cover;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    padding: 40px;
    text-align: center;
    color: white;
    width: 90%;
    max-width: 800px;
}

h1 { font-size: clamp(2rem, 8vh, 4rem); margin: 0; font-weight: 800; color: white; }
.subtitle { font-size: 1.2rem; margin-bottom: 30px; opacity: 0.9; }

.language-selector { display: flex; justify-content: center; gap: 10px; margin-bottom: 30px; }
.lang-btn {
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid white;
    color: white;
    border-radius: 100px;
    cursor: pointer;
}
.lang-btn.active { background: white; color: black; }

.instructions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}
.inst-item { background: rgba(255,255,255,0.1); padding: 15px; border-radius: 20px; }
.inst-item .icon { font-size: 30px; display: block; }

#start-button {
    padding: 20px 60px;
    font-size: 1.8rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 100px;
    font-weight: 700;
    cursor: pointer;
}

/* --- オーバーレイ共通 (プレビュー・結果) --- */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(20px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.preview-container, .result-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    width: 90%;
}

#preview-image, #captured-image {
    max-width: 60vw;
    max-height: 60vh;
    border-radius: 20px;
    border: 2px solid white;
}

/* --- 特殊演出 --- */
#status-message {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 2rem;
    background: rgba(0,0,0,0.6);
    padding: 15px 40px;
    border-radius: 100px;
    z-index: 10;
}

#countdown {
    position: absolute;
    font-size: 30vh;
    color: white;
    font-weight: 800;
    z-index: 10;
}

#flash {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
}
#flash.active { opacity: 1; }

.qr-card { background: white; padding: 20px; border-radius: 20px; text-align: center; color: black; }

.btn-group { display: flex; gap: 20px; margin-top: 30px; }
.btn-main { padding: 15px 40px; font-size: 1.2rem; border-radius: 100px; font-weight: 700; cursor: pointer; border: none; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-secondary { background: #444; color: white; }

/* 掲示許可 */
.permission-section { margin-bottom: 20px; color: white; }

/* 共通：非表示設定 (最優先) */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 横画面最適化 */
@media (orientation: landscape) {
    .instructions { grid-template-columns: repeat(4, 1fr); }
    .glass-panel { padding: 20px; }
}
