/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure tables display properly */
table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    display: table !important;
    width: 100% !important;
}

th, td {
    display: table-cell !important;
    vertical-align: middle !important;
}

tr {
    display: table-row !important;
}

tbody {
    display: table-row-group !important;
}

thead {
    display: table-header-group !important;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    color: #333;
}

.game-info-wrapper {
    width: 33.33%;
    margin: 0 auto;
    position: relative;
    float: none;
    clear: both;
}

.game-container {
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    float: none;
    clear: both;
}

/* Side table areas */
.table-left, .table-right {
    width: 25%;
    position: fixed;
    top: 0;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow-y: auto;
    gap: 15px;
}

.table-left {
    left: 0;
}

.table-right {
    right: 0;
}

.side-table {
    width: 100% !important;
    border-collapse: collapse !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) !important;
    margin-top: 0 !important;
    display: table !important;
    border: 2px solid #e2e8f0 !important;
}

.side-table:not(:first-child) {
    margin-top: 15px !important;
}

.side-table th {
    background: #667eea !important;
    color: white !important;
    padding: 15px 20px !important;
    text-align: center !important;
    font-size: 1.1em !important;
    font-weight: 600 !important;
    border: none !important;
    display: table-cell !important;
}

.side-table td {
    padding: 12px 20px !important;
    text-align: center !important;
    color: #4a5568 !important;
    font-size: 0.95em !important;
    line-height: 1.5 !important;
    border: 1px solid #e2e8f0 !important;
    background: rgba(255, 255, 255, 0.8) !important;
    display: table-cell !important;
}

.top-scores-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar styling */
.top-scores-container::-webkit-scrollbar {
    width: 8px;
}

.top-scores-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.top-scores-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.top-scores-container::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

/* Firefox scrollbar styling */
.top-scores-container {
    scrollbar-width: thin;
    scrollbar-color: #667eea rgba(255, 255, 255, 0.1);
}

.top-scores-table {
    font-size: 1.1em;
    margin: 0;
}

.top-scores-table th {
    padding: 6px 4px;
    font-size: 1em;
    font-weight: 600;
}

.top-scores-table th:first-child {
    background: #667eea;
    color: white;
    font-size: 1.2em;
    padding: 8px 4px;
}

.top-scores-table td {
    padding: 4px 3px;
    font-size: 0.9em;
    border: 1px solid #e2e8f0;
}

.top-scores-table tbody tr:nth-child(odd) {
    background: rgba(102, 126, 234, 0.05);
}

.top-scores-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.8);
}

.top-scores-table tbody tr:first-child {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    font-weight: 600;
}

.top-scores-table tbody tr:nth-child(2) {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    font-weight: 600;
}

.top-scores-table tbody tr:nth-child(3) {
    background: linear-gradient(135deg, #cd7f32 0%, #daa520 100%);
    font-weight: 600;
}

/* Screen management */
.screen {
    display: none;
}

#menu-screen {
    display: block;
}

/* Menu styles */
.menu-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    animation: slideIn 0.5s ease-out;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    width: auto;
    min-width: 300px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lektoren-title {
    font-size: 2.2em;
    margin-bottom: 10px;
    color: #667eea;
    font-weight: 700;
    animation: shake 1.5s infinite;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.student-character.happy {
    animation: happyBounce 0.5s ease-out;
}

.student-character.sad {
    animation: sadShake 0.5s ease-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes happyBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes sadShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-2px) rotate(-1deg); }
    20% { transform: translateX(2px) rotate(1deg); }
    30% { transform: translateX(-2px) rotate(-1deg); }
    40% { transform: translateX(2px) rotate(1deg); }
    50% { transform: translateX(-1px) rotate(-0.5deg); }
    60% { transform: translateX(1px) rotate(0.5deg); }
    70% { transform: translateX(-1px) rotate(-0.5deg); }
    80% { transform: translateX(1px) rotate(0.5deg); }
    90% { transform: translateX(-1px) rotate(-0.5deg); }
}

h1 {
    font-size: 2.5em;
    margin-bottom: 15px;
    color: #4a5568;
    font-weight: 700;
}

h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #4a5568;
    font-weight: 700;
}

p {
    font-size: 1.1em;
    margin-bottom: 30px;
    color: #718096;
    line-height: 1.6;
}

/* Version selector styles */
.version-selector {
    margin: 20px 0;
    text-align: center;
}

.version-selector label {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 15px;
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.version-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.version-item:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.version-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #5a67d8;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.version-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8em;
    margin-right: 10px;
    flex-shrink: 0;
}

.version-item.active .version-number {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.version-title {
    font-size: 0.85em;
    font-weight: 500;
    flex: 1;
    text-align: left;
}

/* Word order selector styles */
.word-order-selector {
    margin: 15px 0;
    text-align: center;
}

.word-order-selector label {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
}

.order-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.order-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 80px;
}

.order-item:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.order-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #5a67d8;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.order-icon {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.order-title {
    font-size: 0.9em;
    font-weight: 500;
    text-align: center;
}


/* Button styles */
.btn-primary, .btn-secondary {
    padding: 15px 30px;
    border: none;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px;
    min-width: 200px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.btn-lektoren {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    box-shadow: 0 10px 20px rgba(255, 107, 107, 0.3);
}

.btn-lektoren:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(255, 107, 107, 0.4);
}

/* Game screen styles */
#game-screen {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0;
    padding: 10px;
    box-shadow: none;
    border: none;
    height: 96vh;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
}

.stats-header, .stats-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.stats-left {
    display: flex;
    gap: 20px;
}

.stats-left span, .stats-bottom span {
    color: #4a5568;
}

.stats-left span span, .stats-bottom span span {
    color: #667eea;
    font-weight: 700;
}

/* Game area */
.game-area {
    position: relative;
    height: calc(96vh - 200px);
    background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 0;
    margin: 0;
    overflow: hidden;
    border: none;
    z-index: 1;
}

.danger-line {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #e53e3e 0%, #fc8181 50%, #e53e3e 100%);
    animation: pulse 1s infinite;
}

.danger-zone {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, rgba(229, 62, 62, 0.2), transparent);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.student-character-game {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 60px;
    z-index: 10;
}

/* Falling words */
.falling-word {
    position: absolute;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #667eea;
    border-radius: 20px;
    font-weight: 600;
    color: #4a5568;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.1s ease;
    cursor: pointer;
    user-select: none;
    z-index: 10;
}

.falling-word.being-typed {
    background: #667eea;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.falling-word.danger {
    background: #e53e3e;
    color: white;
    border-color: #c53030;
    animation: dangerPulse 0.5s infinite;
}

@keyframes dangerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Input area */
.input-area {
    text-align: center;
    padding: 10px;
    flex-shrink: 0;
}

/* Info table - Under spillet */
.info-table-container {
    height: auto;
    padding: 20px;
    position: relative;
    z-index: 10;
    display: none; /* Hidden by default */
    background: transparent;
    margin: 20px 0;
    clear: both;
    width: 100%;
    float: none;
    position: static;
}

/* Show info table only when game screen is active */
#game-screen ~ .info-table-container {
    display: block;
}

.info-table {
    width: 100% !important;
    border-collapse: collapse !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1) !important;
    border: 2px solid #e2e8f0 !important;
}

.info-table th {
    background: #667eea !important;
    color: white !important;
    padding: 15px 20px !important;
    text-align: center !important;
    font-size: 1.2em !important;
    font-weight: 600 !important;
    border: none !important;
    display: table-cell !important;
}

.info-table td {
    padding: 15px 20px !important;
    text-align: left !important;
    color: #4a5568 !important;
    font-size: 1em !important;
    line-height: 1.6 !important;
    border: 1px solid #e2e8f0 !important;
    background: rgba(255, 255, 255, 0.8) !important;
    display: table-cell !important;
}

#word-input {
    width: 100%;
    max-width: 400px;
    padding: 15px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 1.1em;
    text-align: center;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

#word-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

.input-area p {
    margin-top: 10px;
    font-size: 0.9em;
    color: #718096;
}

/* Stats display */
.stats {
    margin: 20px 0;
}

/* Level complete and game over screens */
#level-complete-screen, #game-over-screen {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 33.33%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.stats p {
    margin: 10px 0;
    font-size: 1em;
}

.stats p span {
    font-weight: 700;
    color: #667eea;
}

/* Responsive design */
@media (max-width: 1024px) {
    .game-container {
        transform: scale(0.9);
        transform-origin: top center;
    }
    
    #game-screen {
        height: 90vh;
    }
    
    .game-area {
        height: calc(90vh - 200px);
    }
    
    .table-left, .table-right {
        width: 20%;
        padding: 15px;
    }
    
    .side-table th, .side-table td {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .top-scores-table th, .top-scores-table td {
        padding: 3px 2px;
        font-size: 0.9em;
    }
}

@media (max-width: 768px) {
    .game-container {
        transform: scale(0.8);
        transform-origin: top center;
    }
    
    .menu-card {
        padding: 30px 20px;
        margin: 20px;
        max-width: 95vw;
        max-height: 95vh;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    h1 {
        font-size: 2em;
    }
    
    .stats-header, .stats-bottom {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .stats-left {
        flex-direction: column;
        gap: 10px;
    }
    
    #game-screen {
        height: 85vh;
    }
    
    .game-area {
        height: calc(85vh - 200px);
    }
    
    .btn-primary, .btn-secondary {
        min-width: 150px;
        padding: 12px 20px;
    }
    
    .table-left, .table-right {
        width: 15%;
        padding: 10px;
    }
    
    .side-table th, .side-table td {
        padding: 8px 10px;
        font-size: 0.8em;
    }
    
    .top-scores-table th, .top-scores-table td {
        padding: 2px 1px;
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .game-container {
        transform: scale(0.7);
        transform-origin: top center;
    }
    
    #game-screen {
        height: 80vh;
    }
    
    .game-area {
        height: calc(80vh - 200px);
    }
    
    .menu-card {
        padding: 20px 15px;
        margin: 10px;
        max-width: 98vw;
        max-height: 98vh;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        overflow-y: auto;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    h2 {
        font-size: 1.8em;
    }
    
    .lektoren-title {
        font-size: 1.6em;
    }
    
    .student-character {
        font-size: 60px;
    }
    
    .student-character-game {
        font-size: 40px;
    }
    
    .falling-word {
        padding: 6px 12px;
        font-size: 0.9em;
    }
    
    .table-left, .table-right {
        width: 10%;
        padding: 5px;
    }
    
    .side-table th, .side-table td {
        padding: 5px 8px;
        font-size: 0.7em;
    }
    
    .top-scores-table th, .top-scores-table td {
        padding: 1px 1px;
        font-size: 0.7em;
    }
    
    .version-list {
        max-height: 200px;
        overflow-y: auto;
    }
    
    .btn-primary, .btn-secondary {
        min-width: 120px;
        padding: 10px 15px;
        font-size: 1em;
    }
}

/* Success and error animations */
.success-flash {
    animation: successFlash 0.5s ease-out;
}

@keyframes successFlash {
    0% { background: #48bb78; }
    100% { background: rgba(255, 255, 255, 0.95); }
}

.error-flash {
    animation: errorFlash 0.5s ease-out;
}

@keyframes errorFlash {
    0% { background: #e53e3e; }
    100% { background: rgba(255, 255, 255, 0.95); }
}
