:root {
    --nf-bg: #050712;
    --nf-panel: #141827;
    --nf-orange: #FF9F2E; 
    --nf-purple: #A259FF; 
    --nf-green: #59FF84;
    --nf-red: #FF4F70;
    --nf-white: #f0f0f5;
    --nf-border: #30364c;
    --nf-text-main: #f5f5f7;
    --nf-text-muted: #a2a7c2;
    
    --cols: 5;
    --rows: 8;
}
  
*, *::before, *::after { box-sizing: border-box; }
  
html, body { 
    margin: 0; padding: 0; min-height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--nf-bg); color: var(--nf-text-main);
    display: flex; flex-direction: column;
    overflow-x: hidden;
    user-select: none;
}

/* --- STAR FIELD (UPDATED: More Stars, Brighter) --- */
.fixed-background {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0;
    background-color: #020205; overflow: hidden; pointer-events: none;
}
.fixed-background::before {
    content: ""; position: absolute; inset: 0;
    /* Layer 1: Dense, slower stars */
    background-image: 
        radial-gradient(2px 2px at 10% 10%, #fff, transparent), 
        radial-gradient(2px 2px at 20% 80%, #fff, transparent),
        radial-gradient(2px 2px at 50% 50%, #fff, transparent),
        radial-gradient(2px 2px at 80% 20%, #fff, transparent),
        radial-gradient(2px 2px at 90% 90%, #fff, transparent);
    background-size: 400px 400px; 
    opacity: 1; /* Max Brightness */
    animation: starIntro 100s linear infinite;
}
.fixed-background::after {
    content: ""; position: absolute; inset: 0;
    /* Layer 2: Scattered, faster, larger stars */
    background-image: 
        radial-gradient(3px 3px at 5% 90%, #fff, transparent), 
        radial-gradient(3px 3px at 25% 10%, #fff, transparent),
        radial-gradient(3px 3px at 60% 40%, #fff, transparent),
        radial-gradient(3px 3px at 90% 75%, #fff, transparent);
    background-size: 500px 500px; 
    opacity: 1; /* Max Brightness */
    animation: starIntroFast 60s linear infinite;
}
@keyframes starIntro { from { background-position: 0 0; } to { background-position: 0 1000px; } }
@keyframes starIntroFast { from { background-position: 0 0; } to { background-position: 0 1200px; } }

.center-wrapper { margin: auto; width: 100%; display: flex; flex-direction: column; align-items: center; padding: 20px 8px; position: relative; z-index: 1; }

.game-shell.nf-shell {
    width: 100%; 
    max-width: 460px; 
    padding: 18px 14px; 
    margin: 0 auto;
    background: rgba(20, 24, 39, 0.95); backdrop-filter: blur(16px);
    border-radius: 26px; 
    box-shadow: 0 0 0 1px rgba(162, 89, 255, 0.1), 0 20px 50px rgba(0,0,0,0.8);
    position: relative; z-index: 1;
}

.nf-confetti-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
.hidden { display: none !important; }

/* HEADER & TOP BAR */
.nf-header { text-align: center; margin-bottom: 8px; }
.nf-header h1 { margin: 0 0 4px; letter-spacing: 0.1em; font-weight: 800; font-size: 1.6rem; color: #fff; text-shadow: 0 0 20px rgba(162, 89, 255, 0.6); }
.nf-tagline { margin: 0; font-size: 0.75rem; color: var(--nf-text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.nf-howto-btn { margin-top: 6px; background: transparent; border: none; color: var(--nf-text-muted); font-size: 0.75rem; cursor: pointer; text-decoration: underline; }
.nf-howto-tooltip { margin: 10px 0; font-size: 0.8rem; background: rgba(20, 24, 39, 0.98); border-radius: 12px; padding: 14px; border: 1px solid var(--nf-border); color: #ccc; text-align: center; line-height: 1.5; box-shadow: 0 10px 30px rgba(0,0,0,0.8); position: relative; z-index: 200; }
.nf-btn-mini { margin: 10px auto 0 auto; padding: 6px 20px; border-radius: 99px; border: none; background: #fff; color: #000; font-weight: 800; font-size: 0.75rem; text-transform: uppercase; display: block; width: auto; cursor: pointer; }

/* TOP BAR LAYOUT */
.top-bar.nf-top-bar { 
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(10, 12, 20, 0.6); border-radius: 16px; padding: 8px 12px; border: 1px solid var(--nf-border); margin-bottom: 12px; 
}
.top-row { display: flex; justify-content: space-between; flex: 1; align-items: center; }
.top-item { display: flex; flex-direction: column; align-items: center; min-width: 60px; }
.top-label { text-transform: uppercase; letter-spacing: 0.1em; color: var(--nf-text-muted); font-size: 0.55rem; font-weight: 700; margin-bottom: 2px; }
.top-value { font-weight: 700; font-size: 0.85rem; color: #fff; font-variant-numeric: tabular-nums; }
.nf-sound-toggle { background: transparent; border: none; color: var(--nf-text-muted); font-size: 1rem; cursor: pointer; margin-left: 10px; padding: 4px; }

/* MODE SWITCH */
.mode-switch.nf-mode-switch { display: flex; justify-content: center; background: rgba(20, 24, 39, 0.8); border-radius: 99px; padding: 4px; border: 1px solid var(--nf-border); margin-bottom: 10px; width: fit-content; margin-left: auto; margin-right: auto; }
.mode-btn { border: none; background: transparent; color: var(--nf-text-muted); padding: 6px 14px; border-radius: 99px; cursor: pointer; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; transition: 0.2s; }
.mode-btn.active { background: #fff; color: #000; box-shadow: 0 0 10px rgba(255,255,255,0.2); }

/* --- GAME BOARD --- */
.nf-game-area { 
    background: #0b0d14; 
    border-radius: 12px; 
    border: 2px solid var(--nf-border); 
    position: relative; 
    margin: 0 auto;
    width: 100%;
    max-width: 100%; 
    aspect-ratio: 1/1.15; 
    overflow: hidden;
}

.nf-board-container {
    position: relative;
    width: 100%; height: 100%;
    padding: 10px;
}

.nf-board {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    grid-template-rows: repeat(var(--rows), 1fr);
    gap: 3px; 
    width: 100%; height: 100%;
    position: relative;
    z-index: 2;
}

.nf-cell {
    background: rgba(255,255,255,0.06); 
    border: 1px solid rgba(255,255,255,0.05); 
    border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; 
    font-weight: 700; 
    color: rgba(255,255,255,0.7); 
    position: relative;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    transition: background-color 0.15s, box-shadow 0.15s, color 0.15s;
}

/* SNAKE EFFECT */
.nf-cell.snake-active {
    background: var(--nf-orange) !important;
    color: #000 !important;
    box-shadow: 0 0 10px var(--nf-orange);
    border-color: #fff;
    z-index: 10;
}

/* START TILE */
.nf-cell.start-node { 
    border: 1px solid rgba(89, 255, 132, 0.5); 
    color: #fff;
    background: rgba(89, 255, 132, 0.1);
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* FINISH TILE */
.nf-cell.end-node { 
    border: 1px solid rgba(89, 255, 132, 0.5); 
    color: #fff;
    background: rgba(89, 255, 132, 0.1);
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    z-index: 5;
}

/* Win State: Bright Green Highlight */
.board-win .nf-cell.end-node {
    box-shadow: 0 0 30px #59FF84;
    border-color: #59FF84;
    background: #59FF84;
    color: #000;
}

.nf-cell.snake-start { background: rgba(255, 79, 112, 0.2); box-shadow: inset 0 0 5px var(--nf-red); color: #fff; border-color: var(--nf-red); }
.nf-cell.ladder-start { background: rgba(89, 255, 132, 0.2); box-shadow: inset 0 0 5px var(--nf-green); color: #fff; border-color: var(--nf-green); }

.nf-connections {
    position: absolute; inset: 0; width: 100%; height: 100%;
    z-index: 1; pointer-events: none;
}
.conn-line { fill: none; stroke-width: 3; stroke-linecap: round; opacity: 0.6; }
.conn-snake { stroke: var(--nf-red); stroke-dasharray: 5, 3; }
.conn-ladder { stroke: var(--nf-green); }

/* --- HAND AREA --- */
.nf-hand-wrapper {
    margin-top: 10px;
    height: 90px;
    display: flex; justify-content: center;
    perspective: 1000px; 
}

.nf-hand {
    display: flex; gap: 4px; 
    padding: 5px;
}

.nf-card-container {
    width: 48px;
    height: 70px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
}
.nf-card-container.revealed:hover { 
    transform: translateY(-6px); 
    z-index: 10;
}
.nf-card-container.revealed:hover .nf-card-front {
    box-shadow: 0 0 10px rgba(255,255,255,0.4);
    border-color: #fff;
}

.nf-card-container.disabled { cursor: default; opacity: 0.6; }

.nf-card-inner {
    position: relative;
    width: 100%; height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
    transform: rotateY(180deg);
}

.nf-card-container.revealed .nf-card-inner { transform: rotateY(0deg); }

.nf-card-face {
    position: absolute;
    width: 100%; height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    display: flex; flex-direction: column; 
    align-items: center; justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.6);
    border: 1px solid #ccc;
    font-family: serif;
}

/* Front: Classic White */
.nf-card-front {
    background: #fff;
    color: #000;
    transform: rotateY(0deg);
}

/* Suit Colors: Classic Red & Black */
.nf-card-front.suit-red { 
    color: #d32f2f; 
    text-shadow: none;
}
.nf-card-front.suit-black { 
    color: #000; 
    text-shadow: none;
}

.nf-card-front .card-val { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.nf-card-front .card-suit { font-size: 1.2rem; line-height: 1; margin-top: -2px; }

/* Corner numbers */
.nf-card-front::before { 
    content: attr(data-val); 
    position: absolute; top: 2px; left: 2px; 
    font-size: 0.65rem; line-height: 1;
}
.nf-card-front::after { 
    content: attr(data-val); 
    position: absolute; bottom: 2px; right: 2px; 
    font-size: 0.65rem; line-height: 1; 
    transform: rotate(180deg); 
}

/* Back: Red Stripe */
.nf-card-back {
    background: repeating-linear-gradient(
        45deg,
        #b71c1c,
        #b71c1c 10px,
        #f44336 10px,
        #f44336 20px
    );
    border: 2px solid #fff;
    transform: rotateY(180deg);
}

/* CONTROLS */
.nf-status-bar { text-align: center; margin: 4px 0 8px; height: 1.2em; }
.nf-status-text { font-size: 0.85rem; color: #fff; }
.nf-status-text.win { color: #59FF84; }
.nf-status-text.error { color: #FF4F70; animation: shake 0.3s; }

.nf-controls { display: flex; gap: 10px; margin-top: 8px; }
.nf-ctrl-btn { flex: 1; padding: 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); color: #fff; font-weight: 800; text-transform: uppercase; font-size: 0.8rem; cursor: pointer; transition: 0.2s; }
.nf-ctrl-btn:hover { background: rgba(255,255,255,0.1); transform: translateY(-2px); }

/* BOTTOM BUTTONS */
.nf-bottom-actions { display: flex; gap: 8px; margin-top: 12px; }
.nf-bottom-btn { flex: 1; padding: 10px; border-radius: 999px; background: transparent; border: 1px solid var(--nf-border); color: var(--nf-text-muted); font-size: 0.85rem; font-weight: 700; text-transform: uppercase; cursor: pointer; transition: all 0.2s ease; }
.nf-bottom-btn:not(:disabled):hover { background: rgba(255, 255, 255, 0.15); border-color: #fff; color: #fff; transform: translateY(-2px); box-shadow: 0 0 15px rgba(255, 255, 255, 0.2); }
.nf-bottom-btn:not(:disabled):active { background: #fff; color: #000; border-color: #fff; box-shadow: 0 0 25px rgba(255, 255, 255, 0.6); transform: scale(0.96); transition: 0s; }

.nf-share-btn:enabled { background: var(--nf-orange); color: #000; border-color: var(--nf-orange); box-shadow: 0 0 15px rgba(255, 159, 46, 0.4); }
.nf-share-btn:enabled:hover { background: #ffaf4d; border-color: #ffaf4d; transform: translateY(-2px); color: #000; }

.difficulty-switch.hidden { display: none; }
.difficulty-switch { display: flex; justify-content: center; gap: 4px; margin-bottom: 10px; }
.diff-btn { border: 1px solid var(--nf-border); background: transparent; color: var(--nf-text-muted); padding: 4px 10px; border-radius: 99px; font-size: 0.65rem; cursor: pointer; text-transform: uppercase; }
.diff-btn.active { background: #fff; color: #000; font-weight: 700; }

.daily-overlay { position: absolute; inset: 0; background: rgba(5, 7, 18, 0.9); backdrop-filter: blur(8px); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; border-radius: 12px; animation: fadeIn 0.5s ease-out; }
.daily-msg { font-size: 2rem; font-weight: 900; color: #fff; margin-bottom: 10px; text-shadow: 0 0 20px rgba(255,255,255,0.5); }
.daily-sub { font-size: 1rem; color: var(--nf-text-muted); text-transform: uppercase; letter-spacing: 0.05em; text-align: center; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* STATS MODAL & FOOTER */
.nf-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 200; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.nf-modal { background: #141827; width: 90%; max-width: 400px; padding: 24px; border-radius: 24px; border: 1px solid rgba(255,255,255,0.1); text-align: center; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.8); }
.nf-modal-title { margin: 0 0 20px; font-size: 1.5rem; letter-spacing: 0.1em; color: #fff; }
.nf-modal-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #666; font-size: 1.8rem; cursor: pointer; }
.nf-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nf-stat-box { background: rgba(255,255,255,0.05); padding: 12px; border-radius: 12px; }
.nf-stat-box .label { font-size: 0.65rem; color: #888; text-transform: uppercase; margin-bottom: 4px; }
.nf-stat-box .value { font-size: 1.4rem; font-weight: 800; color: #fff; }

/* HEAT MAP GRID */
.heat-map-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    justify-items: center;
    margin-top: 5px;
}
.stat-dot {
    width: 14px; height: 14px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1); /* Empty State */
    border: 1px solid rgba(255,255,255,0.05);
}
.stat-dot.normal { background: var(--nf-green); box-shadow: 0 0 5px var(--nf-green); }
.stat-dot.hard { background: var(--nf-orange); box-shadow: 0 0 5px var(--nf-orange); }
.stat-dot.hardest { background: var(--nf-red); box-shadow: 0 0 5px var(--nf-red); }

/* LAYOUT TWEAKS (UPDATED TYPOGRAPHY) */
.content-section { 
    width: 100%; max-width: 600px; margin-top: 10px; padding: 0 20px; 
    color: var(--nf-text-muted); 
    font-size: 0.95rem; /* Reduced slightly */
    line-height: 1.6; 
}
.content-section strong {
    color: #fff; /* Bold text now white */
}
.content-section h2 { color: var(--nf-text-main); font-size: 1.5rem; border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 20px; text-align: center; }
.content-section h3 { color: var(--nf-orange); margin-top: 24px; margin-bottom: 8px; }

.nf-footer { 
    margin-top: 10px; padding: 10px 20px; text-align: center; 
    font-size: 0.85rem; /* Increased size */
    color: var(--nf-text-muted); /* Changed to match About text */
}
.nf-footer-links { display: flex; justify-content: center; gap: 15px; margin-bottom: 10px; }
.nf-footer-link { 
    color: var(--nf-orange); text-decoration: none; transition: 0.2s; 
    font-size: 0.9rem; /* Increased size */
}
/* FIXED: Hover color is now white */
.nf-footer-link:hover { color: #ffffff; }

/* Horizontal Rule for Footer */
.nf-hr { border: 0; border-top: 1px solid var(--nf-border); margin: 20px auto 10px; width: 80%; opacity: 0.3; }

/* Increased Spacing above Exit Button */
.arcade-return-nav { width: 100%; max-width: 460px; margin: 40px auto 10px; display: flex; justify-content: center; }
.return-link { display: flex; align-items: center; gap: 10px; padding: 10px 24px; border-radius: 99px; background: rgba(255,255,255,0.05); color: var(--nf-text-muted); text-decoration: none; font-size: 0.75rem; font-weight: 700; border: 1px solid var(--nf-border); transition: 0.2s; }
/* FIXED: Hover color is now white */
.return-link:hover { background: rgba(255, 159, 46, 0.1); color: #ffffff; border-color: var(--nf-orange); transform: translateY(-2px); }
.return-link:hover .return-icon { transform: translateX(-5px); }