/* Base & Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background-color: #0a0a1a;
    color: #ffffff;
    font-family: system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100%;
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Touch action */
button, .cell {
    touch-action: manipulation;
}

/* Typography & Colors */
.text-accent { color: #00e5ff; }
.text-success { color: #00ff88; }
.text-error { color: #ff3366; }
.text-warning { color: #ffcc00; }
.text-muted { color: rgba(255, 255, 255, 0.6); }

/* Utilities */
.hidden { display: none !important; }
.flex-column { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.max-w-400 { max-width: 400px; }
.text-center { text-align: center; }

/* Spacing */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* Screen Transitions */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(10px);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Home Screen */
#screen-home {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.logo {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(90deg, #00e5ff, #0088ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    -webkit-text-fill-color: initial;
    animation: pulse 2s infinite;
}

#home-mode-emoji {
    font-size: 72px;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

#home-mode-name {
    font-size: 28px;
    margin-bottom: 8px;
}

#home-mode-desc {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
    text-align: center;
}

#home-streak {
    color: #ff9900;
    font-weight: bold;
    margin-bottom: 32px;
    background: rgba(255, 153, 0, 0.1);
    padding: 8px 16px;
    border-radius: 16px;
}

.already-played {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 320px;
}

.home-footer {
    margin-top: auto;
    padding-bottom: 16px;
}

/* Buttons */
button {
    font-family: inherit;
    outline: none;
}

.btn-primary {
    background-color: #00e5ff;
    color: #0a0a1a;
    font-weight: 700;
    padding: 14px 28px;
    border-radius: 24px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    max-width: 320px;
    transition: transform 0.15s, background-color 0.15s;
    margin-bottom: 16px;
}

.btn-primary:hover {
    background-color: #33edff;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background-color: transparent;
    color: #00e5ff;
    border: 2px solid #00e5ff;
    font-weight: 700;
    padding: 14px 28px;
    border-radius: 24px;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    max-width: 320px;
    transition: transform 0.15s, background-color 0.15s;
}

.btn-secondary:hover {
    background-color: rgba(0, 229, 255, 0.1);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-large {
    padding: 18px 32px;
    font-size: 18px;
}

.btn-ghost {
    background-color: transparent;
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-peek {
    background-color: transparent;
    color: #ffcc00;
    border: 1px solid #ffcc00;
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
}

/* Countdown Screen */
.countdown-number {
    font-size: 120px;
    font-weight: bold;
    color: #00e5ff;
    animation: countdownPulse 1s ease-in-out;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.timer {
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 28px;
    color: #00e5ff;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
    font-weight: bold;
}

.game-target {
    font-size: 48px;
    font-weight: bold;
    text-align: center;
    color: #00e5ff;
    margin: 16px 0;
    animation: pulse 1s infinite;
}

.game-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 14px;
}

/* Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 16px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.grid-container.grid-4col {
    grid-template-columns: repeat(4, 1fr);
    max-width: 320px;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, background-color 0.15s, box-shadow 0.15s, opacity 0.3s;
    position: relative;
    transform-style: preserve-3d;
}

.cell:active {
    transform: scale(0.92);
}

.cell.selected {
    border-color: #00e5ff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
    background-color: #1a2a3e;
}

.cell.correct {
    background-color: #00ff88;
    color: #000;
    animation: cellCorrect 0.5s forwards;
    border-color: #00ff88;
}

.cell.wrong {
    background-color: #ff3366;
    border-color: #ff3366;
    animation: cellWrong 0.4s;
}

.cell.cleared {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

.cell.hidden-cell {
    background-color: #252542;
    color: transparent;
}
.cell.hidden-cell::after {
    content: '?';
    color: rgba(255, 255, 255, 0.3);
    position: absolute;
}

.cell.revealed {
    animation: cellReveal 0.3s forwards;
}

.cell.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.cell.bomb {
    background-color: #ff3366;
    animation: explode 0.5s forwards;
}

.cell.target-cell {
    background: linear-gradient(135deg, #1a2a3e, #1a1a2e);
    border-color: #00e5ff;
    font-size: 14px;
    pointer-events: none;
}

.cell.math-tile {
    font-size: 15px;
    letter-spacing: -0.5px;
    font-weight: 600;
}

.cell.color-tile {
    font-size: 26px;
}

.cell.stroop-tile {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cell.bomb-preview {
    background-color: rgba(255, 51, 102, 0.25);
    border-color: #ff3366;
    animation: pulse 1s infinite;
}

.cell.disguised-cell {
    background-color: #1a1a2e;
}

/* Result Screen */
.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat {
    background-color: #1a1a2e;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.rank-bar {
    width: 100%;
    height: 8px;
    background-color: #252542;
    border-radius: 4px;
    overflow: hidden;
}

.rank-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00e5ff, #00ff88);
    border-radius: 4px;
    transition: width 1s ease-out;
}

/* Result Action Buttons */
.result-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    gap: 12px;
}

.result-actions button,
.result-actions .btn-primary,
.result-actions .btn-secondary,
.result-actions .btn-ghost {
    width: 100% !important;
    max-width: 340px !important;
    height: 50px;
    padding: 0 20px !important;
    border-radius: 25px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
}

.result-actions .btn-ghost {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.result-actions .btn-ghost:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #1a1a2e;
    border: 1px solid #2a2a4a;
    padding: 12px 24px;
    border-radius: 12px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Animations Keyframes */
@keyframes cellCorrect {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); box-shadow: 0 0 20px rgba(0, 255, 136, 0.8); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes cellWrong {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-4px); }
}

@keyframes cellReveal {
    0% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

@keyframes countdownPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes explode {
    0% { transform: scale(1); background-color: #ff3366; }
    50% { transform: scale(1.5); background-color: #fff; opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* Responsive */
@media (min-width: 480px) {
    .grid-container { max-width: 440px; gap: 10px; }
    .grid-container.grid-4col { max-width: 360px; }
    .cell { font-size: 24px; }
}

@media (min-width: 768px) {
    .grid-container { max-width: 500px; gap: 12px; }
    .grid-container.grid-4col { max-width: 400px; }
    .cell { font-size: 28px; }
    .stat-value { font-size: 32px; }
}

@media (min-width: 1024px) {
    #app {
        display: flex;
        justify-content: center;
        background-color: #050510;
    }
    .screen {
        max-width: 480px;
        margin: 0 auto;
        position: relative;
        background-color: #0a0a1a;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
}

.modal-card {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 16px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.btn-icon {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}
.btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.btn-link {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
}
.btn-link:hover {
    color: #ffffff !important;
}

.text-white {
    color: #ffffff;
}

/* Monetization & PRO Styles */
.home-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
}

.btn-pro-pill {
    background: rgba(255, 204, 0, 0.12);
    color: #ffcc00;
    border: 1px solid rgba(255, 204, 0, 0.35);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-pro-pill:hover {
    background: rgba(255, 204, 0, 0.22);
    border-color: #ffcc00;
    transform: translateY(-1px);
}

.btn-pro-pill.is-pro {
    background: linear-gradient(135deg, rgba(255, 204, 0, 0.25), rgba(255, 153, 0, 0.25));
    border-color: #ffcc00;
    box-shadow: 0 0 12px rgba(255, 204, 0, 0.3);
}

.text-gold {
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

.pro-price-badge {
    background: rgba(255, 204, 0, 0.15);
    color: #ffcc00;
    border: 1px solid rgba(255, 204, 0, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    display: inline-block;
    margin-top: 2px;
}

.btn-pro-primary {
    background: linear-gradient(135deg, #ffcc00, #ff9900);
    color: #0a0a1a;
    font-weight: 800;
    padding: 14px 28px;
    border-radius: 24px;
    border: none;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255, 153, 0, 0.35);
    transition: all 0.15s ease;
}

.btn-pro-primary:hover:not(.btn-disabled) {
    background: linear-gradient(135deg, #ffe066, #ffa31a);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 153, 0, 0.5);
}

.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #33334d !important;
    color: #9999aa !important;
    box-shadow: none !important;
}

.pro-perks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    max-height: 240px;
    overflow-y: auto;
}

.pro-perk-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.pro-perk-icon {
    font-size: 18px;
    line-height: 1.2;
}

.pro-perk-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
}

.pro-perk-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
}

/* Ad Placements */
.ad-slot-container {
    min-height: 60px;
    width: 100%;
}

.ad-house-card {
    position: relative;
    background: linear-gradient(135deg, #131326 0%, #1c1c38 100%);
    border: 1px solid #2a2a52;
    border-radius: 12px;
    padding: 12px 14px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.ad-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 9px;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 700;
}

.ad-house-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ad-house-icon {
    font-size: 26px;
    filter: drop-shadow(0 0 6px rgba(255, 204, 0, 0.4));
}

.ad-house-text {
    flex: 1;
    text-align: left;
}

.ad-house-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffcc00;
}

.ad-house-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.3;
}

.btn-ad-upgrade {
    background: #ffcc00;
    color: #0a0a1a;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s;
}

.btn-ad-upgrade:hover {
    background: #ffe066;
    transform: scale(1.05);
}

.ad-adsense-wrapper {
    position: relative;
    padding-top: 14px;
    min-height: 90px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* VIP & Active PRO Details */
.pro-active-banner {
    background: rgba(255, 204, 0, 0.1);
    border: 1px solid rgba(255, 204, 0, 0.3);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: #ffcc00;
    line-height: 1.4;
}

.vip-input {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    padding: 8px 12px;
    font-size: 12px;
    letter-spacing: 0.5px;
    outline: none;
    transition: border-color 0.2s;
}

.vip-input:focus {
    border-color: #ffcc00;
    box-shadow: 0 0 8px rgba(255, 204, 0, 0.25);
}

/* Daily Archive List & Cards */
.archive-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.archive-card:hover {
    border-color: rgba(0, 229, 255, 0.4);
    background: rgba(255, 255, 255, 0.06);
}

.archive-card-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.archive-emoji {
    font-size: 26px;
}

.archive-day-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.archive-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 2px;
}

.archive-score-badge {
    font-size: 10px;
    color: #00ff88;
    background: rgba(0, 255, 136, 0.12);
    border: 1px solid rgba(0, 255, 136, 0.25);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
}

.btn-archive-play {
    background: #00e5ff;
    color: #0a0a1a;
    font-weight: 700;
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    white-space: nowrap;
}

.btn-archive-play:hover {
    background: #33edff;
    transform: scale(1.05);
}

.btn-archive-lock {
    background: rgba(255, 204, 0, 0.12);
    color: #ffcc00;
    border: 1px solid rgba(255, 204, 0, 0.3);
    font-weight: 700;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s;
    white-space: nowrap;
}

.btn-archive-lock:hover {
    background: rgba(255, 204, 0, 0.22);
    transform: scale(1.04);
}



