:root {
    --bg: #12121f;
    --surface: #1b1b2f;
    --accent: #e94560;
    --accent-soft: #ff6b81;
    --gold: #ffd700;
    --cyan: #00d9ff;
    --text: #f4f4f8;
    --muted: #8a8aa3;
}

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

html, body {
    height: 100%;
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    /* Evita zoom por doble toque, selección accidental y el flash azul al tocar */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.container {
    width: 100%;
    max-width: 460px;
    padding: 16px;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.hidden {
    display: none !important;
}

/* ---------- Inicio ---------- */

.logo {
    font-size: clamp(38px, 13vw, 56px);
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1;
}

.logo span {
    color: var(--accent);
}

.tagline {
    color: var(--muted);
    font-size: 15px;
    margin-top: -10px;
}

.screen-title {
    font-size: 30px;
    color: var(--accent);
}

.stat-row {
    display: flex;
    gap: 28px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

/* ---------- Botones ---------- */

.btn {
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: transform .12s ease, background .2s ease;
}

.btn:active {
    transform: scale(.95);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    /* 56px de alto: objetivo táctil cómodo en móvil */
    padding: 18px 56px;
    font-size: 20px;
    box-shadow: 0 8px 24px rgba(233, 69, 96, .35);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1.5px solid #2f2f47;
    padding: 12px 20px;
    font-size: 14px;
}

.btn-daily {
    background: transparent;
    color: var(--cyan);
    border: 1.5px solid var(--cyan);
    padding: 13px 28px;
    font-size: 15px;
    margin-top: -6px;
}

.btn-daily b {
    color: var(--text);
}

.secondary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.icon-btn {
    background: transparent;
    border: 1.5px solid #2f2f47;
    color: var(--text);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

.icon-btn.small {
    width: 36px;
    height: 36px;
    font-size: 15px;
}

/* ---------- Juego ---------- */

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

.hud-best {
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
}

.hud-best b {
    color: var(--gold);
    font-size: 16px;
}

.canvas-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
}

#gameCanvas {
    display: block;
    border-radius: 50%;
    touch-action: none;
}

.coach-mark {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, .55);
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    text-align: center;
    pointer-events: none;
    animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: .65; }
    50% { opacity: 1; }
}

.shake {
    animation: shake .3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-9px) rotate(-1.5deg); }
    50% { transform: translateX(9px) rotate(1.5deg); }
    75% { transform: translateX(-9px) rotate(-1.5deg); }
}

/* ---------- Game Over ---------- */

.result-card {
    background: var(--surface);
    border-radius: 24px;
    padding: 26px 34px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.result-mode {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--cyan);
    margin-bottom: 2px;
}

.result-label {
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--muted);
}

.result-label.record {
    color: var(--gold);
}

.result-streak {
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 1px;
    word-break: break-all;
    max-width: 260px;
}

.result-score {
    font-size: 72px;
    font-weight: 800;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted);
}

.result-meta b {
    color: var(--text);
}

/* Flotante: lo disparan tanto el resultado como el menú, así que no puede
   vivir dentro de una pantalla (las ocultas van con display:none). */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    font-size: 13px;
    color: var(--gold);
    background: rgba(18, 18, 31, .95);
    border: 1.5px solid var(--gold);
    border-radius: 999px;
    padding: 10px 18px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    animation: toastIn .18s ease-out;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Tienda ---------- */

.shop-section {
    width: 100%;
}

.shop-section h3 {
    font-size: 13px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.shop-item {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    color: var(--muted);
}

.swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid #2f2f47;
    display: block;
    position: relative;
    transition: border-color .2s, transform .15s;
}

.shop-item:active .swatch {
    transform: scale(.92);
}

.shop-item.owned .swatch {
    border-color: #00ff88;
}

.shop-item.equipped .swatch {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(255, 215, 0, .6);
}

.shop-item.equipped .swatch::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    text-shadow: 0 0 4px #000;
}

.shop-item.locked .swatch {
    opacity: .4;
}

.swatch-name {
    font-size: 11px;
}

/* ---------- Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    padding: 36px 44px;
    border-radius: 20px;
    text-align: center;
}

.modal-content h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.timer {
    font-size: 48px;
    font-weight: 800;
    color: var(--gold);
}

/* ---------- Milestone ---------- */

.milestone-text {
    position: fixed;
    top: 50%;
    left: 50%;
    font-size: clamp(28px, 9vw, 44px);
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, .8);
    animation: milestonePulse 1.6s ease-out forwards;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

@keyframes milestonePulse {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
    20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    75%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
