@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;800&display=swap');

:root {
    --bg-color: #0b0d13;
    --card-bg: rgba(20, 24, 35, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --neon-x: #00f0ff;
    --neon-o: #ff007f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(ff, 0, 127, 0.05) 0%, transparent 40%);
}

/* Glass Header */
.glass-header {
    width: 100%;
    max-width: 620px;
    margin-top: 16px;
    padding: 12px 20px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.logo {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 1px;
    white-space: nowrap;
}

.logo span {
    color: var(--neon-x);
}

.scoreboard {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-card .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-card .value {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.2;
}

.x-score .value { color: var(--neon-x); }
.o-score .value { color: var(--neon-o); }

.score-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
}

/* Game Area */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.canvas-wrapper {
    position: relative;
    background: rgba(15, 18, 28, 0.7);
    border-radius: 24px;
    padding: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    transition: box-shadow 0.3s;
}

.canvas-wrapper:has(canvas:hover) {
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

canvas {
    display: block;
    cursor: pointer;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 12px 30px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.02);
}

/* Bottom Sheet Overlay */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 10, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99;
}

.bottom-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    width: 100%;
    max-width: 500px;
    background: #121622;
    border-top: 2px solid var(--border-color);
    border-radius: 30px 30px 0 0;
    padding: 20px 24px 40px;
    transform: translateY(100%);
    transition: transform 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bottom-sheet-overlay.active .bottom-sheet {
    transform: translateY(0);
}

.sheet-win { border-top-color: #ffd700; }
.sheet-lose { border-top-color: #555; }
.sheet-draw { border-top-color: #a855f7; }

.sheet-drag-handle {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    margin-bottom: 20px;
}

.sheet-content {
    text-align: center;
    width: 100%;
}

.sheet-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    background: rgba(255,255,255,0.03);
    border: 2px solid var(--border-color);
    transition: all 0.3s;
}

.sheet-win .sheet-icon {
    background: rgba(255,215,0,0.1);
    border-color: rgba(255,215,0,0.3);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.sheet-lose .sheet-icon {
    background: rgba(100,100,100,0.1);
    border-color: rgba(100,100,100,0.2);
}

.sheet-draw .sheet-icon {
    background: rgba(168,85,247,0.1);
    border-color: rgba(168,85,247,0.3);
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255,215,0,0.2); }
    50% { box-shadow: 0 0 25px rgba(255,215,0,0.5); }
}

#sheet-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 6px;
    transition: color 0.3s;
}

.sheet-win #sheet-title { color: #ffd700; }
.sheet-lose #sheet-title { color: #888; }
.sheet-draw #sheet-title { color: #a855f7; }

#sheet-message {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 24px;
}

.dynamic-btn {
    width: 100%;
    background: var(--text-main);
    color: var(--bg-color);
    border: none;
    font-size: 1rem;
    padding: 14px;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.dynamic-btn:hover {
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255,255,255,0.15);
}

.sheet-win .dynamic-btn {
    background: linear-gradient(135deg, #ffd700, #f59e0b);
    color: #1a1a1a;
}

.sheet-win .dynamic-btn:hover {
    box-shadow: 0 6px 20px rgba(255,215,0,0.4);
}

.sheet-lose .dynamic-btn {
    background: #444;
    color: #ccc;
}

.sheet-lose .dynamic-btn:hover {
    background: #555;
    box-shadow: 0 6px 20px rgba(100,100,100,0.3);
}

.sheet-draw .dynamic-btn {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: #fff;
}

.sheet-draw .dynamic-btn:hover {
    box-shadow: 0 6px 20px rgba(168,85,247,0.4);
}

.screen-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-color); z-index: 100;
}

.lobby-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 36px;
    width: 90%; max-width: 380px;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}

.lobby-card .subtitle {
    color: var(--text-muted); font-size: 0.9rem; margin-bottom: 4px;
}

.input-group { width: 100%; }

.input-group input {
    width: 100%; padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px; color: var(--text-main);
    font-size: 1rem; outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus { border-color: var(--neon-x); }

.action-btn.primary {
    background: var(--neon-x); color: var(--bg-color);
    border: none; width: 100%; padding: 14px; font-weight: 800; font-size: 1rem;
}

.action-btn.secondary {
    width: 100%; padding: 14px; font-size: 1rem;
}

.divider {
    display: flex; align-items: center; width: 100%; gap: 12px;
    color: var(--text-muted); font-size: 0.8rem;
}

.divider::before, .divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}

.error-message {
    color: #ff4444; font-size: 0.85rem; min-height: 1.2em; text-align: center;
}

.room-code-display {
    display: flex; align-items: center; gap: 12px;
    background: rgba(0,0,0,0.3);
    padding: 14px 20px; border-radius: 16px;
    border: 2px solid var(--neon-x);
    font-size: 2rem; font-weight: 800; letter-spacing: 8px;
    color: var(--neon-x); font-family: monospace;
}

.icon-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; padding: 4px; transition: transform 0.2s;
}

.icon-btn:hover { transform: scale(1.2); }

.waiting-dots { display: flex; gap: 8px; margin: 8px 0; }

.waiting-dots .dot {
    width: 10px; height: 10px;
    background: var(--neon-x); border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.waiting-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%,80%,100% { transform: scale(0.5); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.waiting-text { color: var(--text-muted); font-size: 0.9rem; }

.player-info-header {
    display: flex; align-items: center; gap: 8px;
}

.player-tag {
    display: flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px; font-size: 0.8rem;
    transition: border-color 0.3s, background 0.3s;
}

.player-tag.active-turn {
    border-color: var(--neon-x);
    background: rgba(0,240,255,0.05);
}

#player-tag-o.active-turn {
    border-color: var(--neon-o);
    background: rgba(255,0,127,0.05);
}

.player-tag .symbol { font-weight: 800; font-size: 0.9rem; }
#player-tag-x .symbol { color: var(--neon-x); }
#player-tag-o .symbol { color: var(--neon-o); }

.player-tag .name {
    color: var(--text-muted); font-weight: 600;
    max-width: 70px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}

.vs-badge {
    color: var(--text-muted); font-size: 0.65rem;
    font-weight: 700; opacity: 0.5;
}

.turn-indicator {
    text-align: center; margin-top: 8px;
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-muted); transition: color 0.3s;
}

.turn-indicator .turn-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    animation: pulse-dot 1s ease-in-out infinite;
}

.turn-indicator .turn-dot.x-turn { background: var(--neon-x); }
.turn-indicator .turn-dot.o-turn { background: var(--neon-o); }

@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

.game-buttons { display: flex; gap: 10px; }

@media (max-width: 500px) {
    .lobby-card { padding: 24px; }
    .room-code-display { font-size: 1.4rem; letter-spacing: 6px; padding: 10px 14px; }
    .player-info-header { flex-direction: column; gap: 4px; }
    .glass-header { flex-wrap: wrap; justify-content: center; gap: 8px; }
}