@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: #0d1117;
    font-family: 'Space Mono', monospace;
    color: white;
    user-select: none;
    -webkit-user-select: none;
}

.screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    gap: 8px;
}

/* Top Bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-shrink: 0;
}

.topbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.back-btn {
    border: 1px solid #333;
    background: transparent;
    color: #aaa;
    padding: 6px 14px;
    border-radius: 20px;
    font-family: 'Space Mono', monospace;
    font-size: 0.75em;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.back-btn:hover { color: #fff; border-color: #555; }

.title {
    font-size: 1em;
    letter-spacing: 3px;
    color: #ab47bc;
    text-shadow: 0 0 10px rgba(171, 71, 188, 0.3);
}

.restart-btn {
    border: 1px solid #333;
    background: transparent;
    color: #aaa;
    padding: 6px 12px;
    border-radius: 20px;
    font-family: 'Space Mono', monospace;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s;
}

.restart-btn:hover { border-color: #ab47bc; color: #ab47bc; }

.music-btn {
    border: 1px solid #333;
    background: transparent;
    color: #aaa;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.music-btn.on { border-color: #ab47bc; color: #ab47bc; }
.music-btn.off { border-color: #333; color: #444; }

/* Stats */
.stats {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.stat {
    text-align: center;
    background: #111827;
    border: 1px solid #1e2433;
    border-radius: 8px;
    padding: 5px 14px;
    min-width: 65px;
}

.stat-label {
    font-size: 0.5em;
    color: #555;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 0.95em;
    color: #fff;
    font-weight: 700;
}

/* Board */
.board-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

.board {
    display: grid;
    gap: 3px;
    padding: 8px;
    background: #111827;
    border: 1px solid #1e2433;
    border-radius: 14px;
    box-shadow: 0 0 20px rgba(171, 71, 188, 0.1);
}

/* Tile */
.tile {
    position: relative;
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    background-size: cover;
    background-repeat: no-repeat;
    border: 1px solid #2a3a50;
    transition: transform 0.1s ease, box-shadow 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.tile:active { transform: scale(0.94); }

.tile.empty {
    background: #0d1117 !important;
    border: 1px dashed #1a2233;
    cursor: default;
    pointer-events: none;
}

.tile.correct {
    border-color: #4caf50;
    box-shadow: inset 0 0 0 2px #4caf5055;
}

/* Number badge on corner */
.tile-num {
    position: absolute;
    top: 3px;
    left: 3px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.6em;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
    line-height: 1.4;
    z-index: 2;
    pointer-events: none;
}

/* Preview Bar */
.preview-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-bottom: 4px;
}

.preview-label {
    font-size: 0.65em;
    color: #555;
    letter-spacing: 1px;
}

.preview-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ab47bc55;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(10, 14, 20, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 100;
}

.overlay-emoji {
    font-size: 3em;
    animation: bounce 1.5s infinite;
}

.overlay-title {
    font-size: 1.6em;
    letter-spacing: 4px;
    color: #ab47bc;
}

.overlay-sub {
    font-size: 0.75em;
    color: #555;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.8;
}

.diff-row {
    display: flex;
    gap: 10px;
}

.diff-btn {
    background: #111827;
    border: 1px solid #333;
    color: #aaa;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'Space Mono', monospace;
    font-size: 0.75em;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover, .diff-btn.active {
    border-color: #ab47bc;
    color: #ab47bc;
}

.start-btn {
    background: #ab47bc;
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-family: 'Space Mono', monospace;
    font-size: 0.9em;
    letter-spacing: 2px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.start-btn:hover { background: #9c27b0; transform: translateY(-2px); }

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes tileMove {
    0% { transform: scale(0.9); }
    60% { transform: scale(1.05); }
    100% { transform: scale(1); }
}