/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a1a;
    --bg-card: #12122a;
    --accent: #00f0ff;
    --accent-glow: rgba(0, 240, 255, 0.3);
    --gold: #ffd700;
    --text: #e0e0ff;
    --text-muted: #7a7a9a;
    --danger: #ff4757;
    --success: #2ed573;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Inter', sans-serif;
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ===== GAME WRAPPER ===== */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

/* ===== HEADER ===== */
#header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(to bottom, rgba(10, 10, 26, 0.95), transparent);
}

.logo {
    display: flex;
    align-items: center;
    font-family: 'Righteous', 'Orbitron', sans-serif;
    font-size: clamp(14px, 2.5vw, 22px);
    color: var(--accent);
    text-decoration: none;
    text-shadow: 0 0 12px var(--accent-glow);
    letter-spacing: 1px;
    white-space: nowrap;
}

/* Sound Toggle */
.sound-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    margin: 0 8px;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.sound-toggle:hover {
    background: rgba(0, 240, 255, 0.12);
    color: var(--accent);
}

.sound-toggle .hidden {
    display: none;
}

.score-display {
    flex: 1;
    text-align: center;
}

.best-display {
    flex: 1;
    text-align: right;
}

.score-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

#score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(20px, 3vw, 32px);
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
}

#best-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
}

/* ===== CANVAS ===== */
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* ===== OVERLAYS ===== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 20px 24px 90px;
    max-width: 500px;
    width: 90%;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.overlay-content::-webkit-scrollbar {
    display: none;
}

/* ===== START SCREEN ===== */
.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(40px, 8vw, 72px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 6px;
    color: var(--text);
    margin-bottom: 10px;
}

.game-title span {
    color: var(--accent);
    text-shadow: 0 0 40px var(--accent-glow);
}

.subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.instructions {
    margin-top: 30px;
}

.instructions p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 6px 0;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 14px 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #0080ff);
    color: #000;
    box-shadow: 0 4px 30px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 40px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    padding: 10px 24px;
    font-size: 13px;
}

.btn-secondary:hover {
    background: rgba(0, 240, 255, 0.1);
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 30px var(--accent-glow); }
    50% { box-shadow: 0 4px 50px rgba(0, 240, 255, 0.6); }
}

/* ===== GAME OVER ===== */
.gameover-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    color: var(--danger);
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(255, 71, 87, 0.4);
}

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 6px;
}

.final-score-label {
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--text-muted);
}

.final-score-number {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 900;
    color: var(--accent);
    text-shadow: 0 0 30px var(--accent-glow);
    line-height: 1.2;
}

.new-record {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    color: var(--gold);
    margin-bottom: 8px;
    animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

/* ===== LEADERBOARD INPUT ===== */
.leaderboard-input {
    display: flex;
    gap: 8px;
    margin: 12px 0;
    justify-content: center;
}

#player-name {
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    border: 2px solid rgba(0, 240, 255, 0.3);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    outline: none;
    width: 160px;
    transition: border-color 0.3s;
}

#player-name:focus {
    border-color: var(--accent);
}

#player-name::placeholder {
    color: var(--text-muted);
}

/* ===== LEADERBOARD ===== */
.leaderboard {
    margin: 12px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(0, 240, 255, 0.1);
}

.leaderboard h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    color: var(--gold);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.2s;
}

.leaderboard-entry:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-entry .rank {
    width: 28px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: var(--text-muted);
    text-align: left;
}

.leaderboard-entry:nth-child(1) .rank { color: var(--gold); }
.leaderboard-entry:nth-child(2) .rank { color: #c0c0c0; }
.leaderboard-entry:nth-child(3) .rank { color: #cd7f32; }

.leaderboard-entry .name {
    flex: 1;
    text-align: left;
    color: var(--text);
}

.leaderboard-entry .entry-score {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    color: var(--accent);
}

/* ===== PERFECT INDICATOR ===== */
.perfect-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
    z-index: 15;
    pointer-events: none;
    animation: perfectPop 0.8s ease-out forwards;
}

.perfect-indicator.hidden {
    display: none;
}

@keyframes perfectPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* ===== ADS ===== */

/* Bottom Banner */
.ad-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.95);
    border-top: 1px solid rgba(0, 240, 255, 0.1);
    padding: 4px 0;
    min-height: 60px;
}

.ad-placeholder {
    width: min(320px, 90vw);
    height: 50px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-muted);
}

.ad-placeholder-lg {
    width: min(300px, 85vw);
    height: 250px;
    font-size: 12px;
}

/* Interstitial Ad */
.ad-interstitial {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.ad-interstitial.hidden {
    display: none;
}

.ad-interstitial-inner {
    position: relative;
    text-align: center;
    padding: 20px;
}

.ad-close-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
}

.ad-close-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.ad-close-btn:hover {
    background: rgba(255, 71, 87, 0.4);
    border-color: var(--danger);
}

.ad-skip-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 14px;
    letter-spacing: 1px;
}

/* Rewarded Ad */
.ad-rewarded {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ad-rewarded.hidden {
    display: none;
}

.ad-rewarded-inner {
    text-align: center;
    padding: 40px 30px;
    max-width: 360px;
    width: 85%;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid rgba(0, 240, 255, 0.15);
    box-shadow: 0 8px 60px rgba(0, 0, 0, 0.5);
}

.ad-rewarded-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 10px;
    text-shadow: 0 0 20px var(--accent-glow);
}

.ad-rewarded-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.ad-skip-btn {
    display: block;
    margin: 14px auto 0;
    font-size: 12px;
    padding: 8px 20px;
}

/* ===== SHARE BUTTONS ===== */
.share-section {
    margin: 10px 0 6px;
}

.share-label {
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.share-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.share-btn:hover {
    transform: translateY(-2px);
}

.share-native:hover {
    background: rgba(0, 240, 255, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.share-x:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: #fff;
    color: #fff;
}

.share-fb:hover {
    background: rgba(24, 119, 242, 0.2);
    border-color: #1877f2;
    color: #1877f2;
}

.share-wa:hover {
    background: rgba(37, 211, 102, 0.15);
    border-color: #25d366;
    color: #25d366;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    #header { padding: 16px 40px; }
    .instructions p { font-size: 15px; }
    .subtitle { font-size: 18px; }
    .leaderboard { max-width: 450px; margin-left: auto; margin-right: auto; }
    .leaderboard-input { justify-content: center; }
    .btn { padding: 16px 50px; font-size: 18px; }
    .final-score-number { font-size: clamp(48px, 8vw, 64px); }
}

/* Laptop screens with limited height */
@media (max-height: 800px) {
    .overlay-content { padding: 12px 20px 70px; }
    .gameover-title { font-size: 24px; margin-bottom: 6px; }
    .final-score-number { font-size: 40px; }
    .final-score-label { font-size: 10px; }
    .final-score { margin-bottom: 4px; }
    .new-record { font-size: 14px; margin-bottom: 4px; }
    .leaderboard-input { margin: 8px 0; }
    #player-name { padding: 8px 14px; font-size: 13px; }
    .leaderboard { margin: 8px 0; padding: 8px 12px; }
    .leaderboard h3 { margin-bottom: 6px; font-size: 12px; }
    .leaderboard-entry { padding: 4px 10px; font-size: 12px; }
    .share-section { margin: 6px 0 4px; }
    .share-btn { width: 34px; height: 34px; }
    .btn { padding: 10px 32px; font-size: 14px; }
    .ad-banner { min-height: 50px; }
}

@media (max-width: 400px) {
    .btn { padding: 12px 30px; font-size: 14px; }
    #header { padding: 8px 12px; }
    .final-score-number { font-size: 48px; }
    .game-title { font-size: clamp(32px, 10vw, 48px); letter-spacing: 3px; }
    .gameover-title { font-size: 28px; }
    .overlay-content { padding: 20px 16px 80px; }
    .leaderboard { padding: 10px; margin: 12px 0; }
    .leaderboard-input { flex-direction: column; align-items: center; }
    #player-name { width: 100%; max-width: 220px; }
    .ad-rewarded-inner { padding: 30px 20px; }
    .ad-rewarded-title { font-size: 22px; }
    .ad-banner { min-height: 54px; }
}

/* ===== AD BLOCKER POPUP ===== */
.adblock-popup,
.offline-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.adblock-popup.hidden,
.offline-popup.hidden {
    display: none;
}

.adblock-inner,
.offline-inner {
    text-align: center;
    padding: 40px 30px;
    max-width: 400px;
    width: 88%;
    background: var(--bg-card);
    border-radius: 24px;
    border: 1px solid rgba(255, 71, 87, 0.25);
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
}

.offline-inner {
    border-color: rgba(0, 240, 255, 0.2);
}

.adblock-icon,
.offline-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.adblock-title,
.offline-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 900;
    color: var(--danger);
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.offline-title {
    color: var(--accent);
}

.adblock-desc,
.offline-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

.adblock-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 16px;
    letter-spacing: 1px;
    opacity: 0.6;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}
