@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&family=Zen+Maru+Gothic:wght@500;700;900&display=swap');

:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg-dark: #0F172A;
    --card-bg: rgba(30, 41, 59, 0.85);
    --card-border: rgba(255, 255, 255, 0.12);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --namako-green: #7CB518;
    --namako-cream: #FCFAF2;
}

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

body {
    font-family: 'Zen Maru Gothic', 'Outfit', sans-serif;
    background: radial-gradient(circle at 50% 20%, #1E293B, #0F172A);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 6px;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: min(98vw, calc((98vh - 70px) * (4 / 3)));
    background: #111827;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--card-border);
    overflow: hidden;
}

/* ヘッダー */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-badge {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.title-text {
    font-size: 20px;
    font-weight: 900;
    background: linear-gradient(135deg, #F8FAFC, #94A3B8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sensitivity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
}

.sensitivity-control input[type="range"] {
    width: 80px;
    accent-color: #38BDF8;
    cursor: pointer;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.btn-secondary.active {
    background: linear-gradient(135deg, #10B981, #059669);
    border-color: #34D399;
    color: #FFF;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

.cam-status-tag {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #34D399;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    padding: 2px;
}

/* ゲームエリア */
.game-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    cursor: default;
    touch-action: none;
}

canvas#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: auto;
    touch-action: none;
}

/* 画面オーバーレイ */
.screen-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    z-index: 10;
    padding: 24px;
    transition: opacity 0.3s ease;
}

.screen-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* スタート画面 */
.hero-content {
    text-align: center;
    max-width: 680px;
    animation: fadeIn 0.6s ease-out;
}

.hero-namako-icon {
    font-size: 64px;
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}

.hero-title {
    font-size: 38px;
    font-weight: 900;
    color: #FCD34D;
    text-shadow: 0 4px 15px rgba(252, 211, 77, 0.3);
    margin-bottom: 6px;
}

.hero-subtitle {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* モード・設定カード */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.option-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 16px;
    border-radius: 16px;
}

.option-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.button-toggle-group {
    display: flex;
    gap: 8px;
}

.btn-toggle {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 10px 8px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toggle.active {
    background: linear-gradient(135deg, #4F46E5, #6366F1);
    color: #FFF;
    border-color: #818CF8;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.option-desc {
    font-size: 12px;
    color: #A5B4FC;
    margin-top: 8px;
    line-height: 1.4;
}

/* カメラ設定ボックス */
.camera-box {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.camera-preview-wrapper {
    position: relative;
    width: 120px;
    height: 90px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #6366F1;
}

#camPreview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.status-badge {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    padding: 2px 6px;
    border-radius: 6px;
}

.status-ok {
    color: #34D399;
    background: rgba(52, 211, 153, 0.15);
}

.status-warn {
    color: #FBBF24;
    background: rgba(251, 191, 36, 0.15);
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.slider-group input[type="range"] {
    flex: 1;
    accent-color: #6366F1;
}

/* スタート大ボタン */
.btn-main-start {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #FFF;
    border: none;
    font-size: 22px;
    font-weight: 900;
    padding: 16px 48px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.5);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-main-start:hover {
    transform: scale(1.06) translateY(-2px);
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.6);
}

/* HUD (プレイ中情報) */
.hud-overlay {
    position: absolute;
    top: 16px;
    left: 24px;
    right: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 5;
}

.hud-panel {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    padding: 10px 18px;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.hud-time-container {
    min-width: 220px;
}

.hud-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
}

.hud-val {
    font-size: 28px;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
    color: #FFF;
}

.time-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.time-bar-fill {
    height: 100%;
    width: 100%;
    background: #10B981;
    transition: width 0.1s linear, background-color 0.3s ease;
}

/* ペナルティ警告バッジ */
.hud-penalty-badge {
    background: #EF4444;
    color: #FFF;
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 900;
    font-size: 14px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    pointer-events: auto;
}

.hud-penalty-badge.hidden {
    display: none;
}

.blink {
    animation: blinkAnim 0.35s infinite alternate;
}

@keyframes blinkAnim {
    from { transform: scale(1.0); }
    to { transform: scale(1.08); }
}

/* コース外フラッシュ画面 */
.penalty-flash {
    position: absolute;
    inset: 0;
    border: 8px solid transparent;
    pointer-events: none;
    transition: border-color 0.1s ease;
    z-index: 4;
}

.penalty-flash.active {
    border-color: rgba(239, 68, 68, 0.7);
    background: radial-gradient(circle, transparent 60%, rgba(239, 68, 68, 0.25) 100%);
    animation: screenVibrate 0.1s infinite;
}

@keyframes screenVibrate {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -2px); }
    100% { transform: translate(2px, 0px); }
}

/* カウントダウン演出 */
.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 8;
}

.countdown-text {
    font-size: 96px;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
    color: #FCD34D;
    text-shadow: 0 0 30px rgba(252, 211, 77, 0.8);
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    0% { transform: scale(0.2); opacity: 0; }
    100% { transform: scale(1.0); opacity: 1; }
}

/* プレイ中ミニカメラ小窓 */
.in-game-cam {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 110px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    z-index: 6;
}

.in-game-cam.hidden {
    display: none;
}

/* リザルト画面 */
.result-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 36px 48px;
    border-radius: 24px;
    text-align: center;
    max-width: 520px;
    animation: popIn 0.4s ease-out;
}

.result-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 12px;
}

.result-badge.clear {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
    border: 1px solid #10B981;
}

.result-badge.fail {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
    border: 1px solid #EF4444;
}

.result-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 12px;
}

.result-time {
    font-size: 18px;
    color: #FFF;
    margin-bottom: 12px;
}

.result-comment {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.result-namako-mood {
    font-size: 16px;
    font-weight: 700;
    color: #FBBF24;
    margin-bottom: 24px;
}

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

/* トースト通知 */
.toast-msg {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid #818CF8;
    color: #FFF;
    padding: 8px 20px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 20;
    animation: fadeIn 0.3s ease;
}

.toast-msg.hidden {
    display: none;
}

/* モーダル */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 24px;
}

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

.modal-content {
    background: #1E293B;
    border: 1px solid var(--card-border);
    padding: 28px;
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 16px;
    color: #FCD34D;
}

.modal-body p {
    font-size: 14px;
    line-height: 1.7;
    color: #CBD5E1;
    margin-bottom: 12px;
}

.modal-body ul {
    margin-left: 20px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* アニメーション */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

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

/* ==========================================================================
   全画面（フルスクリーン）モード対応
   ========================================================================== */
:fullscreen .game-header,
:-webkit-full-screen .game-header,
.game-container.fullscreen-mode .game-header {
    display: flex !important;
    padding: 10px 18px !important;
    background: rgba(15, 23, 42, 0.9) !important;
    width: 100% !important;
    flex-shrink: 0 !important;
}

:fullscreen .game-container,
:-webkit-full-screen .game-container,
.game-container.fullscreen-mode {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    background: #080C14 !important;
    overflow: hidden !important;
}

:fullscreen .game-viewport,
:-webkit-full-screen .game-viewport,
.game-container.fullscreen-mode .game-viewport {
    flex: 1 !important;
    width: 100% !important;
    height: auto !important;
    max-height: calc(100vh - 58px) !important;
    aspect-ratio: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #000000 !important;
}

:fullscreen canvas#gameCanvas,
:-webkit-full-screen canvas#gameCanvas,
.game-container.fullscreen-mode canvas#gameCanvas {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: 4 / 3 !important;
    object-fit: contain !important;
    margin: auto !important;
}

/* フローティング全画面解除ボタン */
.btn-floating-exit-fs {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 50;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #F8FAFC;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    opacity: 0.65;
}

.btn-floating-exit-fs:hover,
.btn-floating-exit-fs:active {
    opacity: 1;
    background: rgba(239, 68, 68, 0.85);
    border-color: #EF4444;
    transform: scale(1.05);
}

.btn-floating-exit-fs.hidden {
    display: none !important;
}

#btnFullscreen.active {
    background: linear-gradient(135deg, #38BDF8, #0284C7);
    border-color: #38BDF8;
    color: #FFF;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
}

/* ============================================================
   タイトル画面（アップロード画像スタート画面 ＆ リアル押し込みボタン）
   ============================================================ */
.title-screen-overlay {
    background: #000000 !important;
    padding: 0 !important;
    backdrop-filter: none !important;
    overflow: hidden;
    z-index: 100 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.title-screen-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    margin: auto;
}

/* 背景画像（iPadの4:3比率に合わせて画面いっぱいにガッツリ鮮明表示） */
.title-bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* 中央の巨大丸型再生スタートボタン（リッチな立体木製▶ボタン） */
.btn-title-play {
    position: absolute;
    left: 50.8%;
    top: 69.5%;
    transform: translate(-50%, -50%);
    width: 154px;
    height: 154px;
    border-radius: 50%;
    background: radial-gradient(circle at 45% 38%, #FEF08A 0%, #FACC15 42%, #CA8A04 78%, #78350F 100%);
    border: 5px solid #854D0E;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6), inset 0 3px 6px rgba(255, 255, 255, 0.75), inset 0 -5px 10px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline: none;
    z-index: 10;
}

.play-triangle-icon {
    font-size: 64px;
    color: #FFFBEB;
    text-shadow: 0 4px 8px rgba(120, 53, 15, 0.9), 0 1px 3px rgba(0, 0, 0, 0.8);
    margin-left: 10px;
    transition: transform 0.1s ease;
}

/* ホバー時（ふわっと浮き上がり＆輝き） */
.btn-title-play:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 36px rgba(250, 204, 21, 0.85), inset 0 4px 8px rgba(255, 255, 255, 0.9);
    filter: brightness(1.08);
}

.btn-title-play:hover .play-triangle-icon {
    transform: scale(1.08);
}

/* ★ 押した瞬間の抜群の沈み込み演出（リアルに深く奥へカチッと押し込まれる感触） */
.btn-title-play:active {
    transform: translate(-50%, calc(-50% + 7px)) scale(0.93) !important;
    box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.9), 0 2px 5px rgba(0, 0, 0, 0.5) !important;
    background: radial-gradient(circle at 50% 50%, #CA8A04 0%, #A16207 60%, #542B08 100%) !important;
    filter: brightness(0.9) !important;
}

.btn-title-play:active .play-triangle-icon {
    transform: scale(0.9) translateY(2px);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
}

/* 難易度ボタン共通（リッチな立体カプセルボタン：両方クッキリ鮮明表示） */
.btn-title-diff {
    position: absolute;
    top: 87.8%;
    transform: translate(-50%, -50%);
    width: 162px;
    height: 60px;
    border-radius: 30px;
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: 20px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1.0;
    filter: none;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    z-index: 10;
}

/* チェックマークバッジ（選択中のみピカッと表示） */
.diff-check-mark {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #10B981;
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 900;
    margin-right: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* かんたんボタン（左側・ゴールド調） */
.btn-diff-easy {
    left: 41.8%;
    background: linear-gradient(180deg, #FEF08A 0%, #FACC15 50%, #CA8A04 100%);
    border: 4px solid #78350F;
    color: #451A03;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

/* ふつうボタン（右側・ブルー調） */
.btn-diff-normal {
    left: 59.8%;
    background: linear-gradient(180deg, #BFDBFE 0%, #60A5FA 50%, #2563EB 100%);
    border: 4px solid #1E3A8A;
    color: #172554;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

/* ★ 選択されている状態（activeモード：チェックマーク点灯＆輝く強調リング） */
.btn-title-diff.active {
    transform: translate(-50%, -50%) scale(1.06) !important;
    z-index: 20 !important;
}

.btn-title-diff.active .diff-check-mark {
    display: inline-flex !important;
}

.btn-diff-easy.active {
    border-color: #FEF08A !important;
    box-shadow: 0 0 0 4px #FACC15, 0 10px 26px rgba(250, 204, 21, 0.85), inset 0 3px 6px rgba(255, 255, 255, 0.9) !important;
}

.btn-diff-normal.active {
    border-color: #BFDBFE !important;
    box-shadow: 0 0 0 4px #38BDF8, 0 10px 26px rgba(56, 189, 248, 0.85), inset 0 3px 6px rgba(255, 255, 255, 0.9) !important;
}

/* ホバー */
.btn-title-diff:hover {
    transform: translate(-50%, -50%) scale(1.04);
    filter: brightness(1.1);
}

/* ★ 難易度ボタンの押した瞬間（沈み込み押し込み演出） */
.btn-title-diff:active {
    transform: translate(-50%, calc(-50% + 5px)) scale(0.95) !important;
    box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    filter: brightness(0.9) !important;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.08); }
    100% { transform: scale(1.0); opacity: 1; }
}

/* ============================================================
   リザルト画面（ゴールクリア＆タイムアップ アップロード画像全画面化）
   ============================================================ */
#resultScreen {
    background: #000000 !important;
    padding: 0 !important;
    backdrop-filter: none !important;
}

.clear-result-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 100;
    animation: fadeIn 0.35s ease-out;
}

.clear-result-container.hidden {
    display: none !important;
}

.clear-result-inner {
    position: relative;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: auto;
}

.clear-bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* クリアタイム表示バッジ（星の下、リプレイボタンの上の余白に配置） */
.clear-time-badge {
    position: absolute;
    left: 50%;
    bottom: 19.2%;
    transform: translate(-50%, 0);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 6px 20px;
    background: linear-gradient(180deg, #FFFBEB 0%, #FEF3C7 50%, #FDE68A 100%);
    border: 3.5px solid #D97706;
    border-radius: 999px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.95);
    font-family: 'Zen Maru Gothic', sans-serif;
    color: #78350F;
    font-weight: 900;
    z-index: 10;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    animation: clearTimePopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.clear-time-badge.hidden {
    display: none !important;
}

.clear-time-icon {
    font-size: 22px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.clear-time-label {
    font-size: 15px;
    color: #92400E;
    letter-spacing: 0.05em;
    font-weight: 900;
}

.clear-time-num {
    font-size: 28px;
    color: #DC2626;
    font-weight: 900;
    font-family: 'Outfit', 'Zen Maru Gothic', sans-serif;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
    margin-left: 2px;
}

.clear-time-unit {
    font-size: 16px;
    color: #B45309;
    font-weight: 900;
}

@keyframes clearTimePopIn {
    0% {
        transform: translate(-50%, 12px) scale(0.75);
        opacity: 0;
    }
    70% {
        transform: translate(-50%, -3px) scale(1.06);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, 0) scale(1);
        opacity: 1;
    }
}

/* リプレイボタン（画像内下部の🔄リプレイボタンにジャストフィット） */
.btn-clear-replay {
    position: absolute;
    left: 50.1%;
    bottom: 8.8%;
    transform: translate(-50%, 0);
    width: 26.5%;
    height: 8.8%;
    border-radius: 999px;
    background: linear-gradient(180deg, #BAE6FD 0%, #38BDF8 50%, #0284C7 100%);
    border: 3.5px solid #0369A1;
    color: #FFFFFF;
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: 20px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.9), 0 0 20px rgba(56, 189, 248, 0.7);
    text-shadow: 0 2px 4px rgba(3, 105, 161, 0.8);
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, filter 0.15s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    z-index: 10;
}

.btn-clear-replay:hover {
    transform: translate(-50%, 0) scale(1.05);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.7), inset 0 3px 6px rgba(255, 255, 255, 0.95), 0 0 28px rgba(56, 189, 248, 0.9);
    filter: brightness(1.1);
}

/* ★ リプレイボタンの押した瞬間（沈み込み押し込み演出） */
.btn-clear-replay:active {
    transform: translate(-50%, 5px) scale(0.93) !important;
    box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.9), 0 2px 4px rgba(0, 0, 0, 0.4) !important;
    background: linear-gradient(180deg, #0284C7 0%, #0369A1 100%) !important;
    filter: brightness(0.9) !important;
}

/* ==========================================================================
   視線トラッキング / カメラUIスタイル
   ========================================================================== */

/* 視線カメラスイッチボタン */
.btn-primary-cam {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0EA5E9, #2563EB);
    color: #FFFFFF;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.35);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-primary-cam:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.5);
    filter: brightness(1.1);
}

.btn-primary-cam:active {
    transform: translateY(1px) scale(0.96);
}

.btn-primary-cam.active {
    background: linear-gradient(135deg, #10B981, #059669);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.6);
    border-color: rgba(52, 211, 153, 0.5);
}

/* タイトル画面内のカメラショートカットボタン */
.btn-title-cam-shortcut {
    position: absolute;
    right: 4%;
    bottom: 4%;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(56, 189, 248, 0.6);
    color: #38BDF8;
    font-family: 'Zen Maru Gothic', sans-serif;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 20;
}

.btn-title-cam-shortcut:hover {
    transform: scale(1.06);
    background: rgba(30, 41, 59, 0.95);
    border-color: #38BDF8;
    color: #FFFFFF;
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn-title-cam-shortcut.active {
    background: linear-gradient(135deg, #10B981, #059669);
    border-color: #34D399;
    color: #FFFFFF;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.6);
}

/* HUD視線バッジ */
.hud-gaze-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: rgba(16, 185, 129, 0.5) !important;
    color: #6EE7B7 !important;
    font-weight: 800;
}

.gaze-active-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 10px #10B981;
    animation: gaze-pulse 1.5s infinite ease-in-out;
}

@keyframes gaze-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

/* カメラプレビュー小窓 (PiP) */
.gaze-pip-container {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 192px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 2px solid rgba(56, 189, 248, 0.5);
    border-radius: 16px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.25);
    overflow: hidden;
    z-index: 50;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

.gaze-pip-container.minimized {
    transform: translateY(calc(100% + 40px));
    opacity: 0;
    pointer-events: none;
}

.gaze-pip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    background: rgba(30, 41, 59, 0.95);
    font-size: 11px;
    font-weight: 800;
    color: #38BDF8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
}

.btn-pip-close {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.btn-pip-close:hover {
    color: #FFFFFF;
    background: rgba(239, 68, 68, 0.4);
}

.gaze-pip-body {
    position: relative;
    width: 192px;
    height: 144px; /* 4:3 視野 */
    background: #0B0F19;
    overflow: hidden;
}

/* ビデオ映像（自然なミラー反転＆視野フィット） */
.gaze-pip-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* 自撮り・鏡表示 */
    display: block;
}

/* ランドマーク・瞳孔オーバーレイCanvas（ビデオの真上にジャスト配置） */
.gaze-pip-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    display: block;
}

.gaze-pip-status {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    font-size: 10px;
    font-weight: 700;
    color: #38BDF8;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 3;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* 視線ターゲット光輪（レティクル） */
.gaze-pointer-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.gaze-ring {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.6);
    background: radial-gradient(circle, rgba(56, 189, 248, 0.2) 0%, rgba(56, 189, 248, 0) 70%);
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
    animation: gaze-ring-spin 6s linear infinite;
}

.gaze-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38BDF8;
    box-shadow: 0 0 8px #38BDF8;
}

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




