* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #05050a;
    font-family: 'Orbitron', sans-serif;
    overflow: hidden;
}

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.game-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 25px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 340px;
    gap: 15px;
}

h1 {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    text-align: center;
    letter-spacing: 2px;
}

h1 span {
    color: #0ff;
    text-shadow: 0 0 20px #0ff, 0 0 40px #0ff;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 900;
    color: #0ff;
    text-shadow: 0 0 15px #0ff;
}

.stat-label {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 2px;
}

.best-score {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 2px;
}

.best-score span {
    color: #f0f;
    text-shadow: 0 0 10px rgba(255,0,255,0.5);
}

.grid-wrapper {
    position: relative;
    padding: 3px;
    border-radius: 24px;
    background: linear-gradient(135deg, #0ff, #f0f, #0ff);
    box-shadow: 0 0 30px rgba(0,255,255,0.3), 0 0 60px rgba(255,0,255,0.2);
}

.grid-container {
    position: relative;
    width: 320px;
    height: 320px;
    background: linear-gradient(180deg, #0a0a15 0%, #050510 100%);
    border-radius: 22px;
    overflow: hidden;
}

.grid-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 30% 30%, rgba(0,255,255,0.05) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(255,0,255,0.05) 0%, transparent 50%);
    pointer-events: none;
}

#linesCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.dots-grid {
    display: grid;
    width: 100%;
    height: 100%;
    padding: 35px;
    position: relative;
    z-index: 1;
}

.dot {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.dot-inner {
    width: 28px;
    height: 28px;
    background: radial-gradient(circle, #1a1a2e 0%, #0a0a15 100%);
    border: 2px solid rgba(0,255,255,0.6);
    border-radius: 50%;
    position: relative;
    transition: all 0.15s ease;
    box-shadow: 
        0 0 15px rgba(0,255,255,0.3),
        inset 0 0 10px rgba(0,255,255,0.1);
}

.dot-inner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #0ff;
    border-radius: 50%;
    box-shadow: 0 0 10px #0ff;
    opacity: 0.8;
}

.dot:hover .dot-inner {
    transform: scale(1.1);
    border-color: #0ff;
}

.dot.active .dot-inner {
    background: radial-gradient(circle, #0ff 0%, #066 100%);
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 25px #0ff, 0 0 50px rgba(0,255,255,0.5);
}

.dot.active .dot-inner::after {
    background: #fff;
    box-shadow: 0 0 15px #fff;
}

/* Punto inicio - Verde */
.dot.start .dot-inner {
    border-color: #0f0;
    box-shadow: 0 0 20px rgba(0,255,0,0.5), inset 0 0 15px rgba(0,255,0,0.2);
    animation: glow-green 2s ease-in-out infinite;
}

.dot.start .dot-inner::after {
    background: #0f0;
    box-shadow: 0 0 12px #0f0;
    width: 10px;
    height: 10px;
}

/* Punto final - Rojo/Magenta */
.dot.end .dot-inner {
    border-color: #f0f;
    box-shadow: 0 0 20px rgba(255,0,255,0.5), inset 0 0 15px rgba(255,0,255,0.2);
    animation: glow-pink 2s ease-in-out infinite;
}

.dot.end .dot-inner::after {
    background: #f0f;
    box-shadow: 0 0 12px #f0f;
    width: 10px;
    height: 10px;
}

@keyframes glow-green {
    0%, 100% { box-shadow: 0 0 20px rgba(0,255,0,0.5), inset 0 0 15px rgba(0,255,0,0.2); }
    50% { box-shadow: 0 0 35px rgba(0,255,0,0.8), inset 0 0 20px rgba(0,255,0,0.3); }
}

@keyframes glow-pink {
    0%, 100% { box-shadow: 0 0 20px rgba(255,0,255,0.5), inset 0 0 15px rgba(255,0,255,0.2); }
    50% { box-shadow: 0 0 35px rgba(255,0,255,0.8), inset 0 0 20px rgba(255,0,255,0.3); }
}

.hint {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
    text-align: center;
}

.hint .green {
    color: #0f0;
    text-shadow: 0 0 8px #0f0;
}

.hint .pink {
    color: #f0f;
    text-shadow: 0 0 8px #f0f;
}

/* Responsive */
@media (max-width: 380px) {
    .grid-container { width: 280px; height: 280px; }
    .dots-grid { padding: 28px; }
    h1 { font-size: 1.4rem; }
    .stat-value { font-size: 1.2rem; }
}

@media (min-width: 500px) and (min-height: 700px) {
    .grid-container { width: 360px; height: 360px; }
    .dots-grid { padding: 40px; }
}

@media (min-width: 700px) and (min-height: 800px) {
    .grid-container { width: 420px; height: 420px; }
    .dots-grid { padding: 45px; }
    h1 { font-size: 2.2rem; }
    .stat-value { font-size: 1.8rem; }
    .dot-inner { width: 34px; height: 34px; }
}

/* Landscape móvil */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container { 
        flex-direction: row; 
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
        padding: 10px;
    }
    .header { 
        width: auto; 
        gap: 20px;
        order: 1;
    }
    .best-score { 
        order: 2;
        margin-left: 20px;
    }
    .grid-wrapper { 
        order: 3;
    }
    .hint { 
        order: 4;
        width: 100%;
    }
    .grid-container { 
        width: min(280px, 45vh); 
        height: min(280px, 45vh); 
    }
    .dots-grid { padding: 25px; }
    h1 { font-size: 1.3rem; }
    .stat-value { font-size: 1.1rem; }
    .dot-inner { width: 22px; height: 22px; }
}

/* Landscape tablet */
@media (min-height: 500px) and (max-height: 700px) and (orientation: landscape) {
    .grid-container { 
        width: min(320px, 55vh); 
        height: min(320px, 55vh); 
    }
}

/* Pantallas muy altas (tablets portrait) */
@media (min-height: 900px) {
    .game-container { gap: 35px; }
    .grid-container { width: 400px; height: 400px; }
    .dots-grid { padding: 45px; }
}

/* Pantallas grandes desktop */
@media (min-width: 1200px) and (min-height: 800px) {
    .grid-container { width: 450px; height: 450px; }
    .dots-grid { padding: 50px; }
    .dot-inner { width: 38px; height: 38px; }
    .dot-inner::after { width: 10px; height: 10px; }
    h1 { font-size: 2.5rem; }
    .stat-value { font-size: 2rem; }
    .hint { font-size: 0.85rem; }
}
