/* ============================================
   PlayDuo - Mini Games 2 Người Chơi
   Premium dark gaming aesthetic
   ============================================ */

/* === VARIABLES === */
:root {
    --bg-deep: #060a13;
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2235;

    --surface: rgba(17, 24, 39, 0.7);
    --surface-border: rgba(56, 189, 248, 0.08);
    --surface-hover: rgba(25, 35, 55, 0.9);

    --accent-cyan: #22d3ee;
    --accent-cyan-bright: #67e8f9;
    --accent-cyan-dim: rgba(34, 211, 238, 0.12);
    --accent-cyan-glow: rgba(34, 211, 238, 0.25);

    --accent-orange: #fb923c;
    --accent-orange-bright: #fdba74;
    --accent-orange-dim: rgba(251, 146, 60, 0.12);
    --accent-orange-glow: rgba(251, 146, 60, 0.25);

    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-gold: #fbbf24;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
}

a { color: var(--accent-cyan); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* === BACKGROUND EFFECTS === */
.bg-effects {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: orbFloat 25s ease-in-out infinite alternate;
}

.orb-1 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--accent-cyan-glow), transparent 70%);
    top: -15%; left: -10%;
}

.orb-2 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, var(--accent-orange-glow), transparent 70%);
    bottom: -15%; right: -10%;
    animation-delay: -12s;
    animation-direction: alternate-reverse;
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
    100% { transform: translate(10px, -10px) scale(1.02); }
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
}

/* === LAYOUT === */
#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
}

.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
}

.view {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    opacity: 0;
    transition: opacity 0.35s var(--ease);
}

.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* === GLASS CARD === */
.glass-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* === BUTTONS === */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.25s var(--ease);
    width: 100%;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), #0891b2);
    color: #0a0f1a;
    box-shadow: 0 4px 20px var(--accent-cyan-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--accent-cyan-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
}
.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}
.btn-danger:hover {
    background: rgba(248, 113, 113, 0.2);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    width: auto;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    transition: color 0.2s;
}
.btn-back:hover { color: var(--accent-cyan); }

/* === INPUTS === */
input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
    outline: none;
}
input[type="text"]::placeholder { color: var(--text-muted); }
input[type="text"]:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-dim);
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.hero-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-text {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan-bright));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
}

.section-title {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.game-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(10px);
    padding: 1.75rem;
    text-align: center;
}

.game-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px var(--accent-cyan-glow);
    border-color: var(--accent-cyan);
}

.game-card-icon {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.game-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.game-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.accent { color: var(--accent-cyan); -webkit-text-fill-color: var(--accent-cyan); }

.lobby-title {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.lobby-name-section {
    margin-bottom: 1.5rem;
}

.input-label { font-size: 1rem; }

.lobby-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.lobby-card {
    text-align: center;
}

.lobby-card-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.lobby-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

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

.config-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: block;
}

.room-code-input {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.action-icon { font-size: 2rem; margin-bottom: 0.5rem; }

.action-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.size-selector {
    margin-bottom: 1rem;
}

.size-options {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.size-btn {
    flex: 1;
    padding: 0.6rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s var(--ease);
}

.size-btn:hover { border-color: var(--accent-cyan); color: var(--text-primary); }

.size-btn.active {
    background: var(--accent-cyan-dim);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.code-input-group { margin-bottom: 1rem; }

#room-code-input {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.divider-or {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}
.divider-or::before, .divider-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--surface-border);
}

/* ===== WAITING VIEW ===== */
.waiting-content {
    text-align: center;
    width: 100%;
    max-width: 420px;
}

.waiting-anim {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent-cyan);
    opacity: 0;
    animation: pulseRing 2.5s ease-out infinite;
}
.pulse-ring.r2 { animation-delay: 0.8s; }
.pulse-ring.r3 { animation-delay: 1.6s; }

@keyframes pulseRing {
    0% { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}

.waiting-emoji {
    font-size: 2.5rem;
    animation: floatBounce 2s ease-in-out infinite;
}

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

.waiting-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.waiting-sub {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.room-code-box {
    text-align: center;
    margin-bottom: 2rem;
}

.code-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.code-value {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    color: var(--accent-cyan);
    text-shadow: 0 0 30px var(--accent-cyan-glow);
    margin-bottom: 1rem;
    font-variant-numeric: tabular-nums;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--accent-cyan-dim);
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-cyan);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}
.btn-copy:hover { background: rgba(34, 211, 238, 0.2); }

.slots-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    min-width: 120px;
}

.slot.filled { border-color: var(--accent-green); }

.slot-avatar { font-size: 1.8rem; }

.pulse-opacity { animation: pulseOp 1.5s ease-in-out infinite; }
@keyframes pulseOp {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.slot-name {
    font-size: 0.85rem;
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.slot-badge.online {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
}
.slot-badge.waiting {
    background: rgba(251, 191, 36, 0.15);
    color: var(--accent-gold);
}

.vs-badge {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text-muted);
}

/* ===== GAME VIEW ===== */
.game-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    backdrop-filter: blur(20px);
    z-index: 10;
    flex-shrink: 0;
}

.player-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    transition: all 0.3s var(--ease);
    min-width: 0;
}

.player-panel.active-turn {
    background: var(--accent-cyan-dim);
    box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.player-panel.p2.active-turn {
    background: var(--accent-orange-dim);
    box-shadow: 0 0 15px var(--accent-orange-glow);
}

.panel-piece {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.piece-x {
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.piece-o {
    background: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange-glow);
}

.panel-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-info.right { align-items: flex-end; }

.panel-name {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.panel-status {
    font-size: 0.7rem;
    color: var(--accent-green);
    font-weight: 500;
}

.panel-status.disconnected { color: var(--accent-red); }

.turn-indicator {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 1px solid var(--surface-border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-cyan);
    white-space: nowrap;
    flex-shrink: 0;
}

.turn-indicator.your-turn {
    background: var(--accent-cyan-dim);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan-bright);
    animation: glowPulse 1.5s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 10px var(--accent-cyan-glow); }
    50% { box-shadow: 0 0 25px var(--accent-cyan-glow); }
}

/* ===== ZOOM CONTROLS ===== */
.zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    flex-shrink: 0;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--surface-border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.zoom-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }

.zoom-input {
    width: 52px;
    height: 32px;
    text-align: center;
    border: 1px solid var(--surface-border);
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    -moz-appearance: textfield;
}
.zoom-input::-webkit-outer-spin-button,
.zoom-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.zoom-input:focus { border-color: var(--accent-cyan); }

.zoom-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.board-area {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    padding: 0.75rem;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.board {
    display: grid;
    gap: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--surface-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    position: relative;
}

.cell {
    width: var(--cell-size, 36px);
    height: var(--cell-size, 36px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 163, 184, 0.06);
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.cell:hover:not(.filled) {
    background: rgba(34, 211, 238, 0.06);
}

.cell.filled { cursor: default; }

.cell.last-move {
    background: rgba(251, 191, 36, 0.1);
    box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.3);
}

.cell.win-cell {
    background: rgba(52, 211, 153, 0.15);
    animation: winGlow 0.8s ease-in-out infinite alternate;
}

@keyframes winGlow {
    0% { background: rgba(52, 211, 153, 0.1); }
    100% { background: rgba(52, 211, 153, 0.25); }
}

.cell .piece {
    width: 65%;
    height: 65%;
    border-radius: 50%;
    transform: scale(0);
    animation: piecePlace 0.25s var(--ease-bounce) forwards;
}

@keyframes piecePlace {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.cell .piece.p1 {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.cell .piece.p2 {
    background: var(--accent-orange);
    box-shadow: 0 0 8px var(--accent-orange-glow);
}

.game-bottombar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--surface-border);
    backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.room-tag {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== WIN LINE ===== */
.win-line-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
}

.win-line {
    stroke: var(--accent-green);
    stroke-width: 5;
    stroke-linecap: round;
    filter: drop-shadow(0 0 10px rgba(52, 211, 153, 0.7));
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawWinLine 0.5s ease forwards 0.15s;
}

@keyframes drawWinLine {
    to { stroke-dashoffset: 0; }
}

/* ===== RESULT OVERLAY ===== */
#game-result-overlay {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 50;
}

.result-modal {
    text-align: center;
    padding: 2.5rem 2rem;
    max-width: 360px;
    width: 90%;
    animation: resultSlideIn 0.4s var(--ease-bounce);
}

@keyframes resultSlideIn {
    0% { transform: scale(0.7) translateY(30px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 0.75rem;
    animation: resultBounce 0.6s var(--ease-bounce);
}

@keyframes resultBounce {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.result-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 0.4rem;
}

.result-title.win { color: var(--accent-green); }
.result-title.lose { color: var(--accent-red); }
.result-title.draw { color: var(--accent-gold); }

.result-msg {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s;
}

.overlay.hidden { display: none; }

.overlay-box {
    text-align: center;
    padding: 2rem;
    max-width: 320px;
}

.overlay-box h3 {
    margin-top: 1rem;
    font-size: 1.1rem;
}

.overlay-box p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.35s var(--ease-bounce);
    pointer-events: auto;
    backdrop-filter: blur(20px);
}

.toast.error {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(127, 29, 29, 0.5);
}

.toast.success {
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(6, 78, 59, 0.5);
}

.toast.fade-out {
    animation: toastOut 0.3s var(--ease) forwards;
}

@keyframes toastIn {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(100%); opacity: 0; }
}

/* ===== LOADING STATE ===== */
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading span { visibility: hidden; }

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container { padding: 1rem; }

    .logo-text { font-size: 2.2rem; }
    .subtitle { font-size: 0.85rem; }

    .game-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lobby-actions {
        grid-template-columns: 1fr;
    }

    .glass-card { padding: 1.25rem; }

    .panel-name { max-width: 60px; font-size: 0.75rem; }
    .turn-indicator { font-size: 0.7rem; padding: 0.3rem 0.6rem; }

    .result-icon { font-size: 3.5rem; }
    .result-title { font-size: 1.5rem; }
}

@media (min-width: 641px) {
    .lobby-actions {
        flex-direction: row;
        align-items: stretch;
    }
    .lobby-actions > .action-card { flex: 1; }
    .divider-or {
        flex-direction: column;
        width: auto;
    }
    .divider-or::before, .divider-or::after {
        width: 1px;
        height: auto;
        flex: 1;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
