/*==================================================
    Animaybe
==================================================*/

:root {
    --bg: #140f24;
    --panel: #1f1836;
    --panel-2: #2a2147;
    --line: rgba(255, 255, 255, 0.1);
    --text: #f4f0ff;
    --muted: #a99fc7;
    --pink: #f472b6;
    --violet: #a78bfa;
    --hit: #22c55e;
    --part: #eab308;
    --miss: #be123c;
    --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
    --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 400px at 10% -10%, rgba(244, 114, 182, 0.18), transparent 60%),
        radial-gradient(800px 400px at 100% 0%, rgba(167, 139, 250, 0.16), transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
}

button,
input {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-2);
    padding: 8px 16px;
    font-weight: 800;
}

button:hover {
    border-color: rgba(244, 114, 182, 0.6);
}

button.primary {
    border-color: var(--pink);
    background: linear-gradient(180deg, #ec4899, #be185d);
}

a {
    color: var(--violet);
}

/* Top bar and tabs */
.am-top {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 980px;
    margin: 0 auto;
    padding: 16px 16px 8px;
}

.am-home {
    color: var(--muted);
    font-size: 1.4rem;
    text-decoration: none;
}

.am-logo {
    flex: 1;
    margin: 0;
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.01em;
}

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

.am-play-kind {
    display: flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
}

.am-play-kind button {
    border: 0;
    background: transparent;
    padding: 6px 14px;
}

.am-play-kind button.active {
    background: var(--pink);
    color: #1b0b19;
}

.am-icon-button {
    padding: 6px 10px;
    font-size: 1.1rem;
}

.am-modes {
    display: flex;
    gap: 6px;
    max-width: 980px;
    margin: 0 auto;
    padding: 4px 16px 10px;
    overflow-x: auto;
    scrollbar-width: none;
}

.am-modes button {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    background: var(--panel);
}

.am-modes button.active {
    border-color: var(--pink);
    background: rgba(244, 114, 182, 0.18);
}

.am-modes button.done::after {
    content: "✓";
    color: var(--hit);
}

/* Main column */
.am-main {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 16px 24px;
}

.am-intro h2 {
    margin: 6px 0 2px;
    font-family: var(--font-display);
    font-size: 1.5rem;
}

.am-intro h2 small {
    color: var(--muted);
    font-size: 0.9rem;
}

.am-intro p {
    margin: 0 0 12px;
    color: var(--muted);
}

/* Endless difficulty */
.am-difficulty {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 12px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
}

.am-difficulty button {
    border: 0;
    background: transparent;
    padding: 6px 14px;
}

.am-difficulty button small {
    color: var(--muted);
    font-weight: 700;
}

.am-difficulty button.active {
    background: var(--violet);
    color: #1b1033;
}

.am-difficulty button.active small {
    color: #3b2a63;
}

.am-empty,
.am-guess-note {
    color: var(--muted);
    font-size: 0.9rem;
}

.am-guess-note {
    margin: 6px 4px 0;
}

/* Guess box */
.am-guess {
    position: relative;
    z-index: 5;
    margin: 12px 0;
}

.am-guess[hidden] {
    display: none;
}

.am-guess-row {
    display: flex;
    gap: 8px;
}

.am-search {
    position: relative;
    flex: 1;
}

.am-search input {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    font-size: 1.05rem;
    outline: none;
}

.am-search input:focus {
    border-color: var(--pink);
}

.am-ghost {
    background: transparent;
}

.am-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #231b3d;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.am-suggestions li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
}

.am-suggestions li.active,
.am-suggestions li:hover {
    background: rgba(244, 114, 182, 0.18);
}

.am-suggestions img {
    width: 30px;
    height: 42px;
    border-radius: 5px;
    object-fit: cover;
}

.am-suggestions span {
    display: grid;
    flex: 1;
    min-width: 0;
}

.am-suggestions b,
.am-suggestions small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.am-suggestions small,
.am-suggestions em {
    color: var(--muted);
    font-size: 0.8rem;
    font-style: normal;
}

/* Guess pips */
.am-pips {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 12px 0 4px;
}

.am-pips i {
    width: 34px;
    height: 8px;
    border-radius: 999px;
    background: var(--panel-2);
}

.am-pips i.miss { background: var(--miss); }
.am-pips i.skip { background: #57534e; }
.am-pips i.hit { background: var(--hit); }

.am-misses {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
    padding: 0;
    list-style: none;
}

.am-misses li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border: 1px solid rgba(190, 18, 60, 0.5);
    border-radius: 999px;
    background: rgba(190, 18, 60, 0.15);
    font-size: 0.85rem;
}

.am-misses li.skip {
    padding-left: 10px;
    border-color: var(--line);
    background: var(--panel);
    color: var(--muted);
}

.am-misses img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}

.am-hint {
    margin: 8px 0 0;
    color: #fde68a;
    text-align: center;
    font-weight: 700;
}

/* Classic */
.am-classic {
    display: grid;
    gap: 8px;
}

.am-classic-row {
    display: grid;
    grid-template-columns: minmax(150px, 1.4fr) repeat(8, minmax(0, 1fr));
    gap: 4px;
    animation: am-pop 0.35s ease-out;
}

.am-classic-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 4px;
    border-radius: 10px;
    background: var(--panel);
    font-weight: 800;
    font-size: 0.85rem;
}

.am-classic-name img {
    width: 34px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
}

.am-cell {
    display: grid;
    align-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 4px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
    word-break: break-word;
}

.am-cell small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.am-cell b {
    text-decoration: underline;
}

.am-cell i {
    font-style: normal;
    font-size: 1rem;
}

.am-cell.hit { background: #15803d; }
.am-cell.part { background: #a16207; }
.am-cell.miss { background: #881337; }

.am-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 0.8rem;
}

.am-legend span::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 5px;
    border-radius: 3px;
    background: var(--miss);
}

.am-legend .hit::before { background: var(--hit); }
.am-legend .part::before { background: var(--part); }

@keyframes am-pop {
    from { opacity: 0; transform: translateY(-6px); }
}

/* Frame */
.am-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    /* Banner-shaped, but never so short on a phone that the art is a strip. */
    height: clamp(160px, 21vw, 230px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #000;
}

.am-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease, filter 0.6s ease;
    user-select: none;
    pointer-events: none;
}

/* Synopsis */
.am-synopsis {
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    font-size: 1.02rem;
    line-height: 1.75;
}

.am-redacted {
    border-radius: 3px;
    background: #3b3060;
    color: transparent;
    letter-spacing: -0.5px;
}

.am-redacted.is-name {
    background: #6b2155;
}

.am-secret {
    border-radius: 3px;
    background: rgba(244, 114, 182, 0.25);
}

/* Emoji */
.am-emoji {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 22px 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
}

.am-emoji span {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 14px;
    background: var(--panel-2);
    font-size: 2.2rem;
    opacity: 0.35;
}

.am-emoji span.shown {
    opacity: 1;
    animation: am-pop 0.35s ease-out;
}

/* Closer */
.am-closer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
}

.am-closer-actions span {
    flex: 1;
}

.am-closer,
.am-closer-latest {
    display: grid;
    gap: 6px;
}

.am-closer-latest {
    margin: 10px 0 0;
}

.am-closer-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    padding: 5px 12px 5px 5px;
    border-radius: 12px;
    background: var(--panel);
    font-weight: 800;
}

.am-closer-row > i {
    position: absolute;
    inset: 0 auto 0 0;
    opacity: 0.35;
}

.am-closer-row img,
.am-closer-row span,
.am-closer-row b {
    position: relative;
}

.am-closer-row img {
    width: 30px;
    height: 42px;
    border-radius: 6px;
    object-fit: cover;
}

.am-closer-row span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.am-closer-row.is-latest {
    outline: 2px solid var(--text);
}

.am-closer-row.hit > i { background: var(--hit); opacity: 0.8; }
.am-closer-row.hot > i { background: #f97316; }
.am-closer-row.warm > i { background: #eab308; }
.am-closer-row.cool > i { background: #3b82f6; }
.am-closer-row.cold > i { background: #64748b; }

/* Opening */
.am-opening {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
}

.am-opening p {
    margin: 0;
    color: var(--muted);
}

.am-play {
    width: 72px;
    height: 72px;
    padding: 0;
    border-color: var(--pink);
    background: linear-gradient(180deg, #ec4899, #9d174d);
    font-size: 1.6rem;
}

.am-play.is-playing,
.am-play.is-loading {
    background: var(--panel-2);
}

.am-play.is-loading {
    animation: am-pulse 1s ease-in-out infinite;
}

@keyframes am-pulse {
    50% { opacity: 0.55; }
}

.am-loading {
    min-height: 1.2em;
    color: #fde68a;
}

/* The seek bar: --open is the unlocked part, --at the play point. */
.am-track {
    --open: 5%;
    --at: 0%;
    position: relative;
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: #0f0b1c;
    cursor: pointer;
    touch-action: none;
    outline: none;
}

/* A taller strip to grab than the bar shows. */
.am-track::before {
    content: "";
    position: absolute;
    inset: -10px 0;
}

.am-track:focus-visible {
    box-shadow: 0 0 0 2px var(--violet);
}

.am-track span {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--open);
    border-radius: 999px;
    background: rgba(244, 114, 182, 0.3);
    transition: width 0.3s ease;
}

.am-track i {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--at);
    border-radius: 999px;
    background: var(--pink);
}

.am-track b {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--muted);
    pointer-events: none;
}

.am-track em {
    position: absolute;
    top: 50%;
    left: var(--at);
    width: 18px;
    height: 18px;
    border: 3px solid var(--pink);
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.am-volume {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

/* Result */
.am-result {
    margin-top: 16px;
}

.am-result-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid rgba(190, 18, 60, 0.5);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(190, 18, 60, 0.18), var(--panel));
    animation: am-pop 0.4s ease-out;
}

.am-result-card.won {
    border-color: rgba(34, 197, 94, 0.6);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), var(--panel));
}

.am-result-card > img {
    width: 110px;
    height: 156px;
    flex: none;
    border-radius: 10px;
    object-fit: cover;
}

.am-result-card small {
    color: var(--muted);
    font-weight: 800;
}

.am-result-card h2 {
    margin: 2px 0;
    font-family: var(--font-display);
}

.am-result-card p {
    margin: 4px 0;
}

.am-romaji {
    color: var(--muted);
}

.am-song small {
    color: var(--muted);
}

.am-result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.am-next {
    color: var(--muted);
}

/* Stats */
.am-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
}

.am-modal[hidden] {
    display: none;
}

.am-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 3, 12, 0.7);
}

.am-modal-card {
    position: relative;
    width: min(440px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
}

.am-modal-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.am-modal-card h2 {
    margin: 0;
    font-family: var(--font-display);
}

.am-modal-card h3 {
    margin: 14px 0 8px;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.am-stat-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    text-align: center;
}

.am-stat-tiles b {
    display: block;
    font-family: var(--font-display);
    font-size: 1.5rem;
}

.am-stat-tiles small {
    color: var(--muted);
    font-size: 0.75rem;
}

.am-dist {
    display: grid;
    gap: 3px;
    margin-top: 10px;
}

.am-dist div {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.am-dist span {
    width: 18px;
    text-align: right;
}

.am-dist i {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--violet);
    color: #1b1033;
    font-style: normal;
    font-weight: 800;
    text-align: right;
}

.am-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    z-index: 30;
    padding: 10px 16px;
    border-radius: 12px;
    background: #f4f0ff;
    color: #1b1033;
    font-weight: 800;
    transform: translateX(-50%);
}

.am-toast[hidden] {
    display: none;
}

.am-footer {
    padding: 20px 16px 28px;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

@media (max-width: 760px) {
    .am-logo {
        font-size: 1.5rem;
    }

    .am-difficulty {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        border-radius: 16px;
    }

    .am-difficulty button {
        display: grid;
        padding: 6px 4px;
        border-radius: 12px;
    }

    .am-classic-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .am-classic-name {
        grid-column: 1 / -1;
    }

    .am-emoji span {
        width: 52px;
        height: 52px;
        font-size: 1.8rem;
    }

    .am-result-card > img {
        width: 80px;
        height: 114px;
    }
}

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