.games-page {
    padding: 28px 0 46px;
}

.games-page__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 28px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--color-surface-soft), var(--color-surface));
    box-shadow: var(--color-shadow);
}

.games-page__header h1 {
    margin: 0;
    color: var(--color-ink);
    font-size: clamp(2.1rem, 4vw, 3.35rem);
    letter-spacing: -.05em;
    line-height: 1;
}

.games-page__header p:not(.eyebrow) {
    margin: 10px 0 0;
    color: var(--color-muted);
    font-size: 1.05rem;
}

.games-page__header-icon {
    display: grid;
    width: 76px;
    height: 76px;
    place-items: center;
    border-radius: 28px;
    background: #fff0f6;
    color: #ed3d70;
    font-size: 2.7rem;
}

[data-theme="dark"] .games-page__header-icon {
    background: #42273a;
    color: #ff8cad;
}

.games-year-filter {
    display: flex;
    align-items: center;
    gap: 22px;
    margin: 20px 0;
    padding: 12px 16px;
    border: 1px solid var(--color-line);
    border-radius: 16px;
    background: var(--color-page);
}

.games-year-filter__label {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    color: var(--color-ink);
    font-weight: 800;
    white-space: nowrap;
}

.games-year-filter__label i {
    color: var(--color-primary);
}

.games-year-filter__buttons {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 6px;
}

.games-year-filter .year-button {
    max-width: none;
    padding: 8px 5px;
    font-size: .86rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.game-card {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 18px;
    min-height: 230px;
    padding: 18px;
    overflow: hidden;
    border: 1px solid var(--color-line);
    border-radius: 22px;
    background: var(--color-surface);
    box-shadow: 0 10px 26px rgba(35, 76, 135, .08);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.game-card:hover {
    border-color: rgba(36, 99, 211, .34);
    box-shadow: 0 16px 32px rgba(35, 76, 135, .14);
    transform: translateY(-3px);
}

.game-card__visual {
    display: grid;
    min-height: 194px;
    place-items: center;
    overflow: hidden;
    border-radius: 18px;
    background: linear-gradient(145deg, #d9f1ff, #ffe0ed 55%, #e3ddff);
}

.game-card__visual img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.game-card__topline,
.game-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.game-card__topline {
    flex-wrap: wrap;
    color: var(--color-primary);
    font-size: .9rem;
}

.game-card__tag {
    color: var(--color-muted);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.game-card__badge {
    display: inline-flex;
    min-height: 22px;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fff1a8;
    color: #7d5b00;
    font-size: .68rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.game-card__badge:empty {
    display: none;
}

[data-theme="dark"] .game-card__badge {
    background: #544615;
    color: #ffe795;
}

.game-card h2 {
    margin: 12px 0 4px;
    color: var(--color-ink);
    font-size: 1.45rem;
    line-height: 1.1;
}

.game-card p {
    margin: 0 0 16px;
    color: var(--color-muted);
    line-height: 1.35;
}

.game-card__footer {
    align-items: flex-end;
    margin-top: auto;
}

.game-card__footer > span {
    color: var(--color-muted);
    font-size: .82rem;
}

.game-card__footer > span i {
    color: var(--color-primary);
}

.game-card .button {
    min-height: 36px;
    padding: 7px 13px;
    font-size: .85rem;
}

.games-empty {
    margin: 18px 0 0;
    padding: 18px;
    border: 1px dashed var(--color-line);
    border-radius: 16px;
    background: var(--color-surface);
    color: var(--color-muted);
    text-align: center;
}

.rhythm-page {
    padding: 28px 0 56px;
}

.rhythm-page__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.rhythm-page__topbar .eyebrow {
    margin: 0;
}

.rhythm-game-shell {
    position: relative;
}

.rhythm-game-shell [hidden] {
    display: none !important;
}

.rhythm-selection {
    position: relative;
    display: block;
    min-height: 680px;
    padding: clamp(24px, 5vw, 56px);
    overflow: hidden;
    border: 1px solid rgba(103, 163, 235, .26);
    border-radius: 30px;
    background: #76bcf5;
    box-shadow: 0 22px 54px rgba(55, 88, 153, .16);
}

[data-theme="dark"] .rhythm-selection {
    background: #183d77;
}

.rhythm-selection__visual {
    position: absolute;
    z-index: 0;
    inset: 0;
    min-height: 0;
}

.rhythm-selection__visual::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(7, 21, 54, .04) 0%, rgba(7, 21, 54, .1) 42%, rgba(7, 21, 54, .58) 100%);
    content: "";
}

.rhythm-selection__visual img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center;
}

.rhythm-selection__content {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(100%, 570px);
    min-height: 568px;
    margin-left: auto;
    flex-direction: column;
    justify-content: center;
    padding: clamp(24px, 4vw, 46px);
    border: 1px solid rgba(255, 255, 255, .38);
    border-radius: 24px;
    background: rgba(255, 255, 255, .68);
    box-shadow: 0 18px 42px rgba(18, 43, 91, .2);
    backdrop-filter: blur(5px);
}

.rhythm-selection__content h1 {
    margin: 0;
    color: var(--color-ink);
    font-size: clamp(2.6rem, 6vw, 5rem);
    letter-spacing: -.06em;
    line-height: .95;
}

.rhythm-selection__intro {
    max-width: 500px;
    margin: 16px 0 28px;
    color: var(--color-muted);
    font-size: clamp(1rem, 2vw, 1.25rem);
    line-height: 1.45;
}

.rhythm-track-picker {
    display: grid;
    gap: 10px;
}

.rhythm-track-picker__label {
    margin: 0;
    color: var(--color-ink);
    font-weight: 900;
}

.rhythm-track-list {
    width: 100%;
    min-height: 158px;
    padding: 4px;
    border: 2px solid rgba(36, 99, 211, .28);
    border-radius: 16px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 8px 18px rgba(35, 76, 135, .08);
    color: var(--color-ink);
    font: inherit;
    font-weight: 900;
}

[data-theme="dark"] .rhythm-track-list {
    background: rgba(12, 23, 48, .72);
}

.rhythm-track-list:focus {
    border-color: var(--color-primary);
    box-shadow: 0 10px 22px rgba(36, 99, 211, .18);
    outline: none;
}

.rhythm-track-list option {
    padding: 12px 14px;
    border-radius: 10px;
}

.rhythm-track-list option:checked {
    background: var(--color-primary);
    color: #fff;
}

.rhythm-track-empty,
.rhythm-selection__hint {
    color: var(--color-muted);
    font-size: .88rem;
    line-height: 1.45;
}

.rhythm-selection__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.rhythm-selection__hint {
    max-width: 510px;
    margin: 18px 0 0;
}

.button--large {
    min-height: 48px;
    padding-inline: 22px;
}

.button--ghost {
    border: 1px solid rgba(255, 255, 255, .22);
    background: transparent;
    color: #fff;
}

.rhythm-play {
    padding: 12px;
    overflow: hidden;
    border-radius: 24px;
    background: #091a3a;
    box-shadow: 0 20px 60px rgba(6, 20, 57, .3);
}

.rhythm-play__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 6px 12px;
    color: #fff;
}

.rhythm-play__track {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.rhythm-play__track strong {
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.08rem;
    white-space: nowrap;
}

.rhythm-play__track span {
    color: rgba(255, 255, 255, .72);
    font-size: .84rem;
    font-variant-numeric: tabular-nums;
}

.rhythm-play__controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.rhythm-spectrum {
    display: flex;
    height: 26px;
    align-items: flex-end;
    gap: 4px;
    margin: 0 6px 10px;
    padding: 0 2px;
    opacity: .92;
}

.rhythm-spectrum__bar {
    display: block;
    min-width: 4px;
    height: 12%;
    flex: 1 1 0;
    border-radius: 999px 999px 3px 3px;
    background: linear-gradient(180deg, #fff 0%, #77d8ff 48%, #5d7cff 100%);
    box-shadow: 0 0 10px rgba(116, 211, 255, .46);
    transform-origin: bottom center;
    transition: height 70ms linear, opacity 120ms linear;
}

.rhythm-spectrum.is-beat .rhythm-spectrum__bar {
    background: linear-gradient(180deg, #fff 0%, #ffd96a 48%, #ff5f9e 100%);
    box-shadow: 0 0 14px rgba(255, 114, 173, .7);
}

.rhythm-control {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .17);
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
}

.rhythm-control:hover,
.rhythm-control:focus-visible {
    background: rgba(255, 255, 255, .2);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.rhythm-control:disabled {
    cursor: wait;
    opacity: .55;
}

.rhythm-stage {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
    aspect-ratio: 1672 / 941;
    border-radius: 18px;
    background-color: #183979;
    background-image: url("../images/games/siga-o-ritmo/Fundo sem nada.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    isolation: isolate;
}

.rhythm-notes-layer,
.rhythm-countdown,
.rhythm-complete {
    position: absolute;
    inset: 0;
}

.rhythm-notes-layer {
    z-index: 2;
    pointer-events: none;
}

.rhythm-note {
    position: absolute;
    z-index: 2;
    display: block;
    width: 17%;
    max-width: none;
    height: auto;
    pointer-events: none;
    transform-origin: center center;
    will-change: left, top, transform;
}

.rhythm-note.is-arriving {
    filter: brightness(1.16) drop-shadow(0 0 12px rgba(255, 255, 255, .8));
}

.rhythm-countdown,
.rhythm-complete {
    display: grid;
    z-index: 5;
    place-items: center;
    background: rgba(7, 20, 52, .24);
    color: #fff;
    text-align: center;
}

.rhythm-countdown {
    font-size: clamp(4rem, 15vw, 11rem);
    font-weight: 1000;
    text-shadow: 0 8px 20px rgba(5, 15, 42, .45);
}

.rhythm-countdown.is-changing {
    animation: rhythm-countdown-in .65s ease both;
}

.rhythm-complete {
    align-content: center;
    gap: 4px;
    padding: 24px;
    background: rgba(7, 20, 52, .78);
}

.rhythm-complete > i {
    margin-bottom: 8px;
    color: #ffda4f;
    font-size: clamp(2rem, 5vw, 4rem);
}

.rhythm-complete h2 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 4rem);
}

.rhythm-complete p {
    margin: 0 0 18px;
    color: rgba(255, 255, 255, .78);
}

.rhythm-complete__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.rhythm-complete__actions .button {
    font-size: .82rem;
}

.rhythm-game-shell:fullscreen {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    padding: 12px;
    background: #06132d;
}

.rhythm-game-shell:fullscreen .rhythm-play {
    display: flex;
    min-height: calc(100vh - 24px);
    flex: 1;
    flex-direction: column;
    padding: 8px;
}

.rhythm-game-shell:fullscreen .rhythm-stage {
    width: min(100%, calc((100vh - 78px) * 1.7779));
    max-width: none;
    flex: 1;
    height: auto;
    min-height: 0;
}

.admin-auth {
    min-height: 58vh;
    padding: 54px 0 72px;
}

.admin-auth__container {
    display: flex;
    justify-content: center;
}

.admin-auth__card {
    width: min(100%, 480px);
    padding: 30px;
    border: 1px solid var(--color-line);
    border-radius: 24px;
    background: var(--color-surface);
    box-shadow: var(--color-shadow);
}

.admin-auth__card h1 {
    margin: 0;
    color: var(--color-ink);
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    letter-spacing: -.04em;
}

.admin-auth__intro {
    margin: 8px 0 24px;
    color: var(--color-muted);
}

.admin-auth__submit {
    width: 100%;
    margin-top: 20px;
}

.admin-auth__link,
.admin-auth__back {
    display: block;
    margin-top: 16px;
    color: var(--color-primary);
    font-size: .9rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.admin-auth__back {
    color: var(--color-muted);
    font-weight: 600;
}

.admin-auth__link:hover,
.admin-auth__back:hover {
    text-decoration: underline;
}

.admin-password-field {
    position: relative;
}

.admin-password-field input {
    padding-right: 48px;
}

.admin-password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    transform: translateY(-50%);
}

.admin-password-toggle:hover {
    background: var(--color-soft);
    color: var(--color-primary);
}

.admin-page {
    padding: 28px 0 56px;
}

.admin-page__header {
    margin-bottom: 20px;
}

.admin-page__header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.admin-page__header h1 {
    margin: 0;
    color: var(--color-ink);
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -.04em;
}

.admin-page__header p:not(.eyebrow) {
    margin: 8px 0 0;
    color: var(--color-muted);
}

.admin-layout {
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    gap: 20px;
    align-items: start;
}

.admin-panel,
.admin-list {
    padding: 22px;
    border: 1px solid var(--color-line);
    border-radius: 20px;
    background: var(--color-surface);
    box-shadow: var(--color-shadow);
}

.admin-fields {
    display: grid;
    gap: 14px;
}

.admin-field {
    display: grid;
    gap: 6px;
}

.admin-field label {
    color: var(--color-ink);
    font-size: .86rem;
    font-weight: 800;
}

.admin-field input[type="text"],
.admin-field input[type="password"],
.admin-field input[type="email"],
.admin-field input[type="file"] {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--color-line);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-ink);
    font: inherit;
}

.admin-status {
    display: block;
    margin-top: 14px;
    color: var(--color-muted);
    font-size: .9rem;
}

.admin-status.is-success {
    color: #168b5a;
}

.admin-status.is-error {
    color: #c92b59;
}

.admin-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #f1d37a;
    border-radius: 12px;
    background: #fff8dc;
    color: #6c5615;
    font-size: .88rem;
}

[data-theme="dark"] .admin-warning {
    border-color: #665624;
    background: #3d351b;
    color: #ffe99a;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--color-ink);
    font-size: .88rem;
}

.admin-table th,
.admin-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--color-line);
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: var(--color-muted);
    font-size: .76rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.admin-empty {
    margin: 0;
    color: var(--color-muted);
}

@keyframes rhythm-countdown-in {
    0% { opacity: 0; transform: scale(.64); }
    45% { opacity: 1; transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

@media (max-width: 1000px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .games-year-filter {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 860px) {
    .games-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .rhythm-selection {
        min-height: 700px;
        padding: 18px;
    }

    .rhythm-selection__visual {
        min-height: 0;
    }

    .rhythm-selection__visual img {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: cover;
    }

    .rhythm-selection__content {
        width: 100%;
        min-height: 0;
        margin: 0;
        padding: 24px;
    }

    .rhythm-play__toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .rhythm-play__controls {
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    .games-page,
    .rhythm-page,
    .admin-page {
        padding-block: 20px 36px;
    }

    .games-page__header,
    .rhythm-page__topbar,
    .admin-page__header-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .admin-page__header-row .button {
        align-self: stretch;
        justify-content: center;
    }

    .games-page__header {
        padding: 22px;
    }

    .games-page__header-icon {
        width: 64px;
        height: 64px;
        border-radius: 20px;
        font-size: 2.4rem;
    }

    .games-year-filter__buttons {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .game-card {
        grid-template-columns: 1fr;
        gap: 14px;
        min-height: 0;
        padding: 12px;
    }

    .game-card__visual {
        min-height: 190px;
    }

    .game-card__footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .rhythm-selection {
        padding: 20px;
        border-radius: 22px;
    }

    .rhythm-selection__content h1 {
        font-size: clamp(2.4rem, 14vw, 4rem);
    }

    .rhythm-selection__actions {
        align-items: stretch;
        flex-direction: column;
    }

    .rhythm-selection__actions .button {
        justify-content: center;
    }

    .rhythm-control {
        flex: 1 1 auto;
        justify-content: center;
    }

    .rhythm-control span {
        display: none;
    }

    .rhythm-play {
        padding: 7px;
        border-radius: 16px;
    }

    .rhythm-complete__actions {
        align-items: stretch;
        flex-direction: column;
    }

    .rhythm-complete__actions .button {
        justify-content: center;
    }
}

@media (orientation: portrait) and (max-width: 760px) {
    .rhythm-stage::after {
        display: grid;
        position: absolute;
        z-index: 8;
        inset: 0;
        place-items: center;
        padding: 24px;
        background: rgba(7, 20, 52, .72);
        color: #fff;
        content: "Roda o dispositivo para jogar.";
        font-size: 1.2rem;
        font-weight: 900;
        text-align: center;
    }
}
