/* ========================================
   PATTERN RECALL — THE ANTI-PHONE GAME
   Aesthetic: Dark Neon Arcade
   ======================================== */

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --green-main: #00ff88;
    --green-dark: #00cc6a;
    --green-glow: rgba(0, 255, 136, 0.5);
    --red-main: #ff3366;
    --red-dark: #cc2952;
    --red-glow: rgba(255, 51, 102, 0.5);
    --text-primary: #ffffff;
    --text-secondary: #666680;
    --text-accent: #00ff88;
    --border-subtle: #1a1a2e;
    --tile-neutral: #1a1a2e;
    --tile-neutral-hover: #252540;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Space Mono', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(ellipse at 50% 0%, rgba(0, 255, 136, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255, 51, 102, 0.05) 0%, transparent 40%),
        linear-gradient(180deg, #0a0a0f 0%, #0f0f18 100%);
}

/* Scanline effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 1000;
    opacity: 0.3;
}

.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
}

/* ========================================
   HEADER
   ======================================== */

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    text-shadow: 
        0 0 10px var(--green-glow),
        0 0 30px var(--green-glow),
        0 0 50px rgba(0, 255, 136, 0.3);
}

.title .accent {
    color: var(--green-main);
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ========================================
   STATS BAR
   ======================================== */

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.2em;
}

.stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.status-indicator {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.status-indicator.memorize {
    color: var(--green-main);
    text-shadow: 0 0 10px var(--green-glow);
}

.status-indicator.recall {
    color: var(--red-main);
    text-shadow: 0 0 10px var(--red-glow);
}

/* ========================================
   GRID
   ======================================== */

.grid-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.grid-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, var(--green-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    filter: blur(40px);
}

.grid-glow.active {
    opacity: 0.3;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4px;
    padding: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: 8px;
    position: relative;
    z-index: 1;
    max-width: 100%;
    width: fit-content;
    touch-action: manipulation;
}

.tile {
    width: clamp(28px, 5vw, 45px);
    height: clamp(28px, 5vw, 45px);
    background: var(--tile-neutral);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* Only apply hover effects on devices that support hover */
@media (hover: hover) and (pointer: fine) {
    .tile:hover:not(.disabled) {
        background: var(--tile-neutral-hover);
        transform: scale(1.05);
    }

    .tile:hover:not(.disabled)::before {
        opacity: 1;
    }
}

/* Active state for touch feedback */
.tile:active:not(.disabled) {
    transform: scale(0.95);
}

.tile.green {
    background: linear-gradient(135deg, var(--green-main) 0%, var(--green-dark) 100%);
    box-shadow: 
        0 0 15px var(--green-glow),
        inset 0 1px 1px rgba(255,255,255,0.3);
    animation: tilePop 0.3s ease;
}

.tile.green::before {
    opacity: 1;
}

.tile.red {
    background: linear-gradient(135deg, var(--red-main) 0%, var(--red-dark) 100%);
    box-shadow: 
        0 0 15px var(--red-glow),
        inset 0 1px 1px rgba(255,255,255,0.3);
}

.tile.user-selected {
    background: linear-gradient(135deg, var(--green-main) 0%, var(--green-dark) 100%);
    box-shadow: 
        0 0 10px var(--green-glow),
        inset 0 1px 1px rgba(255,255,255,0.3);
    animation: tilePop 0.2s ease;
}

.tile.wrong {
    background: linear-gradient(135deg, var(--red-main) 0%, var(--red-dark) 100%);
    box-shadow: 0 0 20px var(--red-glow);
    animation: wrongShake 0.5s ease;
}

.tile.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

@keyframes tilePop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* Grid Overlay */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 8px;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.grid-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
}

.overlay-icon {
    font-size: 3rem;
    color: var(--green-main);
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.overlay-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    color: var(--text-secondary);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.1); }
}

/* ========================================
   CONTROLS
   ======================================== */

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    padding: 1rem 2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-text {
    position: relative;
    z-index: 2;
}

.btn-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-start {
    background: linear-gradient(135deg, var(--green-main) 0%, var(--green-dark) 100%);
    color: #000;
}

.btn-start .btn-glow {
    background: var(--green-main);
    filter: blur(15px);
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 30px var(--green-glow);
}

.btn-start:hover:not(:disabled) .btn-glow {
    opacity: 0.5;
}

.btn-peek {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--text-secondary);
}

.btn-peek:hover:not(:disabled) {
    border-color: var(--green-main);
    color: var(--green-main);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
}

.btn-recall {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--red-main);
}

.btn-recall .btn-glow {
    background: var(--red-main);
    filter: blur(15px);
}

.btn-recall:hover:not(:disabled) {
    background: var(--red-main);
    color: #fff;
    box-shadow: 0 5px 30px var(--red-glow);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ========================================
   RULES SECTION
   ======================================== */

.rules-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    max-width: 700px;
    margin: 0 auto;
}

.rules-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.rules-text {
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

/* ========================================
   MODALS
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 2px solid var(--border-subtle);
    transform: scale(0.9);
    transition: transform 0.4s ease;
    max-width: 400px;
    width: 90%;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.modal-fail .modal-icon {
    color: var(--red-main);
    text-shadow: 0 0 30px var(--red-glow);
    animation: wrongShake 0.5s ease;
}

.modal-win .modal-icon {
    color: var(--green-main);
    text-shadow: 0 0 30px var(--green-glow);
    animation: pulse 1.5s ease-in-out infinite;
}

.modal-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.modal-fail .modal-title {
    color: var(--red-main);
}

.modal-win .modal-title {
    color: var(--green-main);
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.modal-stat {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.modal-content .btn {
    margin-top: 1.5rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 600px) {
    .game-container {
        padding: 0.75rem;
    }

    .header {
        margin-bottom: 1rem;
    }

    .title {
        font-size: 1.4rem;
        letter-spacing: 0.05em;
    }

    .tagline {
        font-size: 0.65rem;
        letter-spacing: 0.1em;
    }

    .stats-bar {
        gap: 0.8rem;
        padding: 0.6rem 0.8rem;
        margin-bottom: 1rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    .grid-wrapper {
        margin-bottom: 1rem;
    }

    .grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 3px;
        padding: 8px;
    }

    .tile {
        width: clamp(32px, 10vw, 42px);
        height: clamp(32px, 10vw, 42px);
        border-radius: 3px;
    }

    .controls {
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }

    .btn {
        padding: 0.7rem 1rem;
        font-size: 0.65rem;
        letter-spacing: 0.1em;
    }

    .rules-section {
        padding: 1rem;
    }

    .rules-title {
        font-size: 0.7rem;
        margin-bottom: 0.6rem;
    }

    .rules-text {
        font-size: 0.75rem;
        line-height: 1.6;
    }

    .modal-content {
        padding: 2rem 1.5rem;
    }

    .modal-icon {
        font-size: 3rem;
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .modal-text {
        font-size: 0.8rem;
    }

    .modal-stat {
        font-size: 0.95rem;
    }
}

@media (max-width: 380px) {
    .title {
        font-size: 1.2rem;
    }

    .tagline {
        font-size: 0.6rem;
    }

    .tile {
        width: clamp(28px, 9vw, 36px);
        height: clamp(28px, 9vw, 36px);
    }

    .btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.6rem;
    }
}