/* ================================================================
   ZEROBLINK PORTAL — DESIGN SYSTEM (global.css)
   Shared across all pages. No external dependencies except Inter font.
   ================================================================ */

/* ---- Font Import (preconnect handled in HTML <head>) ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap');

/* ================================================================
   1. DESIGN TOKENS
   ================================================================ */
:root {
    /* Backgrounds */
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #111111;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.07);
    --bg-glass-active: rgba(255, 255, 255, 0.10);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --text-dim: #555555;

    /* Accent Palette */
    --accent-cyan: #00ffcc;
    --accent-red: #ff3333;
    --accent-gold: #ffd700;
    --accent-blue: #4488ff;
    --accent-purple: #b44aff;
    --accent-green: #44ff88;

    /* Glow Shadows */
    --glow-cyan: 0 0 20px rgba(0, 255, 204, 0.35);
    --glow-red: 0 0 20px rgba(255, 51, 51, 0.35);
    --glow-gold: 0 0 20px rgba(255, 215, 0, 0.35);
    --glow-blue: 0 0 20px rgba(68, 136, 255, 0.35);
    --glow-purple: 0 0 20px rgba(180, 74, 255, 0.35);

    /* Borders */
    --border-subtle: #1a1a1a;
    --border-medium: #333333;
    --border-strong: #555555;

    /* Spacing Scale */
    --space-2xs: 4px;
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 20px;
    --space-lg: 32px;
    --space-xl: 48px;
    --space-2xl: 64px;

    /* Typography */
    --font-mono: 'Courier New', Courier, monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;

    /* Z-Index Scale */
    --z-canvas: 1;
    --z-ui: 5;
    --z-overlay: 10;
    --z-modal: 50;
    --z-toast: 100;
    --z-nav: 200;
}

/* ================================================================
   2. RESET & BASE
   ================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-cyan); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--text-primary); text-decoration: underline; }

/* ================================================================
   3. TYPOGRAPHY
   ================================================================ */
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }

h1, h2, h3 { color: var(--text-primary); font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: 3px; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.3rem); }
p { font-size: 1.05rem; color: var(--text-secondary); }

.highlight-red { color: var(--accent-red); }
.highlight-cyan { color: var(--accent-cyan); }
.highlight-gold { color: var(--accent-gold); }
.highlight { color: var(--text-primary); font-weight: bold; font-size: 1.5rem; }

/* ================================================================
   4. LAYOUT CONTAINERS
   ================================================================ */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

.container--narrow {
    max-width: 700px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

/* ================================================================
   5. NAVIGATION BAR
   ================================================================ */
.portal-nav {
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.portal-nav__logo {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 2px;
    text-decoration: none;
}

.portal-nav__logo:hover {
    color: var(--accent-cyan);
    text-decoration: none;
}

.portal-nav__links {
    display: flex;
    gap: var(--space-md);
    list-style: none;
}

.portal-nav__links a {
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color var(--transition-fast);
}

.portal-nav__links a:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* ================================================================
   6. BUTTONS
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 14px 28px;
    font-size: 1.1rem;
    font-family: var(--font-mono);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--text-primary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after { opacity: 0.08; }
.btn:active { transform: scale(0.97); }
.btn:active::after { opacity: 0.15; }

/* Button variants */
.btn--cyan { border-color: var(--accent-cyan); color: var(--accent-cyan); }
.btn--cyan:hover { box-shadow: var(--glow-cyan); }
.btn--cyan:active { background: var(--accent-cyan); color: var(--bg-primary); }

.btn--red { border-color: var(--accent-red); color: var(--accent-red); }
.btn--red:hover { box-shadow: var(--glow-red); }
.btn--red:active { background: var(--accent-red); color: var(--text-primary); }

.btn--gold { border-color: var(--accent-gold); color: var(--accent-gold); }
.btn--gold:hover { box-shadow: var(--glow-gold); }
.btn--gold:active { background: var(--accent-gold); color: var(--bg-primary); }

.btn--primary {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

.btn--primary:hover {
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.btn--small {
    padding: 8px 16px;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.btn--block { display: flex; width: 100%; max-width: 320px; }

.btn:disabled {
    border-color: var(--border-strong);
    color: var(--text-dim);
    cursor: not-allowed;
    background: transparent;
    box-shadow: none;
}

/* ================================================================
   7. GAME CARDS (Portal Hub)
   ================================================================ */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.game-card {
    position: relative;
    background: var(--bg-glass);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base) var(--ease-out-expo);
    overflow: hidden;
    text-decoration: none;
    display: block;
}

.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: conic-gradient(from var(--card-angle, 0deg), transparent 40%, var(--card-accent, var(--accent-cyan)) 50%, transparent 60%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.game-card:hover::before { opacity: 1; }

.game-card:hover {
    transform: translateY(-4px) scale(1.02);
    background: var(--bg-glass-hover);
    border-color: var(--border-strong);
}

.game-card__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-sm);
}

.game-card__title {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: var(--space-2xs);
    letter-spacing: 2px;
}

.game-card__tagline {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.game-card__badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: var(--radius-full);
    border: 1px solid;
}

.game-card__badge--reflexo { color: var(--accent-cyan); border-color: var(--accent-cyan); }
.game-card__badge--cromático { color: var(--accent-purple); border-color: var(--accent-purple); }
.game-card__badge--precisão { color: var(--accent-gold); border-color: var(--accent-gold); }

/* Featured card glow */
.game-card--featured {
    border-color: var(--accent-cyan);
    animation: borderRotate 4s linear infinite;
}

@property --card-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes borderRotate {
    to { --card-angle: 360deg; }
}

/* ================================================================
   8. OVERLAY SCREENS (Game UI)
   ================================================================ */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: var(--z-overlay);
}

.overlay-screen--blur {
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ================================================================
   9. LEADERBOARD COMPONENT
   ================================================================ */
.leaderboard {
    width: 90%;
    max-width: 420px;
    margin: 0 auto var(--space-md);
    min-height: 250px;
    font-size: 1rem;
    text-align: left;
    background: var(--bg-tertiary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
    overflow-y: auto;
    max-height: 50vh;
}

.lb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--bg-glass); }

.lb-rank { width: 32px; color: var(--accent-gold); font-weight: bold; }
.lb-name {
    flex-grow: 1;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}
.lb-loc { font-size: 0.7rem; color: var(--text-muted); margin-right: 10px; line-height: 1.5; }
.lb-score { color: var(--text-primary); font-weight: bold; min-width: 50px; text-align: right; }

/* Podium highlight */
.lb-row:nth-child(1) .lb-rank { color: var(--accent-gold); font-size: 1.1rem; }
.lb-row:nth-child(2) .lb-rank { color: #c0c0c0; }
.lb-row:nth-child(3) .lb-rank { color: #cd7f32; }

/* ================================================================
   10. SCORE SUBMISSION
   ================================================================ */
.score-submit {
    margin-top: var(--space-sm);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-glass);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-medium);
}

.score-submit__input {
    padding: 10px 16px;
    font-size: 1rem;
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    text-align: center;
    text-transform: uppercase;
    width: 80%;
    max-width: 250px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.score-submit__input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.15);
}

/* ================================================================
   11. AD CONTAINERS (AdSense-compliant)
   ================================================================ */
.ad-container {
    margin: var(--space-lg) auto;
    min-height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    overflow: hidden;
}

.ad-container--inline {
    margin: var(--space-lg) 0;
    padding: var(--space-xs) 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.ad-container--anchor {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-toast);
    min-height: 50px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-2xs);
    /* 150px+ distance from interactive elements enforced by layout */
}

.ad-label {
    display: block;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: var(--space-2xs);
}

/* ================================================================
   12. MODAL
   ================================================================ */
.modal-content {
    border: 2px solid var(--text-primary);
    padding: var(--space-lg);
    max-width: 90vw;
    width: 360px;
    text-align: center;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.modal-content h2 {
    font-size: 1.4rem;
    margin-top: 0;
    letter-spacing: 1px;
}

/* ================================================================
   13. TOAST NOTIFICATION
   ================================================================ */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 10px 24px;
    border-radius: var(--radius-md);
    display: none;
    z-index: var(--z-toast);
    font-weight: bold;
    text-align: center;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2);
    animation: toastIn 300ms var(--ease-out-back) forwards;
}

@keyframes toastIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ================================================================
   14. FOOTER
   ================================================================ */
.portal-footer {
    margin-top: var(--space-2xl);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-lg) var(--space-md);
}

.portal-footer a {
    color: var(--text-muted);
    margin: 0 var(--space-sm);
    transition: color var(--transition-fast);
}

.portal-footer a:hover { color: var(--text-primary); text-decoration: underline; }

/* ================================================================
   15. SECTION STYLES (Portal content)
   ================================================================ */
.section {
    margin-bottom: var(--space-xl);
}

.section__title {
    font-size: 1.5rem;
    margin-bottom: var(--space-md);
    padding-left: var(--space-sm);
    border-left: 4px solid var(--text-primary);
}

.section__title--cyan { border-color: var(--accent-cyan); }
.section__title--red { border-color: var(--accent-red); }
.section__title--gold { border-color: var(--accent-gold); }

.section__text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ================================================================
   16. ANIMATIONS & KEYFRAMES
   ================================================================ */

/* Pulse glow on CTA */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 204, 0.4); }
    50% { box-shadow: 0 0 20px 4px rgba(0, 255, 204, 0.2); }
}

.animate-pulse-glow { animation: pulseGlow 2s ease-in-out infinite; }

/* Record badge pulse */
@keyframes pulseRecord {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.7; transform: scale(1.05); }
}

/* Fade in up */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
    animation: fadeInUp 500ms var(--ease-out-expo) forwards;
}

/* Screen shake */
@keyframes screenShake {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-3px, 2px); }
    20% { transform: translate(3px, -2px); }
    30% { transform: translate(-2px, -1px); }
    40% { transform: translate(2px, 1px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(1px, -1px); }
    70% { transform: translate(-1px, 0); }
    80% { transform: translate(1px, 0); }
}

.shake { animation: screenShake 300ms ease-out; }

/* Float particles (background ambiance) */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* Spin for loading */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Combo popup float */
@keyframes comboFloat {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}

/* ================================================================
   17. AMBIENT PARTICLES (CSS-only, portal pages)
   ================================================================ */
.ambient-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-particles span {
    position: absolute;
    bottom: -10px;
    width: 3px;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    animation: float linear infinite;
}

.ambient-particles span:nth-child(1) { left: 10%; animation-duration: 18s; animation-delay: 0s; width: 2px; height: 2px; }
.ambient-particles span:nth-child(2) { left: 25%; animation-duration: 22s; animation-delay: 2s; }
.ambient-particles span:nth-child(3) { left: 40%; animation-duration: 16s; animation-delay: 4s; width: 4px; height: 4px; }
.ambient-particles span:nth-child(4) { left: 55%; animation-duration: 20s; animation-delay: 1s; }
.ambient-particles span:nth-child(5) { left: 70%; animation-duration: 24s; animation-delay: 3s; width: 2px; height: 2px; }
.ambient-particles span:nth-child(6) { left: 85%; animation-duration: 19s; animation-delay: 5s; }
.ambient-particles span:nth-child(7) { left: 15%; animation-duration: 21s; animation-delay: 7s; width: 2px; height: 2px; }
.ambient-particles span:nth-child(8) { left: 60%; animation-duration: 17s; animation-delay: 6s; }

/* ================================================================
   18. RESPONSIVE
   ================================================================ */
@media (max-width: 640px) {
    .portal-nav__links { gap: var(--space-sm); }
    .portal-nav__links a { font-size: 0.75rem; }
    .games-grid { grid-template-columns: 1fr; }
    .btn { padding: 12px 20px; font-size: 1rem; }
    .container { padding: var(--space-lg) var(--space-sm); }
}

@media (max-width: 400px) {
    .portal-nav { padding: var(--space-xs); }
    .portal-nav__logo { font-size: 1rem; }
}

/* ================================================================
   19. GAME-SPECIFIC SHARED (used by all game pages)
   ================================================================ */
.game-body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

.game-canvas { display: block; }

.game-ui {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    font-size: 1.2rem;
    font-weight: bold;
    display: none;
    width: calc(100% - 40px);
    justify-content: space-between;
    z-index: var(--z-ui);
}

.game-timer { color: var(--accent-red); }

.game-countdown {
    font-size: 6rem;
    font-weight: bold;
    display: none;
    user-select: none;
}

/* Instruction screen shared */
.inst-text {
    font-size: clamp(1rem, 4vw, 1.3rem);
    line-height: 1.6;
    width: 90%;
    max-width: 600px;
    margin: 0 auto var(--space-xl);
    color: #ddd;
    word-wrap: break-word;
}

/* Back to portal link */
.back-to-portal {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: var(--z-overlay);
    color: var(--text-dim);
    font-size: 0.8rem;
    text-decoration: none;
    letter-spacing: 1px;
    transition: color var(--transition-fast);
}

.back-to-portal:hover { color: var(--text-primary); text-decoration: none; }

/* Lang switcher (shared game UI) */
.lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.2rem;
    color: var(--text-dim);
    z-index: var(--z-toast);
    cursor: pointer;
    font-weight: bold;
}

.lang-switcher span {
    margin: 0 5px;
    transition: color 200ms ease;
}

.lang-switcher span.active {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Support section */
.support-wrapper {
    position: absolute;
    bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    width: 100%;
    padding: 0 var(--space-md);
}

.support-msg {
    font-size: 0.75rem;
    color: var(--text-dim);
    max-width: 280px;
    text-align: center;
    font-style: italic;
    margin: 0;
    line-height: 1.4;
}

/* Combo popup (floating score text) */
.combo-popup {
    position: absolute;
    pointer-events: none;
    font-family: var(--font-mono);
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    animation: comboFloat 800ms var(--ease-out-expo) forwards;
    z-index: var(--z-ui);
}

.combo-popup--ghost {
    color: var(--accent-cyan);
    text-shadow: 0 0 12px rgba(0, 255, 204, 0.6);
}

.combo-popup--penalty {
    color: var(--accent-red);
    text-shadow: 0 0 12px rgba(255, 51, 51, 0.6);
}
