/* ============================================
   DRAW & GUESS ONLINE - STYLES
   Mobile-first, dark theme
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --color-bg: #1a1a2e;
    --color-card: #16213e;
    --color-primary: #e94560;
    --color-primary-hover: #ff6b6b;
    --color-secondary: #0f3460;
    --color-text: #ffffff;
    --color-text-dim: #a0a0a0;
    --color-correct: #4ade80;
    --color-timer-warn: #fbbf24;
    --color-timer-danger: #f87171;
    --color-drawer: #8b5cf6;
    --color-guessed: #4ade80;
    --canvas-bg: #ffffff;
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

.screen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
}

/* ============================================
   LOGO
   ============================================ */
.logo {
    text-align: center;
    margin-bottom: 20px;
}

.logo-emoji {
    font-size: 64px;
    display: block;
    margin-bottom: 10px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.tagline {
    color: var(--color-text-dim);
    font-size: 14px;
    margin-top: 4px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    width: 100%;
    max-width: 300px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--color-text-dim);
    margin-bottom: 6px;
}

input[type="text"] {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--color-secondary);
    border-radius: var(--border-radius);
    background: var(--color-card);
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-speed);
}

input[type="text"]:focus {
    border-color: var(--color-primary);
}

input[type="text"]::placeholder {
    color: var(--color-text-dim);
}

.code-input {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 8px;
    text-transform: uppercase;
}

/* ============================================
   BUTTONS
   ============================================ */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    min-height: 48px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
}

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

.btn-secondary:hover:not(:disabled) {
    background: #1a4a7a;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-dim);
    border: 1px solid var(--color-text-dim);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--color-text);
    border-color: var(--color-text);
}

.btn-small {
    padding: 10px 16px;
    font-size: 14px;
    min-height: 40px;
}

.btn-icon {
    font-size: 18px;
}

.help-text {
    font-size: 13px;
    color: var(--color-text-dim);
    text-align: center;
}

/* ============================================
   ROOM CODE
   ============================================ */
.room-code-container {
    text-align: center;
    margin: 10px 0;
}

.room-code-label {
    font-size: 14px;
    color: var(--color-text-dim);
    margin-bottom: 8px;
}

.room-code {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--color-primary);
    font-family: monospace;
}

.share-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================
   PLAYERS LIST (Waiting Screen)
   ============================================ */
.players-section {
    width: 100%;
    max-width: 300px;
}

.players-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.players-list {
    list-style: none;
    background: var(--color-card);
    border-radius: var(--border-radius);
    padding: 8px;
}

.players-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
}

.players-list li.host {
    background: rgba(233, 69, 96, 0.1);
}

.player-icon {
    font-size: 20px;
}

.player-name {
    flex: 1;
    font-weight: 500;
}

.host-badge {
    font-size: 12px;
    background: var(--color-primary);
    padding: 2px 8px;
    border-radius: 10px;
}

.waiting-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

/* ============================================
   WORD SELECTION
   ============================================ */
.word-select-subtitle {
    color: var(--color-text-dim);
    margin-bottom: 10px;
}

.word-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.word-option {
    padding: 20px;
    font-size: 20px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--color-card);
    border: 2px solid var(--color-secondary);
    border-radius: var(--border-radius);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.word-option:hover {
    border-color: var(--color-primary);
    background: var(--color-secondary);
}

/* ============================================
   GAME HEADER
   ============================================ */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-secondary);
}

.timer-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-secondary);
}

.timer {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.timer.warn {
    color: var(--color-timer-warn);
}

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

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

.round-info {
    font-size: 14px;
    color: var(--color-text-dim);
}

.round-divider {
    margin: 0 4px;
}

.word-hint {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 4px;
    font-family: monospace;
}

.word-hint.drawer {
    color: var(--color-drawer);
}

/* ============================================
   CANVAS
   ============================================ */
.canvas-container {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a15;
    overflow: hidden;
}

#canvas {
    background: var(--canvas-bg);
    touch-action: none;
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: var(--color-text);
}

.overlay-emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

/* ============================================
   DRAWING TOOLS
   ============================================ */
.tools-container {
    padding: 10px;
    background: var(--color-card);
    border-top: 1px solid var(--color-secondary);
}

.tools-container.hidden {
    display: none;
}

.tools-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--color-secondary);
    border-radius: 8px;
    background: var(--color-bg);
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    border-color: var(--color-text-dim);
}

.tool-btn.active {
    border-color: var(--color-primary);
    background: var(--color-secondary);
}

.color-picker {
    display: flex;
    gap: 4px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-speed);
}

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

.color-btn.active {
    border-color: var(--color-text);
    transform: scale(1.15);
}

/* ============================================
   GAME BOTTOM (Scores + Chat)
   ============================================ */
.game-bottom {
    display: flex;
    flex-direction: column;
    max-height: 40%;
    background: var(--color-card);
}

.scores-panel {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-secondary);
}

.scores-panel h4 {
    font-size: 12px;
    color: var(--color-text-dim);
    margin-bottom: 6px;
}

.scores-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scores-list li {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 4px 8px;
    background: var(--color-bg);
    border-radius: 16px;
}

.scores-list .drawer {
    border: 1px solid var(--color-drawer);
}

.scores-list .drawer::after {
    content: '✏️';
    font-size: 11px;
}

.scores-list .guessed {
    border: 1px solid var(--color-guessed);
}

.scores-list .guessed::after {
    content: '✅';
    font-size: 11px;
}

.score-value {
    font-weight: 600;
    color: var(--color-primary);
}

/* ============================================
   CHAT
   ============================================ */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message {
    font-size: 13px;
    padding: 4px 0;
}

.chat-message .sender {
    font-weight: 600;
    color: var(--color-text-dim);
}

.chat-message.correct {
    background: rgba(74, 222, 128, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--color-correct);
    font-weight: 600;
}

.chat-message.system {
    color: var(--color-text-dim);
    font-style: italic;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--color-secondary);
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--color-secondary);
    border-radius: 20px;
    background: var(--color-bg);
    color: var(--color-text);
    outline: none;
}

#chat-input:focus {
    border-color: var(--color-primary);
}

#chat-input:disabled {
    opacity: 0.5;
}

.btn-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--color-primary);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-send:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   ROUND END
   ============================================ */
.correct-word-container {
    text-align: center;
}

.correct-word-container p {
    color: var(--color-text-dim);
    margin-bottom: 8px;
}

.correct-word {
    font-size: 36px;
    font-weight: 700;
    color: var(--color-correct);
    text-transform: uppercase;
}

.round-points {
    width: 100%;
    max-width: 300px;
    background: var(--color-card);
    border-radius: var(--border-radius);
    padding: 12px;
}

.round-points .point-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-secondary);
}

.round-points .point-item:last-child {
    border-bottom: none;
}

.round-points .points {
    color: var(--color-correct);
    font-weight: 600;
}

.next-round-text {
    color: var(--color-text-dim);
    font-size: 14px;
}

/* ============================================
   FINISHED (Final Ranking)
   ============================================ */
.final-ranking {
    width: 100%;
    max-width: 300px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-card);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.ranking-item.first {
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
    color: #1a1a2e;
}

.ranking-item.second {
    background: linear-gradient(135deg, #c0c0c0 0%, #808080 100%);
    color: #1a1a2e;
}

.ranking-item.third {
    background: linear-gradient(135deg, #cd7f32 0%, #8b4513 100%);
    color: #1a1a2e;
}

.ranking-position {
    font-size: 24px;
    font-weight: 700;
    width: 40px;
    text-align: center;
}

.ranking-name {
    flex: 1;
    font-weight: 600;
}

.ranking-score {
    font-size: 18px;
    font-weight: 700;
}

/* ============================================
   ERROR SCREEN
   ============================================ */
.error-icon {
    font-size: 64px;
    margin-bottom: 10px;
}

#error-title {
    color: var(--color-primary);
}

#error-message {
    color: var(--color-text-dim);
    text-align: center;
    max-width: 280px;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-card);
    color: var(--color-text);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.toast.success {
    background: var(--color-correct);
    color: #1a1a2e;
}

/* ============================================
   RESPONSIVE - Tablet and Up
   ============================================ */
@media (min-width: 768px) {
    .screen-content {
        padding: 40px;
    }

    .logo-emoji {
        font-size: 80px;
    }

    .logo h1 {
        font-size: 36px;
    }

    .room-code {
        font-size: 64px;
    }

    .game-bottom {
        flex-direction: row;
        max-height: 30%;
    }

    .scores-panel {
        width: 200px;
        border-bottom: none;
        border-right: 1px solid var(--color-secondary);
    }

    .scores-list {
        flex-direction: column;
    }

    .chat-panel {
        flex: 1;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-secondary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-dim);
}
