@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Roboto:wght@400;500;700&display=swap');

:root {
    --tk-bg-dark: #12181e;
    --tk-panel-bg: #f5edd6;
    --tk-panel-border: #8c6a46;
    --tk-gold: #e2a838;
    --tk-gold-dark: #a6731e;
    --tk-header-bg: #222c36;
    --tk-text-dark: #3a2a1a;
    --tk-green-btn: #478426;
    --tk-green-btn-hover: #37681d;
    --tk-red-badge: #ab2828;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background: var(--tk-bg-dark) url('https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?auto=format&fit=crop&w=1920&q=80') fixed center/cover;
    color: var(--tk-text-dark);
    animation: bgPan 40s linear infinite alternate;
}

@keyframes bgPan {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 5px rgba(226, 168, 56, 0.4); }
    50% { box-shadow: 0 0 15px rgba(226, 168, 56, 0.8); }
    100% { box-shadow: 0 0 5px rgba(226, 168, 56, 0.4); }
}

/* --- Autenticación (Login / Register) --- */
.auth-container {
    max-width: 420px;
    margin: 80px auto;
    background: rgba(245, 237, 214, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(226, 168, 56, 0.5);
    border-radius: 16px;
    padding: 35px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.2);
    position: relative;
    animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-container h2 {
    font-family: 'Cinzel', serif;
    text-align: center;
    color: var(--tk-panel-border);
    margin-top: 0;
    font-size: 1.8rem;
    text-shadow: 1px 1px 0px #fff;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    color: #4a3828;
    font-size: 0.9rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 2px solid #b89872;
    background: #faf5e8;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #333;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--tk-gold);
}

.btn {
    background: linear-gradient(180deg, #5b9e32 0%, var(--tk-green-btn) 100%);
    color: #fff;
    border: 1px solid #2d5418;
    padding: 12px 18px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 6px;
    width: 100%;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 3px 6px rgba(0,0,0,0.3);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
    transition: all 0.15s ease;
}

.btn:hover {
    background: linear-gradient(180deg, #4c872a 0%, var(--tk-green-btn-hover) 100%);
    transform: translateY(-1px);
}

/* --- Barra Superior (Top Header) --- */
.top-bar {
    background: linear-gradient(180deg, rgba(44,56,70,0.95) 0%, rgba(34,44,54,0.95) 100%);
    backdrop-filter: blur(12px);
    color: #e0e6ed;
    padding: 12px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--tk-gold);
    box-shadow: 0 6px 15px rgba(0,0,0,0.6);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar strong {
    font-family: 'Cinzel', serif;
    color: var(--tk-gold);
    font-size: 1.1rem;
}

.nav-links a {
    color: #cfd8e3;
    text-decoration: none;
    margin-right: 18px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    transition: background 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(226, 168, 56, 0.2);
    color: var(--tk-gold);
}

.server-badge {
    background: var(--tk-red-badge);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* --- Barra de Recursos Estilo Travian Kingdoms --- */
.resources-strip {
    background: linear-gradient(180deg, rgba(240, 226, 195, 0.9) 0%, rgba(216, 196, 157, 0.9) 100%);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 12px 20px;
    border-bottom: 2px solid var(--tk-panel-border);
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.4), 0 4px 12px rgba(0,0,0,0.2);
    animation: fadeInScale 0.5s ease-out 0.1s both;
}

.res-item {
    background: #faf3e3;
    border: 1px solid #b89c7d;
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.res-item small {
    color: #6e5239;
    font-size: 0.8rem;
}

/* --- Layout Principal --- */
.main-container {
    max-width: 1100px;
    margin: 25px auto;
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 22px;
    padding: 0 15px;
}

.card {
    background: rgba(245, 237, 214, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(140, 106, 70, 0.6);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.3);
    position: relative;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.4);
}

.card h3 {
    font-family: 'Cinzel', serif;
    color: #523b26;
    margin-top: 0;
    border-bottom: 2px solid #c8b293;
    padding-bottom: 8px;
    font-size: 1.3rem;
}

/* --- Tablas y Listas --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th {
    font-family: 'Cinzel', serif;
    color: #5e432a;
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid #b89c7d;
}

td {
    padding: 12px 8px;
    border-bottom: 1px solid #d8c4a8;
    font-size: 0.95rem;
}

.alert {
    padding: 12px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: 0.9rem;
}

/* --- Navegación por Pestañas Travian (Dorf 1 vs Dorf 2) --- */
.view-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.tab-btn {
    background: #4a3319;
    color: #e2a838;
    border: 2px solid #8c6a46;
    padding: 10px 24px;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    font-size: 1.05rem;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active, .tab-btn:hover {
    background: #e2a838;
    color: #2a1f18;
    border-color: #fff;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.5);
}

/* --- Mapa Radial de Recursos (Dorf 1) --- */
.fields-map-container {
    width: 600px;
    height: 500px;
    margin: 0 auto;
    background: #5d8c37 url('https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=800&q=80') center/cover;
    border-radius: 50%;
    border: 8px solid #8c6a46;
    position: relative;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 10px 25px rgba(0,0,0,0.8);
}

.resource-node {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(0,0,0,0.5), inset 0 -4px 8px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(4px);
}

.resource-node:hover {
    transform: scale(1.25) translateY(-5px);
    box-shadow: 0 15px 25px rgba(0,0,0,0.5), 0 0 20px rgba(226, 168, 56, 0.6);
    border-color: #fff;
    z-index: 10;
}

.node-wood { background: #27ae60; color: #fff; }
.node-clay { background: #d35400; color: #fff; }
.node-iron { background: #7f8c8d; color: #fff; }
.node-crop { background: #f1c40f; color: #333; }

.level-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: #222c36;
    color: #e2a838;
    border: 1px solid #e2a838;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Mapa de Infraestructura Urbana (Dorf 2) --- */
.town-map-container {
    width: 600px;
    height: 500px;
    margin: 0 auto;
    background: #d4a76a url('https://images.unsplash.com/photo-1578632767115-351597cf2477?auto=format&fit=crop&w=800&q=80') center/cover;
    border-radius: 50%;
    border: 8px solid #5a3d22;
    position: relative;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.7);
}

.building-node {
    position: absolute;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #faf3e3 0%, #e8d8b5 100%);
    border: 2px solid rgba(140, 106, 70, 0.8);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(0,0,0,0.4), inset 0 2px 5px rgba(255,255,255,0.8);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.building-node:hover {
    transform: scale(1.2) translateY(-5px);
    border-color: #3d7a1e;
    z-index: 10;
    box-shadow: 0 12px 25px rgba(0,0,0,0.5), 0 0 15px rgba(61, 122, 30, 0.4);
}

/* --- Mapa con Visión Circular (Radar / Grid Estático) --- */
.map-circular-viewport {
    width: 650px;
    height: 650px;
    display: grid;
    grid-template-columns: repeat(9, 68px);
    grid-template-rows: repeat(9, 68px);
    gap: 4px;
    background: #1e150c;
    padding: 15px;
    border-radius: 50%;
    border: 6px solid var(--tk-gold);
    box-shadow: 0 0 50px rgba(0,0,0,0.9), inset 0 0 30px rgba(0,0,0,0.8);
    position: relative;
    overflow: hidden;
    clip-path: circle(50% at 50% 50%);
}

.map-tile-iconic {
    background: #5b8c32;
    border: 1px solid #456b24;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.7rem;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s, border-color 0.15s;
    user-select: none;
}

.map-tile-iconic:hover {
    transform: scale(1.1);
    border-color: #fff;
    z-index: 10;
    box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

/* Variaciones por Tipo de Casilla */
.map-tile-iconic.tile-wood { background: #27ae60; border-color: #1e8449; }
.map-tile-iconic.tile-clay { background: #d35400; border-color: #a04000; }
.map-tile-iconic.tile-iron { background: #7f8c8d; border-color: #616a6b; }
.map-tile-iconic.tile-crop { background: #f1c40f; color: #333; border-color: #f39c12; }
.map-tile-iconic.tile-village { background: #8c5a2b; border-color: #5d3a1a; }
.map-tile-iconic.tile-my-village { background: #2d6a1b; border: 2px solid #fff; }
.map-tile-iconic.tile-wonder { background: linear-gradient(135deg, #a6731e 0%, #e2a838 100%); border: 2px solid #fff; }

.tile-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.6rem;
    background: rgba(0,0,0,0.6);
    padding: 1px 3px;
    border-radius: 3px;
}

/* --- Mapa Pantalla Completa con Arrastre (Drag & Drop) y Bloqueo de Bosque --- */
body.fullscreen-map-mode {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    background: #0f0a06;
}

.map-drag-viewport {
    width: 100vw;
    height: 100vh;
    cursor: grab;
    overflow: hidden;
    position: relative;
    user-select: none;
}

.map-drag-viewport:active {
    cursor: grabbing;
}

.map-canvas-grid {
    display: grid;
    grid-template-columns: repeat(11, 75px);
    grid-template-rows: repeat(11, 75px);
    gap: 4px;
    padding: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.05s ease-out;
}

/* Casillas Bloqueadas (Bosque periférico fuera del radio circular) */
.map-tile-blocked {
    background: #17260d !important;
    border: 1px solid #0d1707 !important;
    color: #2d4719 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.map-tile-blocked:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* --- Estilos para la Plaza Central (Rally Point) --- */
.rally-point-container {
    background: #faf3e3;
    border: 2px solid #8c6a46;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.movement-card {
    background: #fff8e7;
    border: 1px solid #b89c7d;
    border-left: 5px solid #27ae60;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.movement-card.incoming-attack {
    border-left-color: #c0392b;
    background: #fdf2f2;
}

.movement-card.outgoing-conquer {
    border-left-color: #8e44ad;
}

.movement-info {
    font-size: 0.9rem;
}

.movement-timer {
    font-weight: bold;
    color: #2c3e50;
    font-family: monospace;
    font-size: 1rem;
    background: #f0e2c3;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #b89c7d;
}

/* --- Viewport con Recorte Radial Circular --- */
.map-drag-viewport {
    width: 100vw;
    height: 100vh;
    cursor: grab;
    overflow: hidden;
    position: relative;
    user-select: none;
    background: #050402; /* Fondo abisal fuera del círculo */
}

/* Máscara Circular sobre la cuadrícula del mapa */
.map-canvas-grid {
    display: grid;
    grid-template-columns: repeat(21, 68px);
    grid-template-rows: repeat(21, 68px);
    gap: 4px;
    padding: 20px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center center;
    transform: translate(-50%, -50%) scale(1);
    transition: transform 0.08s ease-out;
}

/* Casillas Bloqueadas: Bosque Oscuro Fuera del Radio Jugable */
.map-tile-blocked {
    background: radial-gradient(circle, #0e1709 0%, #050a04 100%) !important;
    border: 1px solid #030602 !important;
    color: #1a2a10 !important;
    cursor: not-allowed !important;
    opacity: 0.85;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
}

.map-tile-blocked i {
    color: #0d1708 !important;
    text-shadow: 0 0 5px #000;
}

.map-tile-blocked:hover {
    transform: none !important;
    box-shadow: none !important;
}