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

:root {
	--primary: #7c3aed;
	--primary-dark: #6d28d9;
	--secondary: #06b6d4;
	--accent: #f59e0b;
	--success: #10b981;
	--danger: #ef4444;
	--bg-dark: #1a1a2e;
	--bg-card: #16213e;
	--text: #e5e7eb;
	--text-muted: #9ca3af;
	--border: rgba(255, 255, 255, 0.1);
}

body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	min-height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 20px;
	color: var(--text);
}

.container {
	max-width: 900px;
	width: 100%;
	position: relative;
}

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

.screen.active {
	display: block;
}

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

/* HEADER */
.header {
	text-align: center;
	margin-bottom: 3rem;
}

.header h1 {
	font-size: 3.5rem;
	font-weight: 900;
	color: #fff;
	text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
	margin-bottom: 0.5rem;
}

.subtitle {
	font-size: 1.2rem;
	color: rgba(255, 255, 255, 0.8);
	font-weight: 500;
}

/* INPUT DE NOMBRE */
.name-input-section {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	padding: 2rem;
	margin-bottom: 2rem;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
	text-align: center;
}

.name-input-section label {
	display: block;
	font-size: 1.1rem;
	font-weight: 600;
	margin-bottom: 1rem;
	color: #fff;
}

.name-input-section input {
	width: 100%;
	max-width: 400px;
	padding: 1rem 1.5rem;
	font-size: 1.1rem;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	text-align: center;
	font-weight: 600;
	transition: all 0.3s ease;
}

.name-input-section input:focus {
	outline: none;
	border-color: var(--secondary);
	background: rgba(255, 255, 255, 0.25);
	box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.2);
}

.name-input-section input::placeholder {
	color: rgba(255, 255, 255, 0.5);
}

/* BOTONES */
.btn {
	padding: 1.2rem 2rem;
	font-size: 1.1rem;
	font-weight: 700;
	border: none;
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.3s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
	width: 100%;
}

.btn-primary {
	background: linear-gradient(135deg, var(--primary), var(--primary-dark));
	color: #fff;
}

.btn-primary:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
	background: linear-gradient(135deg, var(--secondary), #0891b2);
	color: #fff;
}

.btn-secondary:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 25px rgba(6, 182, 212, 0.4);
}

.btn-outline {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border: 2px solid rgba(255, 255, 255, 0.3);
	color: #fff;
}

.btn-outline:hover {
	background: rgba(255, 255, 255, 0.25);
	border-color: rgba(255, 255, 255, 0.5);
	transform: translateY(-3px);
}

.btn-small {
	padding: 0.8rem 1.5rem;
	font-size: 0.95rem;
}

/* LOBBY OPTIONS */
.lobby-options {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin-bottom: 2rem;
}

/* BUSCADOR DE SALAS PRIVADAS */
.room-search-section {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	padding: 2rem;
	margin-bottom: 2rem;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
	text-align: center;
}

.room-search-section.hidden {
	display: none;
}

.room-search-section h3 {
	font-size: 1.5rem;
	margin-bottom: 1.5rem;
	color: #fff;
}

.search-input-group {
	display: flex;
	gap: 1rem;
	margin-bottom: 1rem;
	max-width: 500px;
	margin-left: auto;
	margin-right: auto;
}

.search-input-group input {
	flex: 1;
	padding: 1rem 1.5rem;
	font-size: 1rem;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	text-align: center;
	font-weight: 600;
	text-transform: lowercase;
}

.search-input-group input::placeholder {
	color: rgba(255, 255, 255, 0.5);
}

.search-input-group input:focus {
	outline: none;
	border-color: var(--secondary);
	background: rgba(255, 255, 255, 0.25);
}

/* LISTA DE SALAS */
.rooms-list {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	padding: 2rem;
	margin-bottom: 2rem;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.rooms-list.hidden {
	display: none;
}

.rooms-list h3 {
	font-size: 1.5rem;
	margin-bottom: 1.5rem;
	color: #fff;
	text-align: center;
}

.search-filter-group {
	margin-bottom: 1.5rem;
}

.search-filter-group input {
	width: 100%;
	padding: 1rem 1.5rem;
	font-size: 1rem;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	font-weight: 500;
}

.search-filter-group input::placeholder {
	color: rgba(255, 255, 255, 0.5);
}

.search-filter-group input:focus {
	outline: none;
	border-color: var(--secondary);
	background: rgba(255, 255, 255, 0.25);
}

#rooms-container {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin-bottom: 1.5rem;
	max-height: 300px;
	overflow-y: auto;
}

.rooms-actions {
	display: flex;
	gap: 1rem;
	justify-content: center;
}

.room-item {
	background: rgba(255, 255, 255, 0.1);
	border: 2px solid rgba(255, 255, 255, 0.2);
	border-radius: 10px;
	padding: 1.2rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	transition: all 0.3s ease;
	cursor: pointer;
}

.room-item:hover {
	background: rgba(255, 255, 255, 0.2);
	border-color: var(--secondary);
	transform: translateX(5px);
}

.room-info {
	flex: 1;
}

.room-info strong {
	display: block;
	font-size: 1.1rem;
	margin-bottom: 0.3rem;
	color: #fff;
}

.room-info span {
	font-size: 0.9rem;
	color: rgba(255, 255, 255, 0.7);
}

.no-rooms {
	text-align: center;
	color: rgba(255, 255, 255, 0.6);
	font-style: italic;
	padding: 2rem;
}

/* PANTALLA DE ESPERA */
.waiting-content {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border-radius: 20px;
	padding: 3rem;
	text-align: center;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.spinner {
	width: 80px;
	height: 80px;
	border: 6px solid rgba(255, 255, 255, 0.2);
	border-top-color: var(--secondary);
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin: 0 auto 2rem;
}

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

.waiting-content h2 {
	font-size: 2rem;
	margin-bottom: 2rem;
	color: #fff;
}

.room-code-display {
	margin: 2rem 0;
}

.room-code-display p {
	font-size: 1rem;
	color: rgba(255, 255, 255, 0.8);
	margin-bottom: 1rem;
}

.room-code {
	display: inline-block;
	font-size: 2.5rem;
	font-weight: 900;
	font-family: 'Courier New', monospace;
	color: var(--secondary);
	background: rgba(0, 0, 0, 0.3);
	padding: 1rem 2rem;
	border-radius: 12px;
	letter-spacing: 0.3rem;
	margin-bottom: 1rem;
}

.waiting-text {
	color: rgba(255, 255, 255, 0.7);
	margin-bottom: 2rem;
	font-size: 1rem;
}

/* PANTALLA DE JUEGO */
.game-header {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 2rem;
	margin-bottom: 2rem;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	padding: 1.5rem;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.player-info {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.player-info:last-child {
	justify-content: flex-end;
}

.player-symbol {
	width: 60px;
	height: 60px;
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2rem;
	font-weight: 900;
	color: #fff;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.player-info:first-child .player-symbol {
	background: linear-gradient(135deg, #ef4444, #dc2626);
}

.player-info:last-child .player-symbol {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.player-details {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.player-name {
	font-weight: 700;
	font-size: 1.1rem;
	color: #fff;
}

.player-turn {
	font-size: 0.9rem;
	color: var(--accent);
	font-weight: 600;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.player-turn.active {
	opacity: 1;
}

.game-status {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
}

.room-id-small {
	font-size: 0.85rem;
	color: rgba(255, 255, 255, 0.6);
	font-weight: 600;
}

.room-id-small span {
	color: var(--secondary);
	font-family: 'Courier New', monospace;
}

.turn-indicator {
	font-size: 1.2rem;
	font-weight: 700;
	color: #fff;
	padding: 0.5rem 1.5rem;
	background: rgba(245, 158, 11, 0.2);
	border: 2px solid var(--accent);
	border-radius: 20px;
}

/* TABLERO */
.board-container {
	display: flex;
	justify-content: center;
	margin-bottom: 2rem;
}

.board {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 15px;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	padding: 20px;
	border-radius: 20px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
	max-width: 500px;
	width: 100%;
}

.cell {
	aspect-ratio: 1;
	background: rgba(255, 255, 255, 0.2);
	border: 3px solid rgba(255, 255, 255, 0.3);
	border-radius: 15px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 4rem;
	font-weight: 900;
	color: #fff;
	cursor: pointer;
	transition: all 0.3s ease;
	min-height: 100px;
}

.cell:hover:not(.taken) {
	background: rgba(255, 255, 255, 0.3);
	border-color: var(--secondary);
	transform: scale(1.05);
}

.cell.taken {
	cursor: not-allowed;
}

.cell.x {
	color: #ef4444;
	animation: placeX 0.3s ease;
}

.cell.o {
	color: #3b82f6;
	animation: placeO 0.3s ease;
}

@keyframes placeX {
	0% { transform: scale(0) rotate(-180deg); opacity: 0; }
	50% { transform: scale(1.2) rotate(0deg); }
	100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes placeO {
	0% { transform: scale(0) rotate(180deg); opacity: 0; }
	50% { transform: scale(1.2) rotate(0deg); }
	100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.cell.winning {
	background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(5, 150, 105, 0.4));
	border-color: var(--success);
	animation: winPulse 1s ease infinite;
}

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

/* ACCIONES DEL JUEGO */
.game-actions {
	display: flex;
	justify-content: center;
	gap: 1rem;
}

/* OVERLAYS */
.overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.8);
	backdrop-filter: blur(10px);
	display: none;
	justify-content: center;
	align-items: center;
	z-index: 1000;
	animation: fadeIn 0.3s ease;
}

.overlay.show {
	display: flex;
}

.overlay-content {
	background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(109, 40, 217, 0.95));
	border-radius: 20px;
	padding: 3rem;
	text-align: center;
	max-width: 500px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.result-icon {
	font-size: 5rem;
	margin-bottom: 1rem;
}

.overlay-content h2 {
	font-size: 2.5rem;
	margin-bottom: 1rem;
	color: #fff;
}

.overlay-content p {
	font-size: 1.2rem;
	color: rgba(255, 255, 255, 0.9);
	margin-bottom: 2rem;
}

.overlay-actions {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* ESTADO DE CONEXIÓN */
.connection-status {
	position: fixed;
	bottom: 20px;
	right: 20px;
	background: rgba(0, 0, 0, 0.8);
	backdrop-filter: blur(10px);
	padding: 1rem 1.5rem;
	border-radius: 30px;
	display: flex;
	align-items: center;
	gap: 0.8rem;
	color: #fff;
	font-weight: 600;
	font-size: 0.9rem;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
	z-index: 100;
}

.status-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #fbbf24;
	animation: pulse 2s ease infinite;
}

.connection-status.connected .status-dot {
	background: #10b981;
}

.connection-status.disconnected .status-dot {
	background: #ef4444;
	animation: none;
}

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

/* BOTÓN DE VOLVER */
.back-btn {
	display: inline-block;
	color: #fff;
	text-decoration: none;
	font-size: 1rem;
	font-weight: 600;
	padding: 1rem 2rem;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	border-radius: 12px;
	transition: all 0.3s ease;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
	text-align: center;
	display: block;
	margin-top: 2rem;
}

.back-btn:hover {
	background: rgba(255, 255, 255, 0.25);
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* RESPONSIVE */
@media (max-width: 768px) {
	.header h1 {
		font-size: 2.5rem;
	}

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

	.player-info {
		justify-content: center !important;
	}

	.game-status {
		order: -1;
	}

	.board {
		gap: 10px;
		padding: 15px;
	}

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

	.player-symbol {
		width: 50px;
		height: 50px;
		font-size: 1.5rem;
	}
}

@media (max-width: 480px) {
	.header h1 {
		font-size: 2rem;
	}

	.cell {
		font-size: 2.5rem;
		min-height: 70px;
	}

	.btn {
		padding: 1rem 1.5rem;
		font-size: 1rem;
	}

	.overlay-content {
		padding: 2rem;
		margin: 20px;
	}

	.result-icon {
		font-size: 4rem;
	}

	.overlay-content h2 {
		font-size: 2rem;
	}
}
