/* Base Styles & Variables */
:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #131a2e;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-focus: rgba(255, 255, 255, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --accent: #06b6d4;
    --accent-glow: rgba(6, 182, 212, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.3);
    --success: #10b981;
    --font-family: 'Noto Sans KR', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
}

/* Background Deco Glows */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}
.bg-glow-1 {
    top: -200px;
    left: -200px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}
.bg-glow-2 {
    bottom: -200px;
    right: -200px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    min-height: 100vh;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
    position: relative;
}

/* Header & Controls */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h1 span {
    -webkit-text-fill-color: initial;
    animation: bounce 2s infinite;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
    font-weight: 300;
}

.header-right {
    display: flex;
    gap: 0.75rem;
}

/* Button Styles */
.btn {
    border: none;
    outline: none;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--primary-glow);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-reveal {
    background: rgba(6, 182, 212, 0.1);
    color: #a5f3fc;
    border: 1px solid rgba(6, 182, 212, 0.2);
}
.btn-reveal:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow);
}
.btn-reveal:active {
    transform: translateY(0);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--danger-glow);
}
.btn-danger:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-border-focus);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.05);
}
.btn-secondary:active {
    transform: translateY(0);
}

/* Blackboard Area */
.blackboard-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.blackboard {
    width: 60%;
    min-width: 300px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 8px solid #334155;
    border-radius: 8px;
    padding: 1rem 0;
    text-align: center;
    box-shadow: 
        0 10px 15px -3px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.8);
    position: relative;
    border-bottom-width: 14px; /* 분필 거치대 느낌 */
}

.blackboard::after {
    content: '';
    position: absolute;
    bottom: -14px;
    left: 20px;
    width: 60px;
    height: 6px;
    background: #e2e8f0; /* 분필 */
    border-radius: 2px;
}

.chalkboard-text {
    color: #e2e8f0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    opacity: 0.85;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

/* Main Layout & Classroom Grid */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.classroom-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3분단 구조 */
    gap: 2.5rem 4rem;
    padding: 1rem;
    justify-content: center;
}

/* Desk Pair (2 desks side-by-side) */
.desk-pair {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

/* Single Desk Card Container */
.desk {
    flex: 1;
    height: 90px;
    perspective: 1000px; /* 3D Card Flip */
    cursor: pointer;
}

.desk-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

/* Desk Revealed State (CSS class added by JS) */
.desk.revealed .desk-inner {
    transform: rotateY(180deg);
}

/* Card Sides */
.desk-front, .desk-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

/* Front (Locked/Hidden State) */
.desk-front {
    background: var(--glass-bg);
    border: 2px dashed var(--glass-border);
    color: var(--text-muted);
}

.desk-front .seat-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    opacity: 0.6;
    text-transform: uppercase;
}

.desk-front .question-mark {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 0.25rem;
    opacity: 0.3;
}

.desk:hover .desk-front {
    border-color: var(--glass-border-focus);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Back (Revealed Student State) */
.desk-back {
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 100%);
    border: 2px solid var(--primary);
    transform: rotateY(180deg);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
}

.desk-back::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 45%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 55%
    );
    transform: rotate(45deg);
    animation: shine 4s infinite;
    pointer-events: none;
}

.desk-back .seat-label-back {
    font-size: 0.7rem;
    color: var(--text-secondary);
    position: absolute;
    top: 8px;
    font-weight: 500;
}

.desk-back .student-number {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff 40%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 5px;
}

.desk-back .student-suffix {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e9d5ff;
    margin-left: 2px;
}

/* Glowing animation for newly revealed seat */
.desk.highlighted .desk-back {
    animation: neonGlow 1.5s ease-in-out 3 alternate;
    border-color: #f472b6;
}

/* Student Button Panel (Footer) */
footer {
    background: rgba(19, 26, 46, 0.6);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.footer-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.student-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 0.75rem;
}

/* Student Button */
.student-btn {
    aspect-ratio: 1 / 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.student-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px var(--primary-glow);
}

.student-btn:active:not(:disabled) {
    transform: translateY(0);
}

.student-btn:disabled {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    cursor: not-allowed;
    text-decoration: line-through;
    opacity: 0.5;
}

.status-indicator {
    align-self: flex-end;
    font-size: 0.9rem;
    font-weight: 700;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 1rem;
    border-radius: 30px;
    color: var(--accent);
    font-family: 'Outfit', sans-serif;
}

/* Fullscreen Overlay (Bouncing Heartbeat) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 20, 0.92);
    backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

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

.overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.heartbeat-emoji {
    font-size: 6rem;
    animation: heartbeat 1.2s infinite ease-in-out;
    filter: drop-shadow(0 0 30px rgba(236, 72, 153, 0.6));
}

.heartbeat-text {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, #f472b6, #db2777);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: pulseText 1.2s infinite ease-in-out;
}

.student-bubble {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    font-size: 3.5rem;
    font-weight: 900;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 15px 30px rgba(99, 102, 241, 0.4),
        0 0 0 10px rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: floatBubble 3s ease-in-out infinite;
}

.heartbeat-sub {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Confetti Canvas */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* Custom Keyframe Animations */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.15); }
    40% { transform: scale(1.05); }
    60% { transform: scale(1.2); }
}

@keyframes pulseText {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; transform: scale(1.02); }
}

@keyframes floatBubble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 200%; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(-6px) rotate(10deg); }
}

@keyframes neonGlow {
    from {
        box-shadow: 
            0 0 10px rgba(244, 114, 182, 0.4),
            0 0 20px rgba(244, 114, 182, 0.2),
            inset 0 0 10px rgba(244, 114, 182, 0.2);
    }
    to {
        box-shadow: 
            0 0 25px rgba(244, 114, 182, 0.9),
            0 0 45px rgba(99, 102, 241, 0.6),
            inset 0 0 20px rgba(244, 114, 182, 0.5);
        border-color: #f472b6;
    }
}

/* Responsive Rules */
@media (max-width: 900px) {
    .classroom-grid {
        grid-template-columns: repeat(2, 1fr); /* 2분단으로 조정 */
        gap: 2rem 1.25rem;
    }
    .blackboard {
        width: 80%;
    }
}

@media (max-width: 600px) {
    .classroom-grid {
        grid-template-columns: 1fr; /* 1열로 조정 */
        gap: 1.5rem;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    .btn {
        flex: 1;
        justify-content: center;
        font-size: 0.85rem;
    }
    .blackboard {
        width: 100%;
    }
    .student-bubble {
        width: 90px;
        height: 90px;
        font-size: 2.5rem;
    }
    .heartbeat-emoji {
        font-size: 4.5rem;
    }
    .heartbeat-text {
        font-size: 1.5rem;
    }
}

/* Empty Seat Desk Styles */
.desk.empty {
    pointer-events: none;
    cursor: default;
}
.desk.empty .desk-front {
    border: 2px dashed rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.01);
    color: rgba(255, 255, 255, 0.12);
}
.desk.empty .question-mark {
    display: none;
}
.desk.empty .seat-label {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.3;
}
.desk.empty .desk-front::after {
    content: '공석';
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 0.25rem;
    opacity: 0.4;
    letter-spacing: 0.05em;
}

/* Settings Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 20, 0.82);
    backdrop-filter: blur(10px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}
.modal.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-content {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: modalSlideUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
@keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: white;
}
.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    line-height: 1;
}
.modal-close-btn:hover {
    color: white;
}
.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.form-group label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.form-group input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 1rem;
    transition: var(--transition-smooth);
    outline: none;
}
.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
    background: rgba(255, 255, 255, 0.05);
}
.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: flex-end;
}
.modal-footer .btn {
    width: 100%;
    justify-content: center;
}

