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

body {
    font-family: 'Segoe UI', 'Arial', sans-serif;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}


/* Background pattern overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><circle cx="30" cy="30" r="4"/></g></svg>') repeat;
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 30px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    margin-top: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: block;
}

h1 {
    text-align: center;
    margin-bottom: 15px;
    color: #4a90e2;
    font-size: 2.8rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(74, 144, 226, 0.3);
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #4a90e2;
    font-weight: 600;
    font-size: 1.8rem;
}

p {
    text-align: center;
    margin-bottom: 25px;
    color: #555;
    font-size: 1.1rem;
    line-height: 1.6;
}

.player-setup {
    margin-bottom: 30px;
}

input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 1.1rem;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
}

input[type="text"]:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

input[type="text"]:hover {
    border-color: #9bb5d6;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}


.btn.primary {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.btn.primary:hover {
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}

.btn.secondary {
    background: rgba(240, 240, 240, 0.9);
    color: #333;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn.secondary:hover {
    background: rgba(224, 224, 224, 0.95);
}

.room-code {
    font-size: 2.2rem;
    font-weight: 800;
    color: #4a90e2;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 25px;
    border-radius: 15px;
    display: inline-block;
    border: 2px solid rgba(74, 144, 226, 0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

#room-info {
    text-align: center;
    margin-bottom: 30px;
}

#players-list {
    margin-bottom: 30px;
}

#players-list h3 {
    margin-bottom: 15px;
    color: #4a90e2;
    text-align: center;
}

#players-ul {
    list-style: none;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border: 2px solid rgba(74, 144, 226, 0.1);
}

#players-ul li {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
}

#players-ul li:hover {
    background: rgba(74, 144, 226, 0.05);
}

#players-ul li:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

#players-ul li::before {
    content: '👤';
    font-size: 1.2rem;
}

.category-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 20px;
    background: white;
}

.category-select:focus {
    outline: none;
    border-color: #4a90e2;
}

#category-selection h3 {
    margin-bottom: 10px;
    color: #4a90e2;
    text-align: center;
}

/* Game Screen Styles */
#game-screen {
    background: white;
    padding: 0;
}

/* Hide drawing tools for non-drawers */
.game-content.viewer-mode .drawing-tools {
    display: none;
}

.game-content.viewer-mode #drawing-canvas {
    pointer-events: none;
    border-color: #ccc;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: white;
    padding: 15px 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: relative;
    gap: 15px;
}

/* Drawer mode - green to distinguish from viewer */
.game-header.drawer-mode {
    background: #27ae60 !important;
}

/* Viewer mode - blue */
.game-header.viewer-mode {
    background: #3498db !important;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.drawer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
}

.drawer-icon {
    font-size: 1rem;
}

.word-display {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    flex: 1;
}

.round-info {
    font-size: 1rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 5px;
}

.category-badge {
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255, 215, 0, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid rgba(255, 215, 0, 0.5);
}

.timer-badge {
    font-size: 1.4rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 8px 16px;
    border-radius: 8px;
    min-width: 70px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.timer-badge.warning {
    background: #ffc107;
    color: #000;
}

.timer-badge.danger {
    background: #dc3545;
    color: #fff;
}

.live-scores {
    display: flex;
    gap: 8px;
    align-items: center;
}

.live-score-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
}

.live-score-item.leader {
    background: rgba(255, 215, 0, 0.3);
}

.game-content {
    display: flex;
    min-height: calc(100vh - 120px);
}

.drawing-area {
    flex: 3;
    padding: 10px;
    border-right: 2px solid #e9ecef;
    display: flex;
    flex-direction: column;
}

#drawing-canvas {
    border: 3px solid #e1e5e9;
    border-radius: 15px;
    cursor: crosshair;
    display: block;
    margin: 0 auto;
    width: 100%;
    height: calc(100vh - 200px);
    max-height: 600px;
    min-height: 300px;
    background: white;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    position: relative;
}

#drawing-canvas:hover {
    border-color: #4a90e2;
    box-shadow: 0 8px 30px rgba(74, 144, 226, 0.2);
}

#drawing-canvas.drawing-active {
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

.drawing-area {
    position: relative;
}

.drawing-area::before {
    content: '🎨 Teiknisvæði';
    position: absolute;
    top: -10px;
    left: 20px;
    background: linear-gradient(135deg, #4a90e2, #357abd);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10;
}

.drawing-tools {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

.tool-divider {
    width: 2px;
    height: 30px;
    background: linear-gradient(180deg, transparent, #ccc, transparent);
    margin: 0 5px;
}

.tool-btn {
    padding: 10px 18px;
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    position: relative;
    overflow: hidden;
}

.tool-btn:hover {
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
    border-color: #4a90e2;
}

.tool-btn.active {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    color: white;
    border-color: #357abd;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
}

.tool-btn.active::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 8px #4ade80;
}

#color-picker {
    width: 45px;
    height: 45px;
    border: 3px solid #e1e5e9;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#color-picker:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.brush-label {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 15px;
    border-radius: 10px;
    border: 2px solid #e1e5e9;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.brush-label span:first-child {
    color: #4a90e2;
}

#brush-size {
    width: 100px;
    cursor: pointer;
}

#brush-size-display {
    min-width: 20px;
    text-align: center;
    color: #4a90e2;
    font-weight: 700;
}

.guessing-area {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.guessing-area::before {
    content: '💬 Giskanir';
    font-size: 1.1rem;
    font-weight: 700;
    color: #4a90e2;
    margin-bottom: 15px;
}

.guesses {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    overflow-y: auto;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
    border: 2px solid #e9ecef;
}

.guess-item {
    margin-top: 10px;
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    border-left: 4px solid;
}

.guess-item.correct {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left-color: #28a745;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.guess-item.incorrect {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
}

.guess-input {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.guess-input input {
    flex: 1;
    margin-bottom: 0;
    border: 2px solid #e1e5e9;
    padding: 14px 18px;
    font-size: 1rem;
}

.guess-input input:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.guess-input .btn {
    min-width: 100px;
}

.scoreboard {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 25px;
    margin: 0 20px 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 2px solid rgba(74, 144, 226, 0.1);
}

.scoreboard h3 {
    margin-bottom: 20px;
    color: #4a90e2;
    font-size: 1.3rem;
    text-align: center;
    position: relative;
    padding-bottom: 10px;
}

.scoreboard h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #4a90e2, transparent);
    border-radius: 2px;
}

#scores-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

#scores-list li {
    background: white;
    padding: 12px 20px;
    border-radius: 10px;
    border-left: 4px solid #4a90e2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-weight: 600;
    color: #333;
}

#scores-list li:hover {
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.2);
}

#scores-list li:first-child {
    border-left-color: #ffd700;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

#scores-list li:first-child::before {
    content: '🏆 ';
}

/* Popup Styles */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup.hidden {
    display: none;
}

.popup-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 2px solid rgba(74, 144, 226, 0.2);
}

/* Big success popup */
.popup.big-success .popup-content {
    max-width: 600px;
    padding: 60px 80px;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 4px solid #28a745;
}

.big-success-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #155724;
    margin-bottom: 20px;
}

.big-success-word {
    font-size: 4rem;
    font-weight: 800;
    color: #28a745;
    text-transform: uppercase;
    letter-spacing: 4px;
}

/* Timeout popup */
.popup.timeout-popup .popup-content {
    max-width: 600px;
    padding: 60px 80px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border: 4px solid #ffc107;
}

.timeout-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #856404;
    margin-bottom: 10px;
}

.timeout-subtitle {
    font-size: 1.2rem;
    color: #856404;
    margin-bottom: 10px;
}

.timeout-word {
    font-size: 4rem;
    font-weight: 800;
    color: #d39e00;
    text-transform: uppercase;
    letter-spacing: 4px;
}

.popup-content p {
    font-size: 1.1rem;
    margin-bottom: 25px;
    color: #333;
}

/* Loading states */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.canvas-success {
    box-shadow: 0 0 40px rgba(74, 222, 128, 0.6);
    border-color: #4ade80;
}

/* Tooltips */
[title] {
    position: relative;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 3px solid #4a90e2;
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection color */
::selection {
    background: #4a90e2;
    color: white;
}

/* Game Finished Screen */
#final-scores {
    margin: 30px 0;
}

#final-scores h3 {
    text-align: center;
    color: #4a90e2;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

#final-scores-list {
    list-style: none;
    padding: 0;
}


/* Responsive Design */
@media (max-width: 1200px) {
    .game-content {
        flex-direction: column;
        height: calc(100vh - 80px);
    }

    .drawing-area {
        border-right: none;
        border-bottom: 2px solid #e9ecef;
        padding: 5px;
        flex: 1;
    }

    #drawing-canvas {
        width: 100%;
        height: 60vh;
        min-height: 250px;
        max-height: none;
    }

    .guessing-area {
        height: 25vh;
        min-height: 150px;
        padding: 5px;
    }

    .guesses {
        height: calc(25vh - 60px);
        min-height: 90px;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 15px;
    }

    .header-left, .header-right {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        width: 100%;
    }

    .drawer-info {
        font-size: 0.95rem;
        padding: 8px 15px;
    }

    .word-display {
        font-size: 1.2rem;
    }

    .round-info {
        font-size: 1rem;
    }

    .live-scores {
        width: 100%;
        justify-content: flex-start;
    }

    .live-score-item {
        font-size: 0.85rem;
        padding: 5px 10px;
    }
}

@media (max-width: 768px) {
    .drawing-area {
        padding: 5px;
    }

    #drawing-canvas {
        height: 250px;
    }

    .guessing-area {
        padding: 5px;
        max-height: 180px;
    }

    .guesses {
        max-height: 100px;
        font-size: 0.9rem;
    }

    .menu-buttons {
        flex-direction: column;
    }

    h1 {
        font-size: 2rem;
    }

    .drawing-tools {
        justify-content: space-around;
        flex-wrap: wrap;
        margin-top: 5px;
    }

    .tool-btn {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    #drawing-canvas {
        height: 200px;
    }

    .game-header {
        padding: 5px;
    }

    .word-display, .round-info {
        font-size: 0.9rem;
    }

    .timer {
        font-size: 1.2rem;
        padding: 3px 10px;
    }
}