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

body {
    background: #0a0a0f;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow: hidden;
}

/* スクリーン共通 */
.screen {
    display: none;
    width: 100vw;
    height: 100vh;
}

.screen.active {
    display: flex;
}

/* タイトル画面 */
#titleScreen {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #0f0f1a 100%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.title-content {
    text-align: center;
}

.title-content h1 {
    font-size: 4rem;
    background: linear-gradient(90deg, #ff6b35, #f7931e, #ff6b35);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientMove 3s linear infinite;
    margin-bottom: 10px;
}

@keyframes gradientMove {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.subtitle {
    color: #666;
    font-size: 1.2rem;
    margin-bottom: 40px;
}

.file-section {
    margin-bottom: 30px;
}

.file-label {
    display: inline-block;
    padding: 15px 30px;
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.file-label:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}

.file-label input {
    display: none;
}

.file-name {
    margin-top: 15px;
    color: #666;
}

.settings-section {
    margin-bottom: 30px;
}

.setting-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.setting-group label {
    color: #888;
    font-size: 1rem;
}

.setting-group input[type="range"] {
    width: 150px;
}

.setting-group span {
    color: #fff;
    font-weight: bold;
    width: 30px;
}

.menu-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
    border: 2px solid #3d3d5c;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.menu-btn:hover:not(:disabled) {
    border-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
    transform: translateY(-3px);
}

.menu-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.menu-btn.primary {
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    border: none;
}

.menu-btn.primary:hover:not(:disabled) {
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.6);
}

.menu-btn .icon {
    font-size: 1.5rem;
}

.direction-guide {
    margin-top: 40px;
}

.direction-guide h3 {
    color: #666;
    margin-bottom: 20px;
}

.directions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-width: 300px;
    margin: 0 auto;
}

.dir-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.dir-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
    border: 2px solid #3d3d5c;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* 準備画面 */
#readyScreen {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ready-content {
    text-align: center;
}

.ready-content h2 {
    font-size: 2rem;
    color: #ff6b35;
    margin-bottom: 10px;
}

.ready-content p {
    color: #888;
    margin-bottom: 20px;
}

.camera-preview {
    position: relative;
    width: 640px;
    height: 480px;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid #3d3d5c;
}

.camera-preview video,
.camera-preview canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.camera-preview video {
    background: #0a0a0f;
    opacity: 0; /* 映像を非表示 */
    transform: scaleX(-1);
}

.camera-preview canvas {
    pointer-events: none;
    /* 反転なし - 描画側で処理 */
}

.pose-status {
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.pose-status.detected {
    color: #00ff88;
}

.pose-status.not-detected {
    color: #ff4444;
}

.ready-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.control-btn {
    padding: 10px 25px;
    font-size: 1rem;
    background: #2d2d44;
    border: 1px solid #3d3d5c;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #3d3d5c;
}

/* ゲーム画面 */
#gameScreen {
    flex-direction: column;
    background: #0a0a0f;
    position: relative;
}

.game-header {
    display: flex;
    justify-content: space-between;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.score-display, .combo-display, .accuracy-display {
    text-align: center;
}

.score-display .label, .combo-display .label, .accuracy-display .label {
    display: block;
    font-size: 0.8rem;
    color: #666;
}

#score, #accuracy {
    font-size: 1.8rem;
    font-weight: bold;
}

#combo {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ff6b35;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameVideo {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.4;
}

#gameCanvas, #poseCanvas {
    position: absolute;
    width: 100%;
    height: 100%;
}

#poseCanvas {
    transform: scaleX(-1);
}

.judgement {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: bold;
    opacity: 0;
    text-shadow: 0 0 30px currentColor;
    pointer-events: none;
    z-index: 200;
}

.judgement.show {
    animation: judgementPop 0.5s ease-out;
}

@keyframes judgementPop {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.judgement.perfect { color: #00ffff; }
.judgement.great { color: #00ff88; }
.judgement.good { color: #ffff00; }
.judgement.miss { color: #ff4444; }

.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10rem;
    font-weight: bold;
    color: #ff6b35;
    text-shadow: 0 0 50px rgba(255, 107, 53, 0.8);
    z-index: 300;
    display: none;
}

.countdown.show {
    display: block;
    animation: countdownPulse 1s ease-out;
}

@keyframes countdownPulse {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* 結果画面 */
#resultScreen {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
    align-items: center;
    justify-content: center;
}

.result-content {
    text-align: center;
    background: rgba(30, 30, 50, 0.9);
    padding: 50px 80px;
    border-radius: 20px;
    border: 2px solid #3d3d5c;
}

.result-content h2 {
    font-size: 2rem;
    color: #ff6b35;
    margin-bottom: 20px;
}

.result-grade {
    font-size: 8rem;
    font-weight: bold;
    margin: 20px 0;
    text-shadow: 0 0 50px currentColor;
}

.result-grade.S { color: #00ffff; }
.result-grade.A { color: #00ff88; }
.result-grade.B { color: #ffff00; }
.result-grade.C { color: #ff8800; }
.result-grade.D { color: #ff4444; }

.result-stats {
    display: flex;
    gap: 40px;
    justify-content: center;
    margin: 30px 0;
}

.result-stats .stat {
    text-align: center;
}

.result-stats .label {
    display: block;
    color: #666;
    font-size: 0.9rem;
}

.result-stats .value {
    font-size: 2rem;
    font-weight: bold;
}

.judgement-breakdown {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
}

.judge-stat {
    padding: 10px 20px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

.judge-stat .name {
    display: block;
    font-size: 0.8rem;
}

.judge-stat .count {
    font-size: 1.5rem;
    font-weight: bold;
}

.judge-stat.perfect { color: #00ffff; }
.judge-stat.great { color: #00ff88; }
.judge-stat.good { color: #ffff00; }
.judge-stat.miss { color: #ff4444; }

.result-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

/* ゾーンインジケーター */
.zone-indicator {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.1s ease;
}

.zone-indicator.active {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.2);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
}

.zone-indicator.upper-left { top: 10%; left: 10%; }
.zone-indicator.upper-right { top: 10%; right: 10%; }
.zone-indicator.lower-left { bottom: 10%; left: 10%; }
.zone-indicator.lower-right { bottom: 10%; right: 10%; }

/* アニメーション */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.combo-display.active #combo {
    animation: pulse 0.2s ease;
}

/* キャリブレーション画面 */
#calibrationScreen {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.calibration-content {
    text-align: center;
    max-width: 800px;
}

.calibration-content h2 {
    font-size: 2rem;
    color: #ff6b35;
    margin-bottom: 10px;
}

.calibration-content p {
    color: #888;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.calibration-preview {
    position: relative;
    width: 640px;
    height: 480px;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid #3d3d5c;
}

.calibration-preview video,
.calibration-preview canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
}

.calibration-preview video {
    background: #0a0a0f;
    opacity: 0; /* 映像を非表示 */
}

.calibration-zones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.calib-zone {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 3px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.calib-zone.upper-left { top: 10%; left: 10%; }
.calib-zone.upper-right { top: 10%; right: 10%; }
.calib-zone.lower-left { bottom: 10%; left: 10%; }
.calib-zone.lower-right { bottom: 10%; right: 10%; }

.calib-zone.active {
    border-color: #ff6b35;
    border-style: solid;
    background: rgba(255, 107, 53, 0.2);
    color: #ff6b35;
    transform: scale(1.1);
}

.calib-zone.captured {
    border-color: #00ff88;
    border-style: solid;
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
}

.calibration-progress {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.progress-item {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #666;
    transition: all 0.3s ease;
}

.progress-item.active {
    background: rgba(255, 107, 53, 0.3);
    color: #ff6b35;
}

.progress-item.done {
    background: rgba(0, 255, 136, 0.3);
    color: #00ff88;
}

.calibration-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* 音楽タブ */
.music-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #3d3d5c;
    border-radius: 8px;
    color: #888;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.tab-btn.active {
    background: linear-gradient(90deg, #ff6b35, #f7931e);
    border-color: transparent;
    color: #fff;
}

.tab-content {
    display: none;
    min-height: 150px;
}

.tab-content.active {
    display: block;
}

/* 音楽リスト */
.music-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    margin-bottom: 10px;
}

.music-list::-webkit-scrollbar {
    width: 8px;
}

.music-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.music-list::-webkit-scrollbar-thumb {
    background: #ff6b35;
    border-radius: 4px;
}

.music-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.music-item:last-child {
    margin-bottom: 0;
}

.music-item:hover {
    background: rgba(255, 107, 53, 0.2);
}

.music-item.selected {
    background: linear-gradient(90deg, rgba(255, 107, 53, 0.3), rgba(247, 147, 30, 0.3));
    border: 1px solid #ff6b35;
}

.music-item .title {
    font-size: 1rem;
    color: #fff;
}

.music-item .size {
    font-size: 0.8rem;
    color: #666;
}

.music-list .loading,
.music-list .error {
    text-align: center;
    padding: 20px;
    color: #888;
}

.music-list .error {
    color: #ff4444;
}

/* 録音コントロール */
.record-controls {
    text-align: center;
    padding: 20px;
}

.record-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
}

.record-btn.recording {
    background: linear-gradient(90deg, #ff0000, #ff3333);
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 0, 0, 0.5); }
    50% { box-shadow: 0 0 40px rgba(255, 0, 0, 0.8); }
}

.recording-status {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #ff4444;
}

.recording-time {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    margin-top: 10px;
    font-family: monospace;
}

.recorded-audio {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.recorded-audio audio {
    width: 100%;
    margin-bottom: 15px;
}

.record-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.use-btn, .save-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.use-btn {
    background: linear-gradient(90deg, #00ff88, #00cc66);
    color: #000;
}

.save-btn {
    background: linear-gradient(90deg, #4488ff, #2266dd);
    color: #fff;
}

.use-btn:hover, .save-btn:hover {
    transform: scale(1.05);
}

.save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* モバイル対応 */
html, body {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

/* モバイルレスポンシブ */
@media (max-width: 768px) {
    .title-content h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 25px;
    }

    .music-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .music-list {
        max-height: 150px;
    }

    .music-item {
        padding: 10px 12px;
    }

    .music-item .title {
        font-size: 0.9rem;
    }

    .file-label {
        padding: 12px 20px;
        font-size: 1rem;
    }

    .menu-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .direction-guide {
        margin-top: 25px;
    }

    .directions {
        gap: 10px;
        max-width: 280px;
    }

    .dir-item {
        padding: 8px 12px;
    }

    .dir-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    /* 準備画面 */
    .camera-preview {
        width: 100%;
        max-width: 400px;
        height: auto;
        aspect-ratio: 4/3;
    }

    .ready-content h2 {
        font-size: 1.5rem;
    }

    /* ゲーム画面 */
    .game-header {
        padding: 10px 15px;
    }

    #score, #accuracy {
        font-size: 1.2rem;
    }

    #combo {
        font-size: 1.8rem;
    }

    .judgement {
        font-size: 2.5rem;
    }

    .countdown {
        font-size: 6rem;
    }

    /* 結果画面 */
    .result-content {
        padding: 30px 20px;
        margin: 10px;
        width: calc(100% - 20px);
        max-width: 400px;
    }

    .result-grade {
        font-size: 5rem;
    }

    .result-stats {
        gap: 20px;
        flex-wrap: wrap;
    }

    .result-stats .value {
        font-size: 1.5rem;
    }

    .judgement-breakdown {
        flex-wrap: wrap;
        gap: 10px;
    }

    .judge-stat {
        padding: 8px 15px;
    }

    .result-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .result-buttons .menu-btn {
        width: 100%;
    }

    /* 録音 */
    .record-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .recording-time {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .title-content h1 {
        font-size: 2rem;
    }

    .setting-group {
        flex-wrap: wrap;
        gap: 10px;
    }

    .setting-group input[type="range"] {
        width: 120px;
    }
}
