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

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px;
}

.header {
    text-align: center;
    color: #ff6b9d;
    margin-bottom: 40px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-right {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
}

.header h1 {
    font-size: 3.5em;
    text-shadow: 3px 3px 6px rgba(255, 107, 157, 0.3);
    animation: titlePulse 2s ease-in-out infinite;
    font-weight: bold;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.admin-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    border: 3px solid #ff6b9d;
    color: #ff6b9d;
    padding: 15px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
    white-space: nowrap;
}

.admin-btn:hover {
    background: white;
    color: #667eea;
    transform: scale(1.1);
}

.game-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    position: relative;
}

.player-area {
    flex: 1;
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    border-radius: 30px;
    padding: 35px;
    box-shadow: 0 15px 50px rgba(255, 107, 157, 0.3);
    transition: transform 0.3s ease;
}

.player-area:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px rgba(255, 107, 157, 0.4);
}

.player-a {
    border: 5px solid #ff9a9e;
}

.player-b {
    border: 5px solid #a8e6cf;
}

.player-header {
    text-align: center;
    margin-bottom: 25px;
}

.avatar-container {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    position: relative;
}

.avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    animation: avatarBounce 2s ease-in-out infinite;
    border: 5px solid white;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

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

.rabbit {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    box-shadow: 0 8px 20px rgba(252, 182, 159, 0.6);
}

.bear {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    box-shadow: 0 8px 20px rgba(174, 237, 234, 0.6);
}

.avatar-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 50%;
}

.eyes {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.eye {
    width: 16px;
    height: 16px;
    background: #2d3436;
    border-radius: 50%;
    position: relative;
    animation: blink 3s ease-in-out infinite;
}

.eye::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
}

@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

.nose {
    width: 10px;
    height: 8px;
    background: #ff6b9d;
    border-radius: 50%;
    margin: 0 auto 8px;
}

.mouth {
    width: 25px;
    height: 12px;
    border: 3px solid #2d3436;
    border-top: none;
    border-radius: 0 0 12px 12px;
    margin: 0 auto;
}

.ears {
    position: absolute;
    top: -25px;
    width: 100%;
    display: flex;
    justify-content: space-between;
}

.ear {
    width: 35px;
    height: 45px;
    border-radius: 50% 50% 0 0;
    position: relative;
    border: 3px solid white;
}

.rabbit .ear {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.bear .ear {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.player-header h2 {
    color: #ff6b9d;
    margin-bottom: 12px;
    font-size: 2em;
    font-weight: bold;
}

.score {
    font-size: 1.5em;
    color: #636e72;
    font-weight: bold;
}

.score span {
    color: #ff9a9e;
    font-size: 1.5em;
}

.question-area {
    text-align: center;
}

.question-text {
    background: #fff;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    font-size: 1.3em;
    color: #2d3436;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.8;
    border: 3px solid #ffecd2;
    box-shadow: 0 4px 10px rgba(255, 236, 210, 0.3);
}

.audio-player {
    margin-bottom: 15px;
}

.audio-player audio {
    width: 100%;
    border-radius: 15px;
    border: 3px solid #ffecd2;
}

.question-image {
    margin-bottom: 20px;
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    border-radius: 15px;
    border: 3px solid #ffecd2;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.2);
}

.question-image img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 15px;
    border: 4px solid #ff9a9e;
    box-shadow: 0 6px 20px rgba(255, 154, 158, 0.3);
}

.options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.option-btn {
    padding: 20px;
    font-size: 1.3em;
    border: 4px solid #ffecd2;
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    color: #2d3436;
    box-shadow: 0 4px 10px rgba(255, 236, 210, 0.3);
}

.option-btn:hover {
    background: linear-gradient(135deg, #ffe3e3 0%, #ffd1dc 100%);
    transform: scale(1.08);
    box-shadow: 0 6px 15px rgba(255, 236, 210, 0.5);
}

.option-btn:active {
    transform: scale(0.95);
}

.option-btn.correct {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border-color: #a8edea;
    animation: correctPulse 0.5s ease;
    box-shadow: 0 6px 20px rgba(174, 237, 234, 0.6);
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.option-btn.wrong {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border-color: #ff9a9e;
    animation: wrongShake 0.5s ease;
    box-shadow: 0 6px 20px rgba(255, 154, 158, 0.6);
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.feedback {
    margin-top: 20px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-width: 250px;
    align-self: stretch;
    padding-bottom: 80px;
}

.start-btn, .next-btn {
    padding: 25px 50px;
    font-size: 1.8em;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: 4px solid #ff6b9d;
    border-radius: 60px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.5);
    transition: all 0.3s ease;
    margin-bottom: 25px;
    font-weight: bold;
}

.start-btn:hover, .next-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(255, 107, 157, 0.7);
}

.round-info {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 20px 35px;
    border-radius: 35px;
    color: #ff6b9d;
    font-size: 1.5em;
    font-weight: bold;
    border: 4px solid white;
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.4);
}

.restart-btn {
    padding: 20px 40px;
    font-size: 1.6em;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border: 4px solid #a8edea;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(174, 237, 234, 0.5);
    margin-top: 15px;
}

.restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(174, 237, 234, 0.7);
}

.fireworks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.firework {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    animation: fireworkExplode 1s ease-out forwards;
}

@keyframes fireworkExplode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

.lightning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    display: none;
}

.lightning.active {
    display: block;
    animation: lightningFlash 0.5s ease;
}

@keyframes lightningFlash {
    0%, 100% {
        background: transparent;
    }
    50% {
        background: rgba(255, 255, 255, 0.8);
    }
}

.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 5000;
    justify-content: center;
    align-items: center;
}

.login-modal.active {
    display: flex;
}

.login-modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.login-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.login-modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.login-modal-body {
    padding: 30px;
}

.machine-code-section,
.activation-code-section {
    margin-bottom: 25px;
}

.machine-code-section label,
.activation-code-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

.machine-code-display {
    display: flex;
    gap: 10px;
}

.machine-code-display input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: #f8f9fa;
    color: #333;
}

.activation-code-section input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s ease;
}

.activation-code-section input:focus {
    outline: none;
    border-color: #667eea;
}

.copy-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.copy-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.login-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    color: #999;
    font-size: 14px;
}

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

.admin-modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

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

.logout-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.logout-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.modal-header h2 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.close-btn:hover {
    transform: rotate(90deg);
}

.modal-body {
    padding: 40px;
}

.admin-layout {
    display: flex;
    gap: 30px;
    min-height: 500px;
}

.admin-left {
    flex: 1;
    min-width: 0;
    padding-right: 20px;
    border-right: 3px solid #ffecd2;
}

.admin-right {
    flex: 1;
    min-width: 0;
    padding-left: 20px;
}

.admin-left .admin-section h3 {
    color: #ff6b9d;
    margin-bottom: 25px;
    border-bottom: 4px solid #ffecd2;
    padding-bottom: 15px;
    font-size: 1.5em;
    font-weight: bold;
}

.admin-right .admin-section h3 {
    color: #ff6b9d;
    margin-bottom: 25px;
    border-bottom: 4px solid #ffecd2;
    padding-bottom: 15px;
    font-size: 1.5em;
    font-weight: bold;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #ff6b9d;
    font-weight: bold;
    font-size: 1.1em;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 15px;
    border: 3px solid #ffecd2;
    border-radius: 15px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: #fff;
    font-weight: normal;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #ff9a9e;
    box-shadow: 0 0 10px rgba(255, 154, 158, 0.3);
}

.image-preview {
    position: relative;
    display: inline-block;
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    border-radius: 15px;
    border: 3px solid #ffecd2;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.2);
    text-align: center;
}

.image-preview img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 10px;
    border: 3px solid #ffecd2;
    box-shadow: 0 4px 10px rgba(255, 107, 157, 0.3);
}

.add-btn {
    padding: 18px 40px;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border: 4px solid #a8edea;
    border-radius: 30px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(174, 237, 234, 0.5);
}

.clear-all-btn {
    padding: 18px 40px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: 4px solid #ff6b9d;
    border-radius: 30px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.5);
}

.clear-all-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 107, 157, 0.7);
}

.add-btn:hover {
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.add-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(174, 237, 234, 0.7);
}

.questions-list {
    max-height: calc(90vh - 200px);
    overflow-y: auto;
    padding-right: 10px;
}

.question-item {
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    border-left: 5px solid #ff9a9e;
    box-shadow: 0 4px 10px rgba(255, 154, 158, 0.2);
}

.question-item h4 {
    color: #ff6b9d;
    margin-bottom: 12px;
    font-size: 1.2em;
    font-weight: bold;
}

.question-item p {
    color: #636e72;
    font-size: 1em;
    margin-bottom: 8px;
}

.question-item .delete-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: 3px solid #ff6b9d;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 12px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(255, 107, 157, 0.3);
}

.question-item .delete-btn:hover {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff9a9e 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 157, 0.5);
}

.question-item .edit-btn {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border: 3px solid #a8edea;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 12px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(174, 237, 234, 0.3);
}

.question-item .edit-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(174, 237, 234, 0.5);
}

.cancel-edit-btn {
    padding: 18px 40px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: 4px solid #ff6b9d;
    border-radius: 30px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.5);
}

.cancel-edit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 107, 157, 0.7);
}

.storage-info {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 3px solid #a8edea;
}

.storage-title {
    font-size: 1.1em;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 15px;
    text-align: center;
}

.storage-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.storage-used {
    height: 100%;
    width: 0%;
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    border-radius: 10px;
    transition: width 0.3s ease, background 0.3s ease;
}

.storage-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: #636e72;
    font-weight: bold;
}

.storage-text span {
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.storage-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.storage-btn {
    padding: 12px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.storage-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.5);
}

.smiley {
    font-size: 80px;
    animation: smileyBounce 0.5s ease;
}

@keyframes smileyBounce {
    0%, 100% { transform: scale(0); }
    50% { transform: scale(1.3); }
}

.cry {
    font-size: 80px;
    animation: cryShake 0.5s ease;
}

@keyframes cryShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-12px); }
    75% { transform: translateX(12px); }
}

.audio-editor {
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    padding: 30px;
    border-radius: 20px;
    border: 4px solid #ffecd2;
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.3);
}

.audio-player-container {
    margin-bottom: 20px;
}

.audio-player-container audio {
    width: 100%;
    border-radius: 15px;
    border: 3px solid #ffecd2;
}

.waveform-container {
    position: relative;
    width: 100%;
    height: 180px;
    background: #2d3436;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 4px solid #ffecd2;
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.3);
}

#waveformCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.selection-handle {
    position: absolute;
    top: 0;
    width: 25px;
    height: 100%;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    cursor: ew-resize;
    pointer-events: auto;
    transition: background 0.3s ease;
    z-index: 100;
    border: 4px solid #ff6b9d;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.5);
}

.selection-handle:hover {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff9a9e 100%);
    transform: scaleX(1.1);
}

.selection-handle.left {
    left: 0;
}

.selection-handle.right {
    left: 100%;
    transform: translateX(-100%);
}

.selection-handle::before {
    content: '◀';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.selection-handle.right::before {
    content: '▶';
}

.time-display {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: 1.1em;
    color: #2d3436;
    border: 3px solid #ffecd2;
    box-shadow: 0 4px 10px rgba(255, 107, 157, 0.2);
}

.time-display span {
    font-weight: bold;
}

.time-display span span {
    color: #ff9a9e;
    font-size: 1.2em;
}

.editor-buttons {
    display: flex;
    gap: 15px;
}

.preview-btn, .reset-btn {
    flex: 1;
    padding: 15px 30px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-btn {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border: 3px solid #a8edea;
}

.preview-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(174, 237, 234, 0.6);
}

.reset-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: 3px solid #ff6b9d;
}

.reset-btn:hover {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff9a9e 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 107, 157, 0.6);
}

.option-group {
    position: relative;
}

.option-image-upload {
    margin-top: 10px;
}

.option-image-upload input[type="file"] {
    padding: 10px;
    font-size: 14px;
}

.option-image-preview {
    position: relative;
    display: inline-block;
    margin-top: 10px;
}

.option-image-preview img {
    max-width: 150px;
    max-height: 100px;
    border-radius: 10px;
    border: 3px solid #ffecd2;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.option-image-preview img:hover {
    transform: scale(1.05);
}

.remove-option-img {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff6b6b;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.remove-option-img:hover {
    background: #ee5a5a;
    transform: scale(1.1);
}

.remove-media-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff6b6b;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.remove-media-btn:hover {
    background: #ee5a5a;
    transform: scale(1.1);
}

.remove-audio-btn {
    padding: 15px 30px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
    border: 3px solid #ff6b6b;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.remove-audio-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.5);
}

.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.image-modal-content img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    cursor: grab;
    transition: transform 0.1s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.image-modal-close:hover {
    transform: rotate(90deg);
}

.image-modal-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.zoom-hint {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.zoom-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.reset-zoom-btn {
    width: auto;
    padding: 0 15px;
    border-radius: 18px;
    font-size: 14px;
}

#zoomLevel {
    color: white;
    font-size: 14px;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}

.crop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.crop-modal.active {
    display: flex;
}

.crop-modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 700px;
    width: 95%;
}

.crop-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.crop-modal-header h3 {
    color: #ff6b9d;
    font-size: 1.5em;
}

.crop-close-btn {
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: #636e72;
    transition: transform 0.3s ease;
}

.crop-close-btn:hover {
    transform: rotate(90deg);
}

.crop-container {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
    line-height: 0;
}

#cropCanvas {
    display: block;
    border-radius: 10px;
    border: 3px solid #ffecd2;
    box-sizing: border-box;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 10px;
    overflow: hidden;
}

.crop-selection {
    position: absolute;
    border: 3px dashed #ff6b9d;
    background: rgba(255, 107, 157, 0.1);
    cursor: move;
    pointer-events: auto;
    box-sizing: border-box;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #ff6b9d;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle.n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle.s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle.w { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }
.crop-handle.e { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }

.crop-info {
    text-align: center;
    margin-bottom: 20px;
    color: #636e72;
    font-weight: bold;
}

.crop-info span span {
    color: #ff6b9d;
}

.crop-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.crop-cancel-btn,
.crop-confirm-btn,
.crop-select-all-btn {
    padding: 15px 40px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.crop-cancel-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    color: white;
    border: 3px solid #ff6b9d;
}

.crop-cancel-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.5);
}

.crop-confirm-btn {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border: 3px solid #a8edea;
}

.crop-confirm-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(174, 237, 234, 0.5);
}

.crop-select-all-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid #667eea;
}

.crop-select-all-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.option-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.option-img {
    max-width: 120px;
    max-height: 80px;
    border-radius: 8px;
    border: 2px solid #ffecd2;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.option-img:hover {
    transform: scale(1.1);
}

.bg-music-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bg-music-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid white;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
}

.bg-music-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.bg-music-toggle.playing {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    animation: musicPulse 1s ease-in-out infinite;
}

@keyframes musicPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.bg-music-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.bg-music-controls.show {
    display: flex;
}

.bg-music-volume {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ffecd2;
    border-radius: 3px;
    outline: none;
}

.bg-music-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(255, 154, 158, 0.4);
}

.bg-music-status {
    font-size: 12px;
    color: #636e72;
    font-weight: bold;
}

.bg-music-preview {
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    border-radius: 15px;
    border: 3px solid #ffecd2;
}

.bg-music-preview audio {
    width: 100%;
    border-radius: 10px;
}

.remove-bg-music-btn {
    margin-top: 10px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
    border: 3px solid #ff6b6b;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.remove-bg-music-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.countdown-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    white-space: nowrap;
    transition: all 0.3s ease;
    display: none;
}

.countdown-display:not(:empty) {
    display: block;
}

.countdown-label {
    margin-right: 5px;
    opacity: 0.9;
}

.countdown-time {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.countdown-warning {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    animation: countdownPulse 2s ease-in-out infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.countdown-expired {
    color: #ff6b6b;
    font-weight: bold;
    font-size: 15px;
}

.countdown-display.expired {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    animation: none;
}

.expired-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2500;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.expired-overlay.active {
    display: flex;
}

.expired-content {
    background: white;
    border-radius: 25px;
    padding: 50px 60px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: expiredSlideIn 0.5s ease-out;
    max-width: 450px;
    width: 90%;
}

@keyframes expiredSlideIn {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.expired-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: lockShake 2s ease-in-out infinite;
}

@keyframes lockShake {
    0%, 90%, 100% { transform: rotate(0deg); }
    92% { transform: rotate(-5deg); }
    94% { transform: rotate(5deg); }
    96% { transform: rotate(-5deg); }
    98% { transform: rotate(5deg); }
}

.expired-content h2 {
    color: #ff6b6b;
    font-size: 28px;
    margin-bottom: 15px;
    font-weight: bold;
}

.expired-content p {
    color: #636e72;
    font-size: 16px;
    margin-bottom: 10px;
    line-height: 1.6;
}

.expired-login-btn {
    margin-top: 25px;
    padding: 18px 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.expired-login-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.6);
}

.expired-contact {
    margin-top: 20px;
    color: #ff6b6b;
    font-weight: bold;
    font-size: 14px;
}

.file-import-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px;
}

/* ── 整屏切换：选完题目文件后，导入界面整屏切走，进入独立的游戏界面 ── */
.screen-hidden {
    display: none !important;
}

.screen-enter {
    animation: screenEnter 0.34s ease-out;
}

@keyframes screenEnter {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.server-load-box {
    display: none;
    margin-top: 18px;
}

.server-load-box.show {
    display: block;
}

.server-load-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #b2bec3;
    font-size: 12px;
    margin-bottom: 12px;
}

.server-load-divider::before,
.server-load-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
}

.server-load-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(9, 132, 227, 0.3);
}

.server-load-btn:hover {
    filter: brightness(1.06);
}

.server-load-btn:disabled {
    opacity: 0.65;
    cursor: default;
}

.server-load-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #636e72;
    word-break: break-all;
}

.build-tag {
    margin-top: 18px;
    font-size: 12px;
    color: #b2bec3;
    letter-spacing: 0.5px;
}

.game-screen {
    display: block;
}

.game-file-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 20px;
    padding: 10px 22px;
    width: fit-content;
    max-width: 100%;
    background: #ffffff;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(255, 107, 157, 0.18);
    font-size: 14px;
    color: #636e72;
}

.game-file-bar .file-name {
    font-weight: 700;
    color: #2d3436;
    word-break: break-all;
}

.game-file-bar .question-count {
    color: #ff6b9d;
    font-weight: 700;
}

.import-card {
    background: linear-gradient(135deg, #fff5f7 0%, #ffe3e3 100%);
    border-radius: 30px;
    padding: 50px 70px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 107, 157, 0.3);
    border: 5px solid #ff9a9e;
    max-width: 500px;
    width: 100%;
}

.import-icon {
    font-size: 80px;
    margin-bottom: 25px;
    animation: iconBounce 2s ease-in-out infinite;
}

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

.import-card h2 {
    color: #ff6b9d;
    font-size: 28px;
    margin-bottom: 15px;
    font-weight: bold;
}

.import-hint {
    color: #636e72;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.file-input-label {
    display: inline-block;
    padding: 20px 50px;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: white;
    border-radius: 30px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(174, 237, 234, 0.5);
    border: 4px solid #a8edea;
}

.file-input-label:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 35px rgba(174, 237, 234, 0.7);
}

.file-info {
    margin-top: 25px;
}

.file-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
    padding: 20px 30px;
    border-radius: 20px;
    border: 4px solid #96e6a1;
}

.success-icon {
    font-size: 36px;
}

.file-name {
    color: #2d3436;
    font-size: 18px;
    font-weight: bold;
    word-break: break-all;
}

.question-count {
    color: #27ae60;
    font-size: 24px;
    font-weight: bold;
}

.change-file-btn {
    display: block;
    margin: 15px auto 0;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid #667eea;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.change-file-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.5);
}

/* ── 局域网设备激活界面（通过局域网打开且未激活时全屏显示）── */
.activate-gate {
    display: none;
}

.activate-gate.active {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 22, 30, 0.94);
    z-index: 40000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.activate-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.activate-icon {
    font-size: 40px;
    margin-bottom: 6px;
}

.activate-card h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: #2d3436;
}

.activate-desc {
    font-size: 13px;
    color: #636e72;
    margin-bottom: 20px;
    line-height: 1.6;
}

.activate-label {
    font-size: 12px;
    color: #636e72;
    text-align: left;
    margin-bottom: 6px;
    font-weight: 600;
}

.activate-code {
    background: #f1f3f6;
    border: 2px dashed #b2bec3;
    border-radius: 10px;
    padding: 14px;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 20px;
    letter-spacing: 3px;
    font-weight: 700;
    color: #0984e3;
    cursor: pointer;
    user-select: all;
    margin-bottom: 18px;
    word-break: break-all;
}

.activate-code:hover {
    border-color: #0984e3;
    background: #eaf4fe;
}

#gateActivationInput {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #dfe6e9;
    border-radius: 10px;
    font-size: 16px;
    text-align: center;
    letter-spacing: 2px;
    outline: none;
    font-family: 'Consolas', 'Menlo', monospace;
    text-transform: uppercase;
}

#gateActivationInput:focus {
    border-color: #0984e3;
}

.activate-error {
    color: #e24b4a;
    font-size: 12px;
    min-height: 18px;
    margin: 6px 0 10px;
    text-align: left;
}

.activate-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #0984e3 0%, #0064c8 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.activate-btn:hover {
    filter: brightness(1.08);
}

.activate-contact {
    margin-top: 14px;
    font-size: 12px;
    color: #b2bec3;
}