/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Accessibility: Screen reader only content */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed; /* Keep background fixed during scroll */
    min-height: 100vh;
    overflow: hidden; /* Prevent scrollbars at body level - screens handle their own scrolling */
    position: relative;
    width: 100%;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    -webkit-touch-callout: none; /* Disable callout on long press */
}

/* Prevent scroll when overlay is open - but keep scrollbar visible */
body.overlay-open {
    overflow: hidden;
    /* Don't use position:fixed as it breaks the background */
}

/* Animated Particles Background */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Build Version Display (temporary) */
.build-version {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

/* Welcome Screen */
.container {
    text-align: center;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(50px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-title {
    font-size: 3.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.game-title .icon {
    font-size: 3rem;
    animation: bounce 2s infinite;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 1))
            drop-shadow(0 0 20px rgba(0, 0, 0, 0.9))
            drop-shadow(0 4px 8px rgba(0, 0, 0, 0.8));
    display: inline-block;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.subtitle {
    font-size: 1.2rem;
    color: #2d3436;
    margin-bottom: 2rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Name Input */
.name-input-container {
    margin-bottom: 2rem;
}

.name-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    text-align: center;
    border: 3px solid #667eea;
    border-radius: 15px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.name-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

.name-input::placeholder {
    color: #999;
    font-weight: 400;
}

/* Menu Options Container */
.all-menu-options {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.menu-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-guess {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    padding: 0.8rem 2rem;
}

.btn-match {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    font-size: 1.1rem;
    padding: 1rem 2rem;
    width: 100%;
}

.btn-match:hover {
    background: linear-gradient(135deg, #fee140 0%, #fa709a 100%);
}

.btn-icon {
    font-size: 1.3rem;
}

/* Join Session Input */
.join-container {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.4s ease;
}

.join-container.hidden {
    display: none;
}

.join-buttons {
    display: flex;
    gap: 1rem;
}

.join-buttons .btn {
    flex: 1;
}

.code-input {
    padding: 1rem;
    font-size: 2rem;
    text-align: center;
    border: 3px solid #667eea;
    border-radius: 15px;
    font-weight: 700;
    letter-spacing: 0.5rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.code-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

/* Game Screen */
.game-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 120px;
    position: relative;
    box-sizing: border-box;
}

/* Game Header */
.game-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.8rem;
    gap: 1rem;
}

.session-info {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.label {
    font-weight: 600;
    color: #495057; /* Improved contrast from #666 to #495057 for better readability */
    font-size: 0.9rem;
}

.session-code {
    font-size: 1.3rem;
    font-weight: 700;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.3rem 1rem;
    border-radius: 10px;
    letter-spacing: 0.2rem;
}

/* Score Board */
.score-board {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.player-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.player-name {
    font-size: 0.95rem;
    color: #666;
    font-weight: 600;
}

.score {
    font-size: 1.6rem;
    font-weight: 700;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 0.3rem 1rem;
    border-radius: 10px;
    min-width: 55px;
    text-align: center;
}

.vs {
    font-weight: 700;
    color: #999;
    font-size: 1.3rem;
}

.round-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.round-info span:last-child {
    font-weight: 700;
    color: #667eea;
}

/* Status Bar */
.status-bar {
    display: flex;
    flex-direction: column;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.8rem;
    gap: 0.8rem;
}

.status-bar-top {
    display: grid;
    grid-template-columns: 150px 1fr 150px;
    align-items: center;
    gap: 1rem;
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.timer {
    font-size: 1.8rem;
    font-weight: 700;
    color: #667eea;
    text-align: center;
}

.timer.warning {
    color: #f5576c;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.timer-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.timer-progress {
    height: 100%;
    background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%);
    transition: width 1s linear;
    border-radius: 10px;
}

.timer-progress.warning {
    background: linear-gradient(90deg, #f5576c 0%, #f093fb 100%);
}

.role-indicator {
    flex: 1;
    text-align: center;
}

.role-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.role-text.drawing {
    color: #43e97b;
}

.role-text.guessing {
    color: #4facfe;
}

.hint-container {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-end;
}

.hint-container.hidden {
    display: none;
}

.hint-label {
    font-size: 0.9rem;
    color: #495057; /* Improved contrast for better readability */
    font-weight: 600;
}

.hint-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: #764ba2;
    letter-spacing: 0.2rem;
    word-break: break-word;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Hide drawing toolbox for guesser */
.drawing-toolbox.hidden {
    display: none !important;
    visibility: hidden !important;
}

/* Chat Window */
.chat-window {
    position: absolute;
    left: -380px;
    top: 0;
    bottom: 120px;
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 5;
    overflow: hidden;
}

.chat-window.hidden {
    display: none !important;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    border-radius: 15px 15px 0 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.chat-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    text-align: center;
}

.chat-placeholder.hidden {
    display: none;
}

.placeholder-icon {
    font-size: 3rem;
    opacity: 0.5;
    margin-bottom: 1rem;
}

.chat-placeholder p {
    margin: 0.3rem 0;
    font-weight: 600;
    font-size: 1rem;
}

.placeholder-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

.chat-message {
    padding: 0.7rem 1rem;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    animation: slideIn 0.3s ease;
}

.chat-message.own {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.other {
    background: #f0f0f0;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message-sender {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    opacity: 0.8;
}

.chat-message-text {
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0 0 15px 15px;
    position: relative;
}

.chat-input {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-emoji-btn {
    width: 45px;
    height: 45px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.3s ease;
}

.chat-emoji-btn:hover {
    transform: scale(1.05);
    border-color: #667eea;
    background: #f8f9fa;
}

.chat-emoji-btn:active {
    transform: scale(0.95);
}

.chat-send-btn {
    width: 45px;
    height: 45px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 1rem;
    right: 1rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    padding: 0.8rem;
    z-index: 100;
    animation: slideUp 0.2s ease;
}

.emoji-picker.hidden {
    display: none;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.3rem;
    text-align: center;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}

/* Game Area */
.game-area {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Drawing Section */
.drawing-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.word-display {
    text-align: center;
    padding: 0.8rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
    animation: slideDown 0.5s ease;
}

.word-display.hidden {
    display: none;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.word-label {
    font-size: 0.8rem;
    opacity: 0.9;
    display: block;
    margin-bottom: 0.3rem;
}

.word {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.2rem;
}

/* Drawing Toolbox - Single Line */
.drawing-toolbox {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    border: 2px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.tool-btn {
    width: 48px;
    height: 48px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.tool-btn:hover {
    background: #f0f0ff;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.tool-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.toolbox-divider {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, transparent, #dee2e6, transparent);
}

.color-strip {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    border: 3px solid transparent;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.color-btn.active {
    transform: scale(1.15);
    border: 3px solid #667eea;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #667eea, 0 3px 10px rgba(102, 126, 234, 0.4);
}

.size-control {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.size-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    white-space: nowrap;
}

.size-slider {
    width: 120px;
    height: 6px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #e0e0e0 0%, #667eea 100%);
    border-radius: 3px;
    outline: none;
}

.size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
}

.size-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.size-value {
    font-weight: 700;
    color: #667eea;
    min-width: 30px;
    text-align: center;
    font-size: 1rem;
    background: #f0f0ff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}

/* Canvas */
#drawingCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 1;
    min-height: 400px;
    max-height: 600px;
    border: 3px solid #667eea;
    border-radius: 15px;
    background: white;
    cursor: crosshair;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: block;
    touch-action: none; /* Prevent touch scrolling/zooming while drawing */
    -webkit-user-select: none; /* Prevent text selection on touch devices */
    user-select: none;
    position: relative;
    z-index: 10;
}

#drawingCanvas.disabled {
    cursor: not-allowed !important;
    opacity: 0.85;
    touch-action: auto;
}

#drawingCanvas.disabled:hover {
    cursor: not-allowed !important;
}

/* Guessing Section */
.guessing-section {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 15px;
}

.guessing-section.hidden {
    display: none;
}

.guess-prompt {
    text-align: center;
}

.guess-prompt h2 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 0.3rem;
}

.guess-subtitle {
    font-size: 0.9rem;
    color: #495057; /* Improved contrast for better readability */
}

.guess-input-container {
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 600px;
}

.guess-input {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.3rem;
    border: 3px solid #667eea;
    border-radius: 15px;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

.guess-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

.guess-feedback {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    padding: 1.2rem 2rem;
    border-radius: 15px;
    font-weight: 600;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    animation: feedbackSlideIn 0.3s ease;
    z-index: 1000;
    pointer-events: none; /* Allow clicking through it */
}

.guess-feedback.hidden {
    display: none;
}

.guess-feedback.wrong {
    background: #ffe0e0;
    color: #f5576c;
    border: 3px solid #f5576c;
}

.guess-feedback.close {
    background: #fff4e0;
    color: #e65100; /* Improved contrast from #ffa726 to #e65100 for WCAG AA compliance */
    border: 3px solid #e65100;
}

.feedback-icon {
    font-size: 2rem;
}

.feedback-text {
    font-size: 1.2rem;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes feedbackSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Waiting Overlay */
.waiting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    z-index: 10;
}

.waiting-overlay.hidden {
    display: none;
}

.waiting-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.waiting-content h2 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 1rem;
}

.waiting-content p {
    font-size: 1.2rem;
    color: #666;
}

.waiting-content strong {
    color: #667eea;
    font-size: 1.5rem;
}

.cancel-search-btn {
    margin-top: 1.5rem;
}

/* Result Overlay */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.result-overlay.hidden {
    display: none;
}

.result-content {
    background: white;
    padding: 2rem;
    border-radius: 30px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-content .btn {
    margin: 0.5rem auto;
    min-width: 200px;
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.result-icon {
    font-size: 3.5rem;
    margin-bottom: 0.8rem;
    animation: bounce 1s infinite;
}

.result-title {
    font-size: 2rem;
    color: #333;
    margin-bottom: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.result-message {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1.2rem;
}

.disconnect-info {
    font-size: 0.9rem;
    color: #999;
    margin-top: 1rem;
    font-style: italic;
}

.rematch-declined-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
    width: 100%;
}

.result-word {
    font-size: 1rem;
    color: #667eea;
    margin-bottom: 1.2rem;
    padding: 0.8rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
}

.result-word strong {
    font-size: 1.4rem;
}

.final-scores {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
}

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.final-score span:first-child {
    font-weight: 600;
    color: #666;
    font-size: 1rem;
    text-align: center;
}

.final-score-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
}

/* Waiting for Player */
.waiting-for-player {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.waiting-for-player.hidden {
    display: none;
}

.waiting-for-player p {
    margin: 0;
    color: #667eea;
    font-weight: 600;
}

.small-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideInRight 0.3s ease;
    min-width: 300px;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success {
    border-left: 5px solid #43e97b;
}

.toast.error {
    border-left: 5px solid #f5576c;
}

.toast.info {
    border-left: 5px solid #4facfe;
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-message {
    flex: 1;
    font-weight: 600;
    color: #333;
}

/* Audio Controls */
.audio-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
    display: flex;
    gap: 10px;
}

.audio-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.audio-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.audio-btn:active {
    transform: scale(0.95);
}

.audio-btn.muted {
    background: rgba(255, 255, 255, 0.5);
    opacity: 0.6;
}

.audio-btn.muted .audio-icon {
    opacity: 0.5;
}

.audio-icon {
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #f0f;
    position: absolute;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Design */

/* Mobile Phones (Portrait) - Up to 480px */
@media (max-width: 480px) {
    /* Hide chat on mobile */
    .chat-window {
        display: none !important;
    }

    /* Welcome Screen */
    .container {
        padding: 1rem 1.5rem;
        width: 95%;
        margin-top: 70px; /* Space for build version and audio buttons */
        margin-bottom: 60px; /* Space for footer */
    }

    .game-title {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .game-title .icon {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    /* Buttons - Larger touch targets for mobile */
    .btn {
        padding: 1.2rem 2rem;
        font-size: 1rem;
        min-height: 55px;
    }

    .code-input {
        font-size: 1.5rem;
        letter-spacing: 0.3rem;
        padding: 0.8rem;
    }

    /* Game Header - Ultra Compact for Mobile */
    .game-header {
        grid-template-columns: 1fr 1fr 1fr;
        text-align: center;
        gap: 0.3rem;
        padding: 0.3rem;
        font-size: 0.7rem;
    }

    .session-info,
    .round-info {
        justify-content: center;
    }

    .session-info .label,
    .round-info .label {
        font-size: 0.65rem;
    }

    .session-code {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    .score-board {
        gap: 0.5rem;
    }

    .player-name {
        font-size: 0.65rem;
    }

    .score {
        font-size: 1rem;
        padding: 0.1rem 0.4rem;
    }

    .vs {
        font-size: 0.8rem;
    }

    /* Status Bar */
    .status-bar {
        gap: 0.8rem;
        padding: 0.8rem;
    }

    .status-bar-top {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 0.8rem;
    }

    .timer-container {
        min-width: 100px;
    }

    .timer {
        font-size: 1.5rem;
    }

    .role-text {
        font-size: 1rem;
    }

    .hint-container {
        align-items: center;
    }

    .hint-text {
        font-size: 1.2rem;
        letter-spacing: 0.2rem;
    }

    /* Drawing Tools */
    .canvas-tools {
        flex-direction: column;
        padding: 0.8rem;
    }

    .tool-group {
        width: 100%;
        justify-content: center;
    }

    .tool-btn {
        width: 55px;
        height: 55px;
        font-size: 1.8rem;
    }

    .size-slider {
        width: 120px;
    }

    /* Color Palette */
    .color-palette {
        padding: 0.8rem;
        gap: 0.8rem;
    }

    .color-btn {
        width: 45px;
        height: 45px;
    }

    /* Canvas */
    #drawingCanvas {
        min-height: 250px;
        max-height: 350px;
        border-width: 2px;
    }

    .word {
        font-size: 1.5rem;
        letter-spacing: 0.1rem;
    }

    /* Guessing Section */
    .guess-prompt h2 {
        font-size: 1.3rem;
    }

    .guess-input-container {
        flex-direction: column;
        gap: 0.8rem;
    }

    .guess-input {
        font-size: 1.1rem;
        padding: 0.9rem 1.2rem;
    }

    .btn-guess {
        padding: 1rem 2rem;
        width: 100%;
    }

    /* Result Overlays */
    .result-content {
        padding: 1.5rem;
        width: 95%;
    }

    .result-icon {
        font-size: 3rem;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .result-message {
        font-size: 0.95rem;
    }

    .result-content .btn {
        min-width: 100%;
        width: 100%;
    }

    .final-scores {
        gap: 2rem;
        flex-direction: column;
    }

    .final-score-value {
        font-size: 2rem;
    }

    /* Toast Notifications - Adjust for mobile */
    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    /* Audio Controls - Move to avoid overlapping */
    .audio-controls {
        top: 10px;
        right: 10px;
        gap: 8px;
    }

    .audio-btn {
        width: 45px;
        height: 45px;
    }

    .audio-icon {
        font-size: 1.3rem;
    }

    /* Game Container */
    .game-container {
        padding: 0.5rem;
        padding-bottom: 100px;
    }

    /* Waiting Overlay */
    .waiting-content h2 {
        font-size: 1.5rem;
    }

    .waiting-content p {
        font-size: 1rem;
    }

    .waiting-content strong {
        font-size: 1.3rem;
    }

    /* Drawing Toolbox - Wrap for mobile */
    .drawing-toolbox {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .toolbox-divider {
        display: none; /* Hide dividers on mobile to save space */
    }

    /* Color Strip - Single line for mobile */
    .color-strip {
        flex-wrap: nowrap;
        justify-content: center;
        gap: 0.3rem;
        max-width: 100%;
    }

    .color-btn {
        width: 22px;
        height: 22px;
        min-width: 22px; /* Prevent shrinking */
        border: 2px solid transparent;
    }

    .color-btn.active {
        border: 2px solid #667eea;
    }

    /* Size Control - Compact for mobile */
    .size-control {
        gap: 0.5rem;
    }

    .size-label {
        font-size: 0.75rem;
    }

    .size-slider {
        width: 80px;
    }

    /* Bottom Ad - In-flow positioning on mobile (not fixed) */
    .bottom-ad-space {
        position: static !important;
        min-height: 35px;
        width: 100%;
        padding: 5px;
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    .ad-space-label {
        font-size: 0.65rem;
    }

    /* Game Container - No extra bottom padding needed since ad is in-flow */
    .game-container {
        padding-bottom: 0.5rem;
    }

    /* Enable scrolling on mobile */
    body {
        overflow-y: auto !important;
        overflow-x: hidden;
    }

    /* Ensure screens can scroll */
    .screen {
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
    }

    /* Footer - Static positioning on mobile (not fixed) */
    .legal-footer {
        position: static !important;
        margin-top: 0;
    }
}

/* Mobile Phones (Landscape) & Small Tablets - 481px to 768px */
@media (min-width: 481px) and (max-width: 768px) {
    /* Hide chat on tablets */
    .chat-window {
        display: none !important;
    }

    /* Welcome Screen */
    .container {
        padding: 2.5rem;
        max-width: 600px;
    }

    .game-title {
        font-size: 2.8rem;
    }

    .game-title .icon {
        font-size: 2.5rem;
    }

    /* Game Header */
    .game-header {
        grid-template-columns: 1fr auto 1fr;
        gap: 1rem;
    }

    .score-board {
        gap: 1.5rem;
    }

    /* Status Bar */
    .status-bar-top {
        grid-template-columns: 120px 1fr 120px;
    }

    /* Canvas */
    #drawingCanvas {
        min-height: 350px;
        max-height: 450px;
    }

    /* Tools */
    .tool-btn {
        width: 52px;
        height: 52px;
    }

    .color-btn {
        width: 42px;
        height: 42px;
    }

    /* Buttons */
    .btn {
        min-height: 50px;
    }

    /* Result Content */
    .result-content {
        max-width: 550px;
    }

    .final-scores {
        gap: 2.5rem;
    }
}

/* Tablets - 769px to 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Hide chat on tablets */
    .chat-window {
        display: none !important;
    }

    .game-container {
        max-width: 1200px;
        padding: 1.5rem;
    }

    #drawingCanvas {
        min-height: 450px;
        max-height: 550px;
    }

    .game-title {
        font-size: 3rem;
    }
}

/* Hide chat on smaller screens */
@media (max-width: 1200px) {
    .chat-window {
        display: none !important;
    }
}

/* Desktop - 1025px and up */
@media (min-width: 1025px) {
    .game-container {
        max-width: 1400px;
    }

    #drawingCanvas {
        min-height: 500px;
        max-height: 600px;
    }

    /* Hover effects only on desktop */
    .btn:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    }

    .tool-btn:hover {
        transform: scale(1.1);
    }

    .color-btn:hover {
        transform: scale(1.2);
    }
}

/* Landscape Mode Detection for Phones */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        padding-bottom: 80px;
    }

    #drawingCanvas {
        min-height: 200px;
        max-height: 300px;
    }

    .game-header {
        padding: 0.5rem;
    }

    .status-bar {
        padding: 0.5rem;
    }

    .result-content {
        max-height: 90vh;
        padding: 1rem;
    }

    .game-title {
        font-size: 2rem;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover,
    .tool-btn:hover,
    .color-btn:hover,
    .audio-btn:hover {
        transform: none;
    }

    /* Increase touch targets */
    .btn {
        min-height: 50px;
    }

    .tool-btn {
        width: 55px;
        height: 55px;
    }

    .color-btn {
        width: 45px;
        height: 45px;
    }

    /* Better tap feedback */
    .btn:active,
    .tool-btn:active,
    .color-btn:active {
        opacity: 0.7;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #drawingCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}


/* Body padding removed - using per-screen padding instead */

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Bottom Ad Space (Game Screen Only) */
.bottom-ad-space {
    position: fixed;
    bottom: 50px;
    left: 0;
    right: 0;
    width: 100%;
    min-height: 100px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 2px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 90;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Show bottom ad only when game screen is active AND game has started */
body.game-in-progress #gameScreen.active ~ .bottom-ad-space {
    display: flex;
}

.ad-space-label {
    font-size: 1rem;
    color: #999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Legal Footer */
.legal-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    text-align: center;
    font-size: 0.85rem;
    color: #666;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.legal-footer a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.legal-footer a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.legal-footer .separator {
    margin: 0 10px;
    color: #999;
}

.legal-footer .copyright {
    color: #999;
}

@media (max-width: 768px) {
    .legal-footer {
        font-size: 0.75rem;
        padding: 10px 15px;
    }

    .legal-footer .separator {
        margin: 0 6px;
    }
}
