/* =============================================================================
   Scrabble Web Interface - CSS
   ============================================================================= */

:root {
    --color-bg: #1a1a2e;
    --color-panel: #16213e;
    --color-text: #eee;
    --color-primary: #e94560;
    --color-success: #2ecc71;
    --color-warning: #f39c12;
    --color-secondary: #666;

    /* Bonus colors */
    --color-tw: #e74c3c;
    --color-dw: #9b59b6;
    --color-tl: #3498db;
    --color-dl: #1abc9c;
    --color-center: #f1c40f;
    --color-empty: #27ae60;

    /* Tile colors */
    --color-tile: #d4a574;
    --color-tile-text: #2c1810;
    --color-tile-blank: #8e7cc3;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.title {
    font-size: 2.5rem;
    letter-spacing: 0.1em;
}

.title .letter {
    display: inline-block;
    color: var(--color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: bounce 0.5s ease-in-out;
    animation-delay: calc(var(--i, 0) * 0.1s);
}

.title .letter:nth-child(1) { --i: 0; }
.title .letter:nth-child(2) { --i: 1; }
.title .letter:nth-child(3) { --i: 2; }
.title .letter:nth-child(4) { --i: 3; }
.title .letter:nth-child(5) { --i: 4; }
.title .letter:nth-child(6) { --i: 5; }
.title .letter:nth-child(7) { --i: 6; }
.title .letter:nth-child(8) { --i: 7; }

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

/* Screens */
.screen {
    display: block;
}

.screen.hidden {
    display: none;
}

/* Setup Screen */
.setup-card {
    background: var(--color-panel);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    margin: 2rem auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.setup-card h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #aaa;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text);
    font-size: 1rem;
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
    background: var(--color-secondary);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

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

.btn-warning {
    background: var(--color-warning);
    color: #333;
}

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

/* Scores */
.scores {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.score-card {
    background: var(--color-panel);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-align: center;
    min-width: 150px;
}

.score-card.active {
    border: 2px solid var(--color-primary);
}

.score-card .name {
    font-size: 0.9rem;
    color: #aaa;
}

.score-card .points {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-primary);
}

/* Game Area */
.game-area {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-start;
}

/* Board */
.board-container {
    background: #2d5016;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 2px;
    background: #1a3009;
}

.cell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.cell:hover:not(.has-tile) {
    transform: scale(1.1);
    z-index: 10;
}

/* Bonus cells */
.cell.bonus-TW { background: var(--color-tw); color: white; }
.cell.bonus-DW { background: var(--color-dw); color: white; }
.cell.bonus-TL { background: var(--color-tl); color: white; }
.cell.bonus-DL { background: var(--color-dl); color: white; }
.cell.bonus-\* { background: var(--color-center); color: #333; }
.cell.bonus-\. { background: var(--color-empty); }

/* Tile on cell */
.cell.has-tile {
    background: var(--color-tile) !important;
    color: var(--color-tile-text) !important;
    font-size: 1.1rem;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.cell.has-tile.is-blank {
    background: var(--color-tile-blank) !important;
}

.cell .tile-value {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 0.5rem;
}

/* Preview tiles (when hovering a move) */
.cell.preview {
    background: rgba(255, 255, 0, 0.3) !important;
    animation: pulse 0.5s ease-in-out infinite;
}

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

/* Sidebar */
.sidebar {
    width: 280px;
}

.panel {
    background: var(--color-panel);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel h3 {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.current-turn {
    border-left: 4px solid var(--color-primary);
}

#current-player-name {
    color: var(--color-primary);
}

/* Rack */
.rack {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
}

.rack-tile {
    width: 40px;
    height: 40px;
    background: var(--color-tile);
    color: var(--color-tile-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 4px;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: grab;
    transition: transform 0.1s ease;
}

.rack-tile:hover {
    transform: translateY(-4px);
}

.rack-tile .value {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 0.6rem;
}

.rack-tile.blank {
    background: var(--color-tile-blank);
}

/* Info panel */
.info-item {
    display: flex;
    justify-content: space-between;
}

.info-item .label {
    color: #888;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--color-panel);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--color-primary);
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: white;
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

/* Moves table */
.moves-table {
    width: 100%;
    border-collapse: collapse;
}

.moves-table th,
.moves-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.moves-table th {
    color: #888;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.moves-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.moves-table .btn {
    width: auto;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-panel);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 3000;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.success {
    border-left: 4px solid var(--color-success);
}

.toast.error {
    border-left: 4px solid var(--color-primary);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Game over content */
#gameover-content {
    text-align: center;
}

#gameover-content h2 {
    color: var(--color-success);
    margin-bottom: 1rem;
}

#gameover-content .final-scores {
    margin: 1rem 0;
}

#gameover-content .final-score {
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#gameover-content .winner {
    font-weight: bold;
    color: var(--color-success);
}

/* Responsive */
@media (max-width: 900px) {
    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .sidebar {
        width: 100%;
        max-width: 500px;
    }

    .cell {
        width: 28px;
        height: 28px;
        font-size: 0.55rem;
    }

    .cell.has-tile {
        font-size: 0.9rem;
    }
}
