:root {
    --primary-color: #4a90e2;
    --secondary-color: #50c878;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --canvas-bg: #ffffff;
    --toolbar-bg: #34495e;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Landscape Enforcement */
.portrait-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
    text-align: center;
    padding: 2rem;
}

.portrait-warning i {
    font-size: 5rem;
    margin-bottom: 2rem;
    animation: rotate 2s infinite;
}

.portrait-warning h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.portrait-warning p {
    font-size: 1.2rem;
    opacity: 0.8;
}

@keyframes rotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

@media (orientation: portrait) {
    .portrait-warning {
        display: flex !important;
    }
    
    .game-container,
    .lobby-container {
        display: none !important;
    }
}

/* Lobby Styles */
.lobby-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.lobby-card {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1000px;
    width: 100%;
}

.lobby-card h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.lobby-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* Two-column layout for landscape */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

/* Game Mode Selector */
.game-mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.5rem;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.mode-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(80, 227, 194, 0.1));
}

.mode-btn i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.mode-btn span {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--dark-color);
}

.mode-btn small {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.timer-display {
    text-align: center;
    font-size: 1.8rem;
    color: var(--primary-color);
    font-weight: bold;
    margin: 0.8rem 0;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 44px;
    min-width: 44px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.3);
}

.btn-success {
    background: var(--secondary-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-success:hover {
    background: #45b369;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--light-color);
    overflow: hidden;
}

/* Header */
.game-header {
    background: var(--dark-color);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.game-info {
    display: flex;
    gap: 2rem;
    align-items: center;
}

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

.timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    min-width: 60px;
    text-align: center;
}

.timer.warning {
    color: var(--danger-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.scores {
    display: flex;
    gap: 2rem;
}

.player-score {
    text-align: center;
}

.player-score .name {
    font-size: 0.8rem;
    opacity: 0.8;
}

.player-score .score {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.player-score.active {
    color: var(--warning-color);
}

/* Main Game Area */
.game-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    background: var(--light-color);
    overflow: hidden;
}

.prompt-box {
    background: white;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.prompt-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: nowrap;
}

.prompt-box h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.prompt-box .prompt-word {
    font-size: 2rem;
    font-weight: bold;
    color: var(--dark-color);
    white-space: nowrap;
    display: inline-block;
    flex-shrink: 0;
}

.difficulty-badge {
    display: inline-flex !important;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.difficulty-badge i {
    margin-right: 0.3rem;
}

.difficulty-easy {
    background: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

.difficulty-medium {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffc107;
}

.difficulty-hard {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    overflow: hidden;
}

#drawingCanvas {
    border: 2px solid var(--toolbar-bg);
    border-radius: 5px;
    cursor: crosshair;
    touch-action: none;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Toolbar */
.toolbar {
    width: 260px;
    background: var(--toolbar-bg);
    color: white;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tool-section h3 {
    margin: 0 0 0.6rem 0;
    font-size: 0.95rem;
    color: var(--light-color);
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.color-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.brush-sizes {
    display: flex;
    gap: 0.5rem;
}

.size-btn {
    flex: 1;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.size-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.size-btn.active {
    background: var(--primary-color);
    border-color: white;
}

.tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* AI Preview Box */
.ai-preview {
    margin-top: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.ai-preview-label {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-preview-guess {
    font-size: 1rem;
    font-weight: bold;
    color: var(--secondary-color);
    padding: 0.4rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    text-align: center;
    min-height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn {
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tool-btn.danger {
    background: var(--danger-color);
}

.tool-btn.danger:hover {
    background: #c0392b;
}

/* Ready Screen */
.ready-screen {
    display: none;
    flex: 1;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: white;
    margin: 1rem;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    padding: 3rem;
    text-align: center;
}

.ready-screen.active {
    display: flex;
}

.ready-screen i {
    font-size: 5rem;
    color: var(--secondary-color);
    margin-bottom: 2rem;
    animation: bounce 2s infinite;
}

.ready-screen h2 {
    font-size: 2.5rem;
    color: var(--dark-color);
    margin-bottom: 1rem;
}

.ready-screen p {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.ready-screen .btn-lg {
    font-size: 1.5rem;
    padding: 1.5rem 3rem;
}

/* Waiting Screen */
.waiting-screen {
    display: none;
    flex: 1;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: white;
    margin: 1rem;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.waiting-screen.active {
    display: flex;
}

.waiting-screen i {
    font-size: 5rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
    animation: bounce 2s infinite;
}

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

.waiting-screen h2 {
    font-size: 2rem;
    color: var(--dark-color);
    margin-bottom: 1rem;
}

.waiting-screen p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    white-space: pre-line;
    line-height: 1.6;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 2rem;
}

.modal-content .guess {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--dark-color);
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--light-color);
    border-radius: 10px;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-buttons .btn {
    flex: 1;
}

/* Results Screen */
.round-results-screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    z-index: 100;
}

.round-results-screen h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.round-results-container {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 15px;
    max-width: 600px;
    width: 100%;
    margin-bottom: 2rem;
}

.player-round-result {
    background: rgba(255, 255, 255, 0.2);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    text-align: left;
}

.player-round-result h3 {
    margin: 0 0 1rem 0;
    font-size: 1.3rem;
}

.player-round-result .ai-guess {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0.5rem 0;
    color: #ffd700;
}

.player-round-result .result-status {
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 0.5rem;
}

.player-round-result .result-status.correct {
    color: #2ecc71;
}

.player-round-result .result-status.wrong {
    color: #e74c3c;
}

.results-screen {
    display: none;
    flex: 1;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: white;
    margin: 1rem;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    padding: 3rem;
}

.results-screen.active {
    display: flex;
}

.results-screen h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.winner {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 3rem;
}

.final-scores {
    display: flex;
    gap: 3rem;
    margin-bottom: 3rem;
}

.final-score {
    text-align: center;
}

.final-score .name {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.final-score .score {
    font-size: 4rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Responsive adjustments for tablets */
@media (max-width: 1024px) {
    .toolbar {
        width: 220px;
    }
    
    .game-header {
        padding: 0.8rem 1rem;
    }
}

/* Loading spinner */
.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
