/* Gameplay V1 - carregar després d'app.css i dialogs.css */
.gameplay {
  box-sizing:border-box; width:100%; max-width:none; height:100dvh; min-height:0;
  padding:0 !important; margin:0 !important; gap:0 !important;
  display:flex !important; flex-direction:column; align-items:stretch;
  overflow:hidden; position:relative;
}
.play-header {
  box-sizing:border-box; height:56px; min-height:56px; flex:0 0 56px;
  width:100%; display:grid; grid-template-columns:56px minmax(0,1fr) 56px;
  align-items:center; padding:0 max(8px,env(safe-area-inset-right)) 0 max(8px,env(safe-area-inset-left));
  border-bottom:1px solid color-mix(in srgb,currentColor 18%,transparent);
  background:var(--game-surface,#222); z-index:2;
}
.play-header .play-icon {
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  width:44px; height:44px; min-width:44px; min-height:44px; padding:0;
  border:0; background:transparent; color:var(--game-text,inherit); font-size:1.45rem;
  justify-self:center; cursor:pointer;
}
.play-clock { display:flex; justify-content:center; align-items:center; gap:.45rem; min-width:0; white-space:nowrap; }
.play-clock .game-time { font-size:clamp(.95rem,3.7vw,1.1rem); font-weight:600; margin:0; }
.play-stage-count { font-size:.78rem; opacity:.55; margin:0; }
.inventory-badge {
  position:absolute; top:1px; right:0; display:flex; justify-content:center; align-items:center;
  min-width:19px; height:19px; padding:0 4px; box-sizing:border-box;
  border-radius:12px; font-size:.68rem; font-weight:700;
  color:var(--game-surface,#222); background:var(--game-text,#fff);
}
.stage-shell { display:flex; flex:1 1 auto; flex-direction:column; min-height:0; width:100%; gap:0; }
.stage-content {
  flex:1 1 auto; min-height:0; width:100%; overflow-y:auto; overscroll-behavior:contain;
  display:flex; flex-direction:column; justify-content:safe center;
  padding:clamp(12px,3vw,24px); box-sizing:border-box;
}
.stage-slide {
  width:100%; max-width:900px; min-height:0; margin:auto;
  display:flex; flex-direction:column; justify-content:center; align-items:center;
  gap:clamp(.6rem,2vh,1.2rem); animation:stage-enter .22s ease-out;
}
.stage-slide .gameplay-title { font-size:clamp(1.15rem,4vw,1.75rem); text-align:center; margin:0; }
.stage-slide .stage-text {
  font-size:clamp(1.08rem,3.7vw,1.4rem); line-height:1.65;
  white-space:pre-line; text-align:center; margin:0; max-width:760px;
}
.stage-slide img, .stage-slide .stage-image, .stage-slide .stage-media {
  display:block; max-width:100%; max-height:calc(100dvh - 180px);
  width:auto; height:auto; object-fit:contain; border-radius:var(--radius,12px);
}
.stage-slide video { width:100%; max-width:900px; max-height:calc(100dvh - 180px); object-fit:contain; }
.stage-slide audio { width:min(100%,560px); }
.stage-navigation {
  box-sizing:border-box; flex:0 0 auto; min-height:64px; width:100%;
  display:grid; grid-template-columns:56px minmax(0,1fr) 56px;
  align-items:center; gap:.5rem;
  padding:6px max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  border-top:1px solid color-mix(in srgb,currentColor 18%,transparent);
  background:var(--game-surface,#222);
}
.stage-navigation .button { width:48px; height:48px; min-height:48px; padding:0; font-size:1.4rem; justify-self:center; }
.stage-navigation .button[hidden] { display:none; }
.stage-counter { text-align:center; font-size:.85rem; opacity:.7; margin:0; }
.stage-tests { display:flex; flex-direction:column; gap:1rem; width:min(100%,720px); margin:auto; padding:8px 0; }
.stage-tests>.gameplay-title { font-size:1.3rem; margin:0; }
.stage-tests .game-card { width:100%; box-sizing:border-box; }
.stage-tests form { display:flex; flex-direction:column; gap:.7rem; }
.stage-tests .stage-answer { width:100%; box-sizing:border-box; }
.stage-tests .form-error:empty { display:none; }
.stage-tests .button { max-width:100%; }
.game-state-body { flex:1 1 auto; min-height:0; overflow:auto; padding:clamp(16px,4vw,32px); display:flex; flex-direction:column; gap:1rem; align-items:stretch; max-width:800px; width:100%; box-sizing:border-box; margin:0 auto; }
.game-state-body .gameplay-title { margin:.5rem 0; }
.media-play-fallback { align-self:center; margin-top:.5rem; }
.game-overlay {
  position:fixed; inset:0; z-index:1100; background:rgba(0,0,0,.78);
  display:flex; justify-content:center; align-items:flex-end;
}
.inventory-panel {
  box-sizing:border-box; width:100%; max-width:680px; max-height:90dvh;
  overflow-y:auto; padding:1.25rem; border-radius:18px 18px 0 0;
  background:var(--game-surface,#222); color:var(--game-text,#fff);
  box-shadow:0 -10px 50px rgba(0,0,0,.35);
}
.inventory-head { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin-bottom:1rem; }
.inventory-head .gameplay-title { margin:0; font-size:1.35rem; }
.inventory-close { width:44px; height:44px; min-width:44px; padding:0; }
.inventory-item { padding:.9rem; border:1px solid color-mix(in srgb,currentColor 40%,transparent); border-radius:var(--radius,12px); margin:.6rem 0; }
.inventory-item summary { cursor:pointer; font-weight:600; }
.inventory-item .stage-media, .help-panel .stage-media { max-width:100%; max-height:55vh; object-fit:contain; margin-top:.8rem; }
.menu-panel { max-width:420px; }
.menu-panel>.gameplay-title { margin:1.25rem 0 .5rem; font-size:1rem; text-transform:uppercase; opacity:.75; letter-spacing:.04em; }
.menu-title-row { display:flex; align-items:center; justify-content:space-between; gap:.75rem; margin:.6rem 0; }
.menu-title-row .gameplay-title { margin:0; font-size:1.15rem; }
.menu-title-row .button, .menu-code-row .button { flex:0 0 auto; width:auto; min-width:44px; min-height:40px; padding:.35rem .6rem; }
.menu-row { display:flex; justify-content:space-between; gap:1rem; margin:.5rem 0; align-items:baseline; }
.menu-label { opacity:.7; margin:0; font-size:.88rem; }
.menu-value { margin:0; font-weight:600; text-align:right; overflow-wrap:anywhere; }
.menu-code-row { display:flex; justify-content:space-between; gap:.5rem; align-items:center; }
.menu-code-row .menu-row { flex:1 1 auto; min-width:0; }
.menu-description { line-height:1.5; opacity:.85; white-space:pre-line; }
@keyframes stage-enter { from { opacity:.4; transform:translateY(5px); } to { opacity:1; transform:none; } }
@media(min-width:700px) {
  .game-overlay { align-items:center; }
  .inventory-panel { border-radius:18px; }
  .menu-panel { margin-left:auto; margin-right:0; max-height:100dvh; min-height:100dvh; border-radius:18px 0 0 18px; }
}
@media(prefers-reduced-motion:reduce) { .stage-slide { animation:none; } }


/* =====================================================
   MENÚ COMPACTE — GAMEPLAY
   ===================================================== */

.game-overlay:has(.menu-panel) {
    justify-content: flex-start;
    align-items: stretch;
    background: rgba(0, 0, 0, .72);
}

.game-overlay .menu-panel {
    width: min(85vw, 380px);
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    border-radius: 0 16px 16px 0;
    overflow-y: auto;
    background: var(--game-surface, #1c1c1c);
    box-sizing: border-box;
}

/* Capçalera */

.menu-panel .inventory-head {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,.15);
}

.menu-panel .inventory-head .gameplay-title {
    font-size: 1.25rem;
    margin: 0;
}

.menu-panel .inventory-close {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 1.1rem;
}

/* Títol del joc */

.menu-panel .menu-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.menu-panel .menu-title-row .gameplay-title {
    font-size: 1.1rem;
    line-height: 1.3;
    margin: 0;
    text-align: left;
}

.menu-panel .menu-title-row .button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    flex-shrink: 0;
    font-size: 1rem;
}

/* Títols de secció */

.menu-panel > .gameplay-title {
    font-family: inherit;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
    opacity: .6;
    margin: 18px 0 7px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

/* Files de dades */

.menu-panel .menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    font-size: .85rem;
}

.menu-panel .menu-label {
    margin: 0;
    font-size: .85rem;
    font-weight: 400;
    opacity: .7;
}

.menu-panel .menu-value {
    margin: 0;
    font-size: .85rem;
    font-weight: 600;
    text-align: right;
}

/* Codi de partida */

.menu-panel .menu-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.menu-panel .menu-code-row .menu-row {
    flex: 1;
    min-width: 0;
}

.menu-panel .menu-code-row .button {
    width: auto;
    min-width: 0;
    min-height: 32px;
    padding: 5px 8px;
    font-size: .75rem;
    white-space: nowrap;
}

/* Descripció */

.menu-panel .menu-description {
    font-size: .82rem;
    line-height: 1.45;
    margin: 6px 0;
    opacity: .85;
}

/* Enllaços */

.menu-panel a {
    display: inline-block;
    margin-top: 8px;
    font-size: .82rem;
}

/* Pantalles petites */

@media (max-height: 700px) {
    .game-overlay .menu-panel {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .menu-panel > .gameplay-title {
        margin-top: 12px;
    }

    .menu-panel .menu-row {
        padding: 3px 0;
    }
}

.menu-panel {
    background: var(--game-menu-surface, var(--game-surface));
}

/* =====================================================
   AJUSTOS FINALS DEL MENÚ LATERAL
   ===================================================== */

.game-overlay:has(.menu-panel) {
    overscroll-behavior: contain;
}

.game-overlay .menu-panel {
    background: var(--game-menu-surface, var(--game-surface));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.menu-panel .menu-main-title {
    margin: 0 0 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.menu-panel .menu-main-title > .gameplay-title {
    flex: 1;
    min-width: 0;
    font-size: 1.1rem;
    line-height: 1.3;
}

.menu-panel .menu-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.menu-panel .menu-icon-button,
.menu-panel .inventory-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    margin: 0;
    border-radius: 9px;
    box-sizing: border-box;
    text-decoration: none;
    color: inherit;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
}

.menu-panel .menu-icon-button:hover,
.menu-panel .inventory-close:hover {
    background: color-mix(in srgb, currentColor 10%, transparent);
}

.menu-panel .menu-icon-button:focus-visible,
.menu-panel .inventory-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.menu-panel .menu-icon-button svg {
    display: block;
    width: 19px;
    height: 19px;
}

.menu-panel .menu-code-row .menu-icon-button {
    flex-shrink: 0;
}

.menu-panel .menu-organizer-row {
    margin-top: 12px;
    margin-bottom: 3px;
}

.menu-panel .menu-organizer-row > .menu-value {
    text-align: left;
    font-weight: 600;
}

.menu-panel .menu-organizer-row .menu-actions {
    margin-left: auto;
}

/* Diferenciem el total sense afegir més espai. */
.menu-panel .menu-row:has(.menu-label):last-of-type .menu-value {
    font-weight: 700;
}

/* El joc ocupa tota la pantalla, sense el padding general de #app */
#app:has(> .gameplay) {
    padding: 0;
    height: 100dvh;
    min-height: 0;
}

.gameplay audio.stage-media {
    display: block;
    width: 100%;
    height: 54px;
    min-height: 54px;
    flex-shrink: 0;
}

/* =========================================
   ETAPA SUPERADA
   ========================================= */

.stage-complete {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
    max-width: none;
    width: 100%;
    overflow: hidden;
}

/* Celebració */

.complete-celebration {
    flex: 0 0 auto;
    text-align: center;
    padding: clamp(18px, 3vh, 32px) 16px 16px;
    animation: stage-enter .3s ease-out;
}

.complete-check {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--game-secondary);
    border-radius: 50%;
    color: var(--game-secondary);
    font-size: 30px;
    font-weight: bold;
}

.complete-celebration .gameplay-title {
    margin: 0;
    font-size: clamp(1.6rem, 5vw, 2.2rem);
}

.complete-subtitle {
    margin: 10px 0 0;
    color: var(--game-muted);
    font-size: .95rem;
}

/* Carrusel */

.complete-carousel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

.complete-slide-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    justify-content: safe center;
}

.complete-reward {
    width: 100%;
    box-sizing: border-box;
    padding: clamp(18px, 4vw, 28px);
    margin: auto;
    background: var(--game-surface);
    border: 1px solid color-mix(
        in srgb,
        var(--game-secondary) 35%,
        transparent
    );
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    animation: stage-enter .22s ease-out;
}

.complete-reward-eyebrow {
    text-align: center;
    color: var(--game-secondary);
    font-size: .75rem;
    font-weight: bold;
    letter-spacing: .1em;
}

.complete-reward-title {
    margin: 0;
    text-align: center;
    font-family: var(--font-title);
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    color: var(--game-text);
}

.complete-reward-content {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.complete-reward-content .stage-media {
    max-width: 100%;
}

.complete-reward-content img,
.complete-reward-content video {
    max-height: 42dvh;
    object-fit: contain;
}

.complete-reward-content audio {
    width: 100%;
    height: 54px;
    min-height: 54px;
    flex-shrink: 0;
}

.complete-reward-content .stage-text {
    margin: 0;
    line-height: 1.6;
    text-align: center;
}

.complete-inventory {
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid color-mix(
        in srgb,
        var(--game-text) 12%,
        transparent
    );
    color: var(--game-secondary);
    font-size: .85rem;
    text-align: center;
}

/* Navegació */

.complete-navigation {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    gap: 8px;
    padding: 8px 20px 12px;
}

.complete-navigation .button {
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    font-size: 1.4rem;
    justify-self: center;
}

.complete-counter {
    margin: 0;
    text-align: center;
    color: var(--game-muted);
    font-size: .9rem;
}

/* Accions */

.complete-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding:
        14px
        max(20px, env(safe-area-inset-right))
        max(18px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));
    border-top: 1px solid color-mix(
        in srgb,
        var(--game-text) 12%,
        transparent
    );
    background: var(--game-background);
}

.complete-actions .button {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.complete-actions .button:disabled {
    opacity: .35;
    cursor: not-allowed;
}

/* Pantalles baixes */

@media (max-height: 650px) {
    .complete-celebration {
        padding: 10px 16px;
    }

    .complete-check {
        width: 40px;
        height: 40px;
        font-size: 23px;
        margin-bottom: 8px;
    }

    .complete-reward {
        padding: 14px;
        gap: 10px;
    }

    .complete-slide-area {
        padding: 8px 16px;
    }
}

/* Descobertes: estructura amb controls sempre visibles */

.complete-discoveries {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.complete-discoveries .complete-carousel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.complete-discoveries .complete-slide-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Indicador d'inventari fora de la zona amb scroll */

.complete-inventory-notice {
    flex: 0 0 auto;
    margin: 0;
    padding: 10px 16px;
    text-align: center;
    color: var(--game-secondary);
    font-size: .85rem;
}

.complete-inventory-notice[hidden] {
    display: none;
}

/* Navegació sempre visible sota el contingut */

.complete-discoveries .complete-navigation {
    flex: 0 0 auto;
    padding: 8px 16px;
}

/* Botó inferior sempre visible */

.complete-discoveries .complete-actions {
    flex: 0 0 auto;
}

/* =========================================
   VISOR D'IMATGES AMB ZOOM
   ========================================= */

.image-zoomable {
    cursor: zoom-in;
}

.image-zoomable:focus-visible {
    outline: 2px solid var(--game-secondary);
    outline-offset: 4px;
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, .97);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-viewer-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}

.image-viewer-viewport:active {
    cursor: grabbing;
}

.image-viewer-image {
    position: absolute;
    top: 50%;
    left: 50%;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform: translate(0, 0) scale(1);
    translate: -50% -50%;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.image-viewer-close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 2;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    background: rgba(30, 30, 30, .85);
    color: white;
    font-size: 22px;
    cursor: pointer;
}

/* =========================================================
   PISTES I SOLUCIONS - TARGETA DE REVELACIÓ
   ========================================================= */

/* Pregunta original */

.help-panel .help-question {
    margin: 8px 0 20px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #aaa69e;
    font-weight: 400;
}


/* Targeta principal */

.help-panel .help-reveal {
    position: relative;
    margin: 0;
    padding: 24px 20px 28px;

    background:
        linear-gradient(
            145deg,
            rgba(200, 149, 69, 0.10),
            rgba(200, 149, 69, 0.025)
        );

    border: 1px solid rgba(200, 149, 69, 0.55);
    border-radius: 14px;

    text-align: center;
}


/* Ornament */

.help-panel .help-ornament {
    margin-bottom: 12px;

    font-family: Georgia, serif;
    font-size: 1.6rem;
    line-height: 1;

    color: #c89545;
}


/* Contingut */

.help-panel .help-content {
    padding: 0;
    border: 0;
    background: none;
    text-align: center;
}

.help-panel .help-content .stage-text {
    margin: 0;

    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.55;

    color: #f2f0eb;

    overflow-wrap: anywhere;
}


/* Imatges, vídeos i àudios */

.help-panel .help-content .stage-media {
    display: block;

    max-width: 100%;
    max-height: 45vh;

    margin: 0 auto;

    object-fit: contain;
    border-radius: 10px;
}

.help-panel .help-content audio {
    width: 100%;
}


/* Penalització: informació secundària */

.help-panel .help-penalty {
    display: block;

    margin: 18px 0 0;
    padding: 0;

    background: none;
    border: 0;

    color: #aaa69e;
    font-size: 0.82rem;
    font-weight: 400;
    text-align: center;
}


/* Prova superada */

.help-panel .help-solved-message {
    margin: 12px 0 0;

    color: #a5d6a7;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}


/* =========================================================
   DIFERENCIACIÓ DE LES SOLUCIONS
   ========================================================= */

.help-panel.help-solution .help-reveal {
    background:
        linear-gradient(
            145deg,
            rgba(155, 28, 28, 0.14),
            rgba(155, 28, 28, 0.025)
        );

    border-color: rgba(155, 28, 28, 0.65);
}

.help-panel.help-solution .help-ornament {
    color: #d66b6b;
}


/* =========================================================
   AJUSTOS PER A MÒBIL
   ========================================================= */

@media (max-width: 480px) {

    .help-panel .help-reveal {
        padding: 20px 16px 24px;
    }

    .help-panel .help-content .stage-text {
        font-size: 1.2rem;
    }

    .help-panel .help-question {
        font-size: 0.85rem;
    }
}

/* =========================================================
   FONS COMÚ: MENÚ, INVENTARI, PISTES I SOLUCIONS
   ========================================================= */

.game-overlay .inventory-panel {
    background: var(
        --game-menu-surface,
        var(--game-surface, #1c1c1c)
    );
}

/* Ombra dels panells inferiors */
.game-overlay .inventory-panel:not(.menu-panel) {
    box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.35);
}

/* ============================================
   CELEBRACIÓ FINAL
   ============================================ */

.game-victory .complete-celebration {
    animation: victoryAppear 0.8s ease-out both;
}

.victory-trophy {
    font-size: 4rem;
    animation: victoryGlow 2.5s ease-in-out infinite alternate;
}

.victory-results {
    text-align: center;
    padding: 1.5rem 1rem;
    margin: 1.5rem 0;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.victory-time-label {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.7;
}

.victory-time {
    font-size: clamp(2.5rem, 9vw, 4rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #d4af37;
    margin: 0.5rem 0;
}

.victory-penalty {
    font-size: 0.85rem;
    opacity: 0.65;
}

@keyframes victoryAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes victoryGlow {
    from {
        filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.2));
    }

    to {
        filter: drop-shadow(0 0 25px rgba(212, 175, 55, 0.65));
    }
}

@media (prefers-reduced-motion: reduce) {
    .game-victory .complete-celebration,
    .victory-trophy {
        animation: none;
    }
}

.victory-ranking-position {
    margin-top: 1.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #d4af37;
}

/* ============================================
   CLASSIFICACIÓ
   ============================================ */

.ranking-screen {
    padding-bottom: 6rem;
}

.ranking-search {
    position: relative;
    margin: 1.5rem 0;
}

.ranking-search input {
    width: 100%;
    padding: 1rem;
    border: 1px solid #a67c2e;
    border-radius: 12px;
    background: #1c1c1c;
    color: #fff;
    font-size: 1rem;
}

.ranking-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 280px;
    overflow-y: auto;
    background: #242424;
    border: 1px solid #a67c2e;
    border-radius: 10px;
}

.ranking-suggestions[hidden] {
    display: none;
}

.ranking-suggestion {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-radius: 0;
    padding: 0.8rem 1rem;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ranking-card {
    padding: 1.5rem;
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 16px;
    text-align: center;
}

.ranking-team-name {
    margin: 0 0 1rem;
    font-size: 1.4rem;
}

.ranking-total-time {
    font-size: clamp(2rem, 7vw, 3rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #d4af37;
}

.ranking-penalty {
    font-size: 0.85rem;
    color: #aaa;
}

.ranking-top-1 {
    border-color: #d4af37;
}

.ranking-top-2 {
    border-color: #a8a8a8;
}

.ranking-top-3 {
    border-color: #a97142;
}

.ranking-mine {
    background: #252015;
    border: 2px solid #d4af37;
}

.ranking-mine-label {
    margin-top: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #d4af37;
}

.ranking-highlight {
    outline: 3px solid #d4af37;
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.35);
}

.ranking-load-previous {
    width: 100%;
}

.ranking-sentinel {
    height: 1px;
}

.ranking-actions {
    margin-top: 2rem;
}

.ranking-actions .button {
    width: 100%;
}

/* ============================================
   CLASSIFICACIÓ: SCROLL VERTICAL
   ============================================ */

.screen.gameplay.ranking-screen {
    height: 100dvh;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-bottom: 3rem;
}

.ranking-screen .ranking-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ranking-screen .ranking-actions {
    margin-top: 2rem;
    padding-bottom: 2rem;
}

/* ============================================
   CLASSIFICACIÓ EN FORMAT TAULA
   ============================================ */

.ranking-row {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;

    padding: 0.65rem 0.4rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-width: 0;
}

.ranking-row-position {
    font-weight: 700;
    color: #d4af37;
    white-space: nowrap;
}

.ranking-row-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-row-result {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ranking-row-time {
    font-weight: 700;
    color: #d4af37;
}

.ranking-row-penalty {
    font-size: 0.75rem;
    color: #999;
}

/* El nostre equip */

.ranking-row.ranking-mine {
    background: rgba(212,175,55,0.1);
    border-left: 3px solid #d4af37;
}
