/* 음퀴생성기 스타일시트 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2em;
    margin-bottom: 10px;
}

.header p {
    opacity: 0.9;
}

/* 버튼 스타일 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd6;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* 카드 스타일 */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* 프로젝트 목록 */
.project-list {
    list-style: none;
}

.project-item {
    display: block;
    padding: 20px;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    cursor: pointer;
}

.project-item:hover {
    background: #f8f9fa;
}

.project-item:last-child {
    border-bottom: none;
}

.project-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.project-desc {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.project-meta {
    font-size: 0.8em;
    color: #999;
}

.project-meta span {
    margin-right: 15px;
}

/* 탭 스타일 */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* 폼 스타일 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* 상태 배지 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 600;
}

.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-closed {
    background: #f8d7da;
    color: #721c24;
}

.badge-music {
    background: #e8daef;
    color: #6c3483;
}

.badge-general {
    background: #d5f5e3;
    color: #1e8449;
}

.badge-played {
    background: #fadbd8;
    color: #922b21;
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: right;
}

/* 헤더 컨트롤 */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* 로딩 */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 빈 상태 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* 알림 */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Admin 특화 스타일 */
.admin-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* 퀴즈 목록 (관리자) */
.quiz-list {
    list-style: none;
}

.quiz-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
}

.quiz-item .quiz-number {
    width: 30px;
    height: 30px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.quiz-item .quiz-info {
    flex: 1;
    min-width: 0;
}

.quiz-item .quiz-info .quiz-summary {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quiz-item .quiz-info .quiz-detail {
    font-size: 0.85em;
    color: #666;
    margin-top: 2px;
}

.quiz-item .quiz-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

/* 라디오 토글 */
.radio-toggle {
    display: flex;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

.radio-toggle label {
    flex: 1;
    padding: 10px 15px;
    text-align: center;
    cursor: pointer;
    background: white;
    font-size: 14px;
    transition: all 0.2s;
    margin-bottom: 0 !important;
}

.radio-toggle input[type="radio"] {
    display: none;
}

.radio-toggle input[type="radio"]:checked + label,
.radio-toggle label.active {
    background: #667eea;
    color: white;
}

/* 파일 업로드 */
.file-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
    border-color: #667eea;
    background: #f8f9ff;
}

.file-upload-area.drag-over {
    border-color: #28a745;
    background: #e8f5e9;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

.file-upload-area.has-file {
    border-color: #28a745;
    background: #f0fff0;
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-top: 8px;
}

.file-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.file-preview .file-name {
    flex: 1;
    font-size: 0.9em;
    word-break: break-all;
}

.file-preview .file-remove {
    color: #dc3545;
    cursor: pointer;
    font-size: 18px;
}

/* ========== 퀴즈 그리드 (프로젝터/리모컨) ========== */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 15px;
    padding: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.quiz-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.quiz-cell.type-music {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.quiz-cell.type-general {
    background: linear-gradient(135deg, #00cec9, #00b894);
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.3);
}

.quiz-cell:hover {
    transform: scale(1.05);
}

.quiz-cell.type-music:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.quiz-cell.type-general:hover {
    box-shadow: 0 6px 20px rgba(0, 184, 148, 0.5);
}

.quiz-cell.played {
    background: linear-gradient(135deg, #636e72, #2d3436);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    opacity: 0.6;
}

.quiz-cell.played:hover {
    opacity: 0.8;
}

.quiz-cell.active {
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    animation: cellPulse 1.5s infinite;
}

@keyframes cellPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(243, 156, 18, 0.7); }
}

/* ========== 대기 화면 ========== */
.waiting-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #1a1a2e;
    color: white;
}

.waiting-screen h2 {
    font-size: 2em;
    margin-bottom: 20px;
    opacity: 0.9;
}

.waiting-screen p {
    font-size: 1.2em;
    opacity: 0.6;
    animation: waitingPulse 2s infinite;
}

@keyframes waitingPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ========== 문제/정답 표시 (프로젝터) ========== */
.quiz-display {
    min-height: 100vh;
    background: #1a1a2e;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
}

.quiz-display .quiz-number-label {
    position: absolute;
    top: 30px;
    left: 40px;
    font-size: 1.5em;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
}

.quiz-display .question-main {
    font-size: 3em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
    line-height: 1.3;
}

.quiz-display .question-hint {
    font-size: 1.5em;
    color: rgba(255,255,255,0.6);
    text-align: center;
    margin-top: 20px;
    font-style: italic;
}

.quiz-display .question-image {
    max-width: 60%;
    max-height: 50vh;
    border-radius: 12px;
    margin-top: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* 정답 화면 */
.answer-reveal {
    width: 100%;
    animation: answerSlideIn 0.6s ease-out;
}

@keyframes answerSlideIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.quiz-display .answer-main {
    font-size: 4em;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
}

.quiz-display .answer-artist {
    font-size: 2em;
    color: rgba(255,255,255,0.7);
    text-align: center;
    margin-bottom: 30px;
}

.quiz-display .answer-explanation {
    font-size: 1.3em;
    color: rgba(255,255,255,0.6);
    text-align: center;
    margin-top: 20px;
}

.quiz-display .answer-image {
    width: 100%;
    max-width: 80%;
    border-radius: 12px;
    margin: auto;
    display: block;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* 목록 화면 (프로젝터) */
.list-screen {
    min-height: 100vh;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.list-project-name {
    position: fixed;
    top: 15px;
    left: 20px;
    color: rgba(255,255,255,0.4);
    font-size: 0.9em;
    z-index: 10;
}

/* ========== 제어 페이지 (모바일) ========== */
.remote-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 15px;
    padding-bottom: 80px;
    min-height: 100vh;
    background: #f5f5f5;
}

.remote-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remote-header h2 {
    font-size: 1.2em;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
}

.connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
}

.connection-dot.connected {
    background: #2ecc71;
    animation: pulse 2s infinite;
}

.connection-dot.disconnected {
    background: #e74c3c;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 모바일 퀴즈 그리드 */
.remote-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.remote-grid .quiz-cell {
    font-size: 1.3em;
    border-radius: 8px;
}

.remote-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.remote-actions .btn {
    padding: 15px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    border-radius: 10px;
}

.btn-answer {
    background: linear-gradient(135deg, #f39c12, #e74c3c);
    color: white;
    font-size: 18px;
}

.btn-answer:hover {
    opacity: 0.9;
}

.btn-random {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
}

.btn-random:hover {
    opacity: 0.9;
}

.btn-list {
    background: linear-gradient(135deg, #636e72, #2d3436);
    color: white;
}

.btn-list:hover {
    opacity: 0.9;
}

/* 재생 위치 토글 */
.playback-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    padding: 8px 12px;
}

.playback-label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.toggle-switch {
    display: flex;
    background: #ddd;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    flex: 1;
}

.toggle-option {
    flex: 1;
    padding: 8px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    transition: all 0.2s;
    white-space: nowrap;
}

.toggle-option.active {
    background: #667eea;
    color: white;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* 하단 고정 랜덤 버튼 바 */
.random-fixed-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 50;
}

.random-fixed-bar .btn {
    flex: 1;
    padding: 14px 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border-radius: 10px;
    border: none;
    color: white;
    cursor: pointer;
}

.btn-random-all {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
}

.btn-random-music {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.btn-random-general {
    background: linear-gradient(135deg, #00cec9, #00b894);
}

/* 리모컨 정답 미리보기 */
.remote-preview {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.remote-preview h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1em;
}

.remote-preview .preview-answer {
    font-size: 1.3em;
    font-weight: 600;
    color: #e74c3c;
    margin-bottom: 5px;
}

.remote-preview .preview-detail {
    font-size: 0.9em;
    color: #666;
}

/* ========== 프리로드 상태 표시 ========== */
.preload-status {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    text-align: center;
    min-width: 300px;
}

.preload-bar-wrap {
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.preload-bar {
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    height: 100%;
    width: 0%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.preload-text {
    color: rgba(255,255,255,0.7);
    font-size: 0.9em;
}

/* ========== 음악 상태 표시 ========== */
.music-status {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    top: 30px;
    right: 40px;
    color: rgba(255,255,255,0.7);
    font-size: 1em;
}

.music-status-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.music-status-icon.loading-spinner {
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #f39c12;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.music-status-icon.playing-bars span {
    display: inline-block;
    width: 4px;
    background: #2ecc71;
    border-radius: 2px;
    animation: playingBar 1s ease-in-out infinite;
}

.music-status-icon.playing-bars span:nth-child(1) {
    height: 8px;
    animation-delay: 0s;
}

.music-status-icon.playing-bars span:nth-child(2) {
    height: 16px;
    animation-delay: 0.15s;
}

.music-status-icon.playing-bars span:nth-child(3) {
    height: 12px;
    animation-delay: 0.3s;
}

.music-status-icon.playing-bars span:nth-child(4) {
    height: 20px;
    animation-delay: 0.45s;
}

@keyframes playingBar {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.2); }
}

/* 퀴즈 모달 2컬럼 레이아웃 반응형 */
@media (max-width: 900px) {
    .modal-body {
        flex-direction: column !important;
    }
    .quiz-modal-left, .quiz-modal-right {
        max-height: none !important;
    }
}

/* 반응형 */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 10px 15px;
        flex: 1;
        text-align: center;
    }

    .header-controls {
        flex-direction: column;
        gap: 10px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .quiz-grid {
        gap: 10px;
        padding: 15px;
    }

    .quiz-cell {
        font-size: 1.8em;
    }

    .quiz-display .question-main {
        font-size: 2em;
    }

    .quiz-display .answer-main {
        font-size: 2.5em;
    }
}

@media (min-width: 1200px) {
    .quiz-grid {
        max-width: 1000px;
        gap: 20px;
    }

    .quiz-cell {
        font-size: 3em;
    }
}
