/* ==========================================================================
   Encuentra la pieza — MexcoParts
   Mismo lenguaje visual que Trivia Vocho: azul VW, tipografía clara, grande.
   ========================================================================== */

:root {
    --bg: #fafafb;
    --surface: #ffffff;
    --ink: #10233f;
    --ink-soft: #1d3a66;
    --muted: #6a6f7b;
    --line: #e6e7eb;
    --line-strong: #d3d5db;
    --hover: #f3f4f6;

    --good: #15803d;
    --good-bg: #e9f7ee;
    --bad: #d92d20;
    --bad-bg: #fdeeec;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --r: 12px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(20px, 7vh, 72px) clamp(16px, 5vw, 32px) 40px;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h2,
p {
    margin: 0;
}

h2 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

/* ---------- Contenedor ---------- */
.container {
    width: 100%;
    max-width: 640px;
    min-width: 0;
}

/* Wordmark */
.container::before {
    content: "MexcoParts · Encuentra la pieza";
    display: block;
    margin-bottom: clamp(28px, 6vh, 48px);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 22px;
}

/* ---------- Pantallas ---------- */
.screen {
    display: none;
    min-width: 0;
}

.screen.active {
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Botón principal ---------- */
.btn {
    width: 100%;
    min-height: 56px;
    padding: 14px 24px;
    font: inherit;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #fff;
    background: var(--ink);
    border: 0;
    border-radius: var(--r);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.12s var(--ease);
}

.btn:hover:not(:disabled) { background: var(--ink-soft); }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ==========================================================================
   PANTALLA DE INICIO
   ========================================================================== */
#start-screen.active {
    display: flex;
    flex-direction: column;
}

#start-screen > h2 {
    font-size: clamp(1.625rem, 5vw, 2rem);
}

#start-screen > p {
    margin: 8px 0 28px;
    color: var(--muted);
    font-size: 1.0625rem;
}

.foot-note {
    margin-top: 20px !important;
    font-size: 0.8125rem !important;
    color: var(--muted);
}

/* Guía "¿Cómo se juega?" */
.howto {
    margin: 4px 0 28px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.howto-title {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 700;
}

.howto-steps {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.howto-steps li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.9375rem;
    color: var(--ink);
    line-height: 1.45;
}

.howto-num {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
}

.howto-steps .ok {
    color: var(--good);
}

.howto-steps .no {
    color: var(--bad);
}

/* ==========================================================================
   PANTALLA DE JUEGO
   ========================================================================== */
#game-screen.active {
    display: flex;
    flex-direction: column;
}

.game-top {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}

.prompt-label {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.prompt-name {
    font-size: clamp(1.375rem, 5vw, 1.75rem);
    font-weight: 700;
    line-height: 1.25;
}

.game-info {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    font-size: 0.9375rem;
    color: var(--muted);
}

.game-info p:last-child {
    font-weight: 600;
    color: var(--ink);
}

.game-info span {
    font-variant-numeric: tabular-nums;
}

/* Foto del motor */
.photo-wrap {
    position: relative;
    border-radius: var(--r);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(17, 19, 24, 0.05);
}

#photo {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    user-select: none;
    -webkit-user-drag: none;
}

.marker-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.pin {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 1.125rem;
    font-weight: 700;
    pointer-events: none;
}

.pin-ok {
    background: var(--good);
    color: #fff;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    animation: pin-pop 0.35s var(--ease);
}

.pin-no {
    background: var(--bad);
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    animation: pin-pop 0.2s ease;
}

.pin-debug {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(16, 35, 63, 0.9);
    color: #fff;
    border: 2px solid #fff;
    font-size: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

@keyframes pin-pop {
    from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#photo.shake {
    animation: shake 0.4s;
}

@keyframes shake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Lista de piezas (chips) */
.parts-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.part-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    cursor: default;
    transition: opacity 0.25s, border-color 0.25s, background-color 0.25s;
}

.part-chip.found {
    opacity: 0.55;
    text-decoration: line-through;
    background: var(--good-bg);
    border-color: var(--good);
    color: var(--good);
}

/* Caja de calibración */
.calib-box {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
}

.calib-box p {
    font-size: 0.9375rem;
    color: var(--muted);
    margin: 0 0 8px;
}

.calib-box .howto-title {
    color: var(--ink);
    margin-bottom: 4px;
}

.calib-box textarea {
    width: 100%;
    font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    resize: vertical;
    color: var(--ink);
    background: var(--bg);
}

.calib-box .btn {
    margin-top: 10px;
}

.calib-legend {
    margin: 0 0 8px;
    padding: 10px 14px;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.calib-legend li {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--ink);
}

.calib-legend strong {
    color: var(--ink-soft);
}

.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line-strong);
}

.btn-ghost:hover {
    background: var(--hover);
}

/* Barra de progreso */
.progress-bar {
    height: 4px;
    margin-top: 18px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.progress {
    width: 0;
    height: 100%;
    background: var(--ink);
    border-radius: inherit;
    transition: width 0.45s var(--ease);
}

/* ==========================================================================
   RESULTADO
   ========================================================================== */
#result-screen.active {
    display: flex;
    flex-direction: column;
}

#result-screen > h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0;
}

.result-info {
    margin: 12px 0 32px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.result-info p {
    font-size: 1.0625rem;
    color: var(--muted);
}

#final-found {
    font-size: clamp(4rem, 17vw, 5.5rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.05em;
    color: var(--ink);
}

#final-total {
    font-weight: 600;
    color: var(--ink);
}

#result-message {
    margin-top: 14px;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.result-stats {
    margin-top: 10px !important;
    font-size: 0.9375rem !important;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (min-width: 1400px) {
    html {
        font-size: 106.25%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
