:root {
    color-scheme: dark;
    --bg-color: #020617;
    --bg-gradient-top: #020617;
    --bg-gradient-bottom: #020617;
    --accent-color: #22d3ee;
    --accent-strong: #eab308;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --panel-bg: rgba(0, 0, 0, 0.6);
    --button-bg: #0f172a;
    --button-border: #22d3ee;
    --button-text: #e5e7eb;
    --error-color: #f97373;
    --transition-fast: 0.2s ease-out;
}

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

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        sans-serif;
    background: radial-gradient(circle at top,
            rgba(34, 211, 238, 0.18),
            transparent 55%),
        radial-gradient(circle at bottom,
            rgba(168, 85, 247, 0.18),
            transparent 60%),
        linear-gradient(to bottom, var(--bg-gradient-top), var(--bg-gradient-bottom));
    color: var(--text-main);
}

body {
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: 1024px;
    height: 100vh;
    max-height: 1366px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    background: linear-gradient(to bottom,
            rgba(15, 23, 42, 0.92),
            rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow:
        0 0 40px rgba(15, 23, 42, 0.9),
        0 0 80px rgba(8, 47, 73, 0.9);
    overflow: hidden;
}

.screen--hidden {
    display: none;
}

.screen-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.9);
    background: radial-gradient(circle at top left,
            rgba(56, 189, 248, 0.2),
            transparent 55%),
        rgba(15, 23, 42, 0.95);
}

.screen-header__title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-color);
}

.screen-header__subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.screen-body {
    flex: 1;
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* カメラエリア */

.camera-area {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-area__inner {
    position: relative;
    width: min(80vw, 640px);
    aspect-ratio: 1 / 1;
    border-radius: 36px;
    overflow: hidden;
    background: radial-gradient(circle at center,
            rgba(15, 23, 42, 1),
            rgba(10, 13, 24, 1));
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.3),
        0 0 40px rgba(15, 23, 42, 0.9);
}

.camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* 顔枠 */

.face-frame {
    position: absolute;
    inset: 10%;
    border-radius: 28px;
    border: 2px solid rgba(34, 211, 238, 0.9);
    box-shadow:
        0 0 24px rgba(34, 211, 238, 0.7),
        inset 0 0 12px rgba(15, 23, 42, 0.8);
    pointer-events: none;
}

.face-frame::before,
.face-frame::after {
    content: "";
    position: absolute;
    border-radius: 24px;
    border: 1px dashed rgba(56, 189, 248, 0.6);
    inset: 14%;
}

/* ボタン */

.scan-button-area {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.primary-button {
    min-width: 260px;
    padding: 16px 32px;
    border-radius: 999px;
    border: 1px solid var(--button-border);
    background:
        radial-gradient(circle at top, rgba(34, 211, 238, 0.3), transparent 55%),
        var(--button-bg);
    color: var(--button-text);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
    transition:
        background var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast),
        border-color var(--transition-fast),
        opacity 0.15s ease-out;
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.9),
        0 0 18px rgba(34, 211, 238, 0.4);
}

.primary-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.9),
        0 0 26px rgba(34, 211, 238, 0.7);
}

.primary-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.9),
        0 0 12px rgba(34, 211, 238, 0.4);
}

.primary-button:disabled {
    opacity: 0.55;
    cursor: default;
}

/* 結果画面 */

.result-face-area {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.result-face-frame {
    position: relative;
    width: min(70vw, 520px);
    aspect-ratio: 1 / 1;
    border-radius: 32px;
    overflow: hidden;
    background: radial-gradient(circle at center,
            rgba(15, 23, 42, 1),
            rgba(10, 10, 19, 1));
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.4),
        0 0 40px rgba(15, 23, 42, 0.9);
}

.result-face-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.rarity-badge {
    position: absolute;
    left: 16px;
    bottom: 16px;
    padding: 8px 16px;
    border-radius: 999px;
    background: radial-gradient(circle at top left,
            rgba(250, 204, 21, 0.25),
            rgba(23, 23, 23, 0.95));
    border: 1px solid rgba(234, 179, 8, 0.9);
    color: var(--accent-strong);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 13px;
    box-shadow:
        0 0 20px rgba(234, 179, 8, 0.7),
        0 0 0 1px rgba(15, 23, 42, 1);
}

/* 結果メッセージパネル */

.result-panel {
    width: 100%;
    margin-top: 8px;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--panel-bg);
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow:
        0 0 20px rgba(15, 23, 42, 0.9),
        0 0 0 1px rgba(15, 23, 42, 1);
}

.result-headline {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    color: #f9fafb;
}

.result-body {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
}

/* 共通 */

.canvas-hidden {
    display: none;
}

/* 横向きレイアウト調整 */

@media (orientation: landscape) and (min-width: 900px) {
    .screen-body {
        flex-direction: row;
        align-items: stretch;
        gap: 24px;
    }

    #screen-wait .screen-body {
        align-items: center;
    }

    .camera-area {
        flex: 1.1;
    }

    .scan-button-area {
        flex: 0 0 220px;
        align-items: center;
    }

    .scan-button-area {
        align-self: center;
    }

    #screen-result .screen-body {
        align-items: center;
    }

    .result-face-area {
        flex: 1.1;
    }

    .result-panel {
        flex: 0 0 260px;
        align-self: center;
    }
}