/* Untangle the Net — FunSlop.com
   Dark neon reskin of the untangle graph puzzle. Self-contained: no parent
   theme stylesheet required. */

:root {
    --color-bg: #090b10;
    --color-bg-secondary: #0e111a;
    --color-panel: #11141f;
    --color-green: #39ff14;
    --color-purple: #bd00ff;
    --color-cyan: #05d9e8;
    --color-pink: #ff2a6d;
    --color-text: #f0f4f8;
    --color-muted: #8b9bb4;

    --font-body: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-head: 'Space Grotesk', var(--font-body);

    --radius-md: 14px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg);
    background-image:
        radial-gradient(circle at 16% 18%, rgba(189, 0, 255, 0.16), transparent 44%),
        radial-gradient(circle at 84% 82%, rgba(5, 217, 232, 0.14), transparent 46%),
        radial-gradient(circle at 50% 50%, rgba(57, 255, 20, 0.05), transparent 60%);
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    user-select: none;
    -webkit-user-select: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
    padding-bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
}

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 1rem;
    gap: 1rem;
}

.title {
    margin: 0;
    font-family: var(--font-head);
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-green);
    text-shadow: 0 0 14px rgba(57, 255, 20, 0.55);
}

.level-display {
    font-family: var(--font-head);
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--color-purple);
    text-shadow: 0 0 12px rgba(189, 0, 255, 0.55);
    white-space: nowrap;
}

.canvas-wrapper {
    width: min(90vw, 90vh - 200px, 400px);
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(57, 255, 20, 0.25);
    box-shadow:
        0 0 28px rgba(189, 0, 255, 0.28),
        inset 0 0 18px rgba(5, 217, 232, 0.12);
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--color-bg-secondary);
    cursor: grab;
    touch-action: none;
}

#canvas:active {
    cursor: grabbing;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    font-size: 1.05rem;
    font-weight: 500;
}

.crossings {
    color: var(--color-pink);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 42, 109, 0.5);
}

.crossings.solved {
    color: var(--color-green);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.6);
}

.timer {
    color: var(--color-muted);
    transition: color 0.2s;
}

.timer.urgent {
    color: var(--color-pink);
    font-weight: 700;
    text-shadow: 0 0 12px rgba(255, 42, 109, 0.7);
    animation: pulse 0.5s ease-in-out infinite;
}

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

/* Control instructions */
.controls-inline {
    margin: 0.85rem 0;
}

.control-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: rgba(189, 0, 255, 0.08);
    border: 1px solid rgba(189, 0, 255, 0.3);
    color: var(--color-muted);
    font-size: 0.9rem;
}

.control-pill .touch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--color-green);
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.8);
}

.result-time {
    font-family: var(--font-head);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-green);
    text-shadow: 0 0 14px rgba(57, 255, 20, 0.5);
    text-align: center;
    margin: 0.5rem 0;
}

.best-level {
    font-size: 1rem;
    color: var(--color-cyan);
    margin: 0 0 1rem;
    text-align: center;
}

.share-container {
    margin-bottom: 0.75rem;
}

.start-btn {
    margin-top: 0.5rem;
    font-family: var(--font-head);
    background: linear-gradient(135deg, var(--color-green), var(--color-cyan));
    color: #04130a;
    border: none;
    padding: 0.95rem 2.8rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 32px rgba(57, 255, 20, 0.6);
}

.start-btn:active {
    transform: scale(0.98);
}

.start-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.6);
}

.home-link {
    position: fixed;
    bottom: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-muted);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    background: rgba(17, 20, 31, 0.85);
    border: 1px solid rgba(139, 155, 180, 0.25);
    backdrop-filter: blur(4px);
    transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 200;
}

.home-link:hover {
    color: var(--color-cyan);
    border-color: rgba(5, 217, 232, 0.5);
    box-shadow: 0 0 18px rgba(5, 217, 232, 0.3);
}

.home-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.6);
}

/* SEO / how-to content */
.how-to-play,
.related-games {
    width: 100%;
    margin-top: 1.75rem;
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.how-to-play h2,
.related-games h3 {
    font-family: var(--font-head);
    color: var(--color-text);
}

.how-to-play h3 {
    font-family: var(--font-head);
    color: var(--color-cyan);
    margin-bottom: 0.25rem;
}

.how-to-play em {
    color: var(--color-green);
    font-style: normal;
}

.how-to-play ol {
    padding-left: 1.2rem;
}

.fun-fact {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--color-purple);
    background: rgba(189, 0, 255, 0.07);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.fun-fact strong {
    color: var(--color-purple);
}

.related-games-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.6rem;
}

.related-game-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--color-text);
    background: rgba(5, 217, 232, 0.08);
    border: 1px solid rgba(5, 217, 232, 0.25);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.related-game-link:hover {
    border-color: rgba(5, 217, 232, 0.6);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.3);
}

/* State visibility */
.state-idle .stats,
.state-idle .result-time,
.state-idle .share-container {
    display: none;
}

.state-playing .result-time,
.state-playing .share-container,
.state-playing .start-btn,
.state-playing .controls-inline {
    display: none;
}

.state-celebrating .controls-inline {
    display: none;
}

.state-solved .controls-inline,
.state-gameover .controls-inline {
    display: none;
}

.state-gameover .result-time {
    color: var(--color-pink);
    text-shadow: 0 0 14px rgba(255, 42, 109, 0.5);
}

/* Hide SEO content during gameplay */
.state-playing .how-to-play,
.state-playing .related-games,
.state-celebrating .how-to-play,
.state-celebrating .related-games,
.state-solved .how-to-play,
.state-solved .related-games,
.state-gameover .how-to-play,
.state-gameover .related-games {
    display: none;
}

/* Fade in UI elements on solve */
.state-solved .result-time,
.state-solved .best-level,
.state-solved .share-container,
.state-solved .start-btn {
    animation: fadeIn 0.4s ease-out;
}

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

/* Responsive */
@media (max-width: 600px) {
    .title {
        font-size: 1.4rem;
    }

    .level-display {
        font-size: 1rem;
    }

    .stats {
        font-size: 0.95rem;
        gap: 1.5rem;
    }

    .start-btn {
        padding: 0.75rem 2rem;
        font-size: 1.05rem;
    }
}

/* Very small screens and iOS safe areas */
@media (max-height: 600px) {
    .game-container {
        padding-top: 0.5rem;
    }

    .header-info {
        margin-bottom: 0.5rem;
    }

    .stats {
        margin-top: 0.5rem;
    }

    .result-time {
        margin: 0.25rem 0;
    }

    .best-level {
        margin: 0 0 0.5rem;
    }

    .share-container {
        margin-bottom: 0.5rem;
    }

    .start-btn {
        padding: 0.6rem 1.75rem;
        font-size: 1rem;
    }
}
