/* =========================================
   CAN YOU REMEMBER? — Memory Game Hub
   ========================================= */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a12;
    --bg-card: #12121c;
    --text: #d0d0dc;
    --text-dim: #6a6a80;
    --text-muted: #3a3a50;
    --border: #222233;
    --glow-spread: 15px;
}

html {
    font-size: 16px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-wrapper {
    width: 100%;
    max-width: 640px;
    padding: 2rem 1.5rem;
    margin: 0 auto;
}

/* =========================================
   HEADER
   ========================================= */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-pre {
    font-size: 0.65rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.8rem;
}

.title {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    font-weight: 900;
    letter-spacing: 0.1em;
    color: #fff;
    margin-bottom: 0.5rem;
    background: linear-gradient(90deg, #00f0ff, #ff00e6, #ffd700, #39ff14);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 300% 100%;
    animation: gradientShift 6s linear infinite;
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.subtitle {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.instructions {
    font-size: 0.75rem;
    color: var(--text-dim);
    max-width: 400px;
    margin: 0 auto;
}

/* =========================================
   STATS BAR
   ========================================= */
.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

/* =========================================
   THE GRID
   ========================================= */
.grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 400px;
    width: 100%;
}

.cell {
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s, border-color 0.3s, box-shadow 0.3s;
    overflow: hidden;
}

.cell:hover:not(.matched):not(.flipped) {
    border-color: #444;
    transform: scale(1.03);
}

.cell::before {
    content: '?';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: opacity 0.3s;
}

.cell.flipped::before,
.cell.matched::before {
    opacity: 0;
}

.cell-color {
    position: absolute;
    inset: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}

.cell.flipped .cell-color,
.cell.matched .cell-color {
    opacity: 1;
}

.cell.matched {
    cursor: default;
    border-color: transparent;
}

.cell.matched .cell-color {
    box-shadow: 0 0 var(--glow-spread) currentColor;
}

/* Wrong match shake */
.cell.wrong {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

/* =========================================
   UNLOCKED LINKS
   ========================================= */
.links-section {
    margin-bottom: 2rem;
}

.links-title {
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 1rem;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.8rem;
    min-height: 50px;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
    animation: linkAppear 0.5s ease;
}

@keyframes linkAppear {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.link-card:hover {
    border-color: #555;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.link-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
}

.link-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.link-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-desc {
    font-size: 0.65rem;
    color: var(--text-dim);
}

/* =========================================
   COMPLETION
   ========================================= */
.completion {
    text-align: center;
    padding: 2rem 0;
    animation: fadeIn 1s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.completion-title {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    color: #fff;
    margin-bottom: 1rem;
    background: linear-gradient(90deg, #00f0ff, #ff00e6, #ffd700, #39ff14);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.completion-text {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.completion-highlight {
    font-size: 1.1rem;
    color: #fff;
    font-weight: 700;
    margin: 1rem 0;
}

.completion-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.completion-grid {
    image-rendering: pixelated;
    margin: 0 auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
}

/* =========================================
   FOOTER
   ========================================= */
.footer {
    text-align: center;
    padding: 2rem 0 0;
}

.footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 480px) {
    .grid {
        gap: 6px;
    }

    .links-grid {
        grid-template-columns: 1fr;
    }

    .stats {
        gap: 1.2rem;
    }
}
