/* Ta-te-ti Online - Mobile-first dark theme */

:root {
    --color-bg: #1A1A2E;
    --color-surface: #16213E;
    --color-primary: #E94560;
    --color-secondary: #0F3460;
    --color-text: #EAEAEA;
    --color-text-muted: #888;
    --color-x: #E74C3C;
    --color-o: #3498DB;
    --color-success: #2ECC71;
    --color-error: #E74C3C;
    --transition-speed: 0.3s;
    --border-radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    padding: 20px;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.container {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    text-align: center;
}

/* Typography */
h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.subtitle {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
}

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

.btn-primary:hover {
    background: #d63a52;
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-secondary:hover {
    background: #0d2a4a;
}

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

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

.button-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

/* Inputs */
.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

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

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

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

.code-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
    font-weight: bold;
}

/* Room Code Display */
.room-code-display {
    margin: 2rem 0;
}

.room-code-display p {
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.code {
    font-size: 2.5rem;
    font-weight: bold;
    letter-spacing: 0.5rem;
    color: var(--color-primary);
    background: var(--color-surface);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    display: inline-block;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-secondary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}

.spinner.small {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

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

/* Game Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--color-surface);
    border-radius: var(--border-radius);
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all var(--transition-speed);
}

.player-info.player-x {
    border-color: var(--color-x);
    background: rgba(231, 76, 60, 0.1);
}

.player-info.player-o {
    border-color: var(--color-o);
    background: rgba(52, 152, 219, 0.1);
}

.player-info .symbol {
    font-size: 1.5rem;
}

.player-info .name {
    font-size: 0.875rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-info.player-x .name {
    color: var(--color-x);
}

.player-info.player-o .name {
    color: var(--color-o);
}

.player-info.current {
    transform: scale(1.05);
}

.player-info.current .name {
    font-weight: bold;
}

.vs {
    font-weight: bold;
    color: var(--color-text-muted);
}

/* Turn Indicator */
.turn-indicator {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    margin-bottom: 1rem;
    transition: all var(--transition-speed);
}

.turn-indicator.your-turn {
    background: var(--color-success);
    color: white;
}

.turn-indicator.opponent-turn {
    background: var(--color-secondary);
    color: var(--color-text-muted);
}

/* Game Board */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 280px;
    margin: 0 auto;
}

.cell {
    aspect-ratio: 1;
    width: 100%;
    min-height: 80px;
    background: var(--color-surface);
    border: 2px solid var(--color-secondary);
    border-radius: var(--border-radius);
    font-size: 2.5rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.cell:hover:not(:disabled):not(.taken) {
    border-color: var(--color-primary);
    background: var(--color-secondary);
}

.cell:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.cell.taken {
    cursor: default;
}

.cell.x {
    color: var(--color-x);
    background: rgba(231, 76, 60, 0.15);
    border-color: var(--color-x);
}

.cell.o {
    color: var(--color-o);
    background: rgba(52, 152, 219, 0.15);
    border-color: var(--color-o);
}

.cell.winning {
    animation: pulse 0.5s ease infinite alternate;
    border-color: var(--color-success);
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Abandon Button */
.btn-abandon {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    padding: 8px 16px;
    min-height: 40px;
}

/* Result Screen */
.result-symbol {
    font-size: 4rem;
    margin: 1rem 0;
}

.result-symbol.win {
    animation: bounce 0.5s ease;
}

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

.waiting-rematch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--color-text-muted);
}

/* Error Screen */
#error-message {
    color: var(--color-error);
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (min-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    .board {
        max-width: 320px;
    }

    .cell {
        min-height: 100px;
        font-size: 3rem;
    }
}
