/* ===== Umamusume palette (flat, no gradients) ===== */
:root {
    --bg: #fbf5ea; /* warm cream */
    --panel: #ffffff;
    --ink: #3a2e39; /* dark plum ink */
    --ink-soft: #6e6470;
    --turf: #4ca62e; /* grass / turf green — branding */
    --turf-dark: #3c8523;
    --sakura: #e85d8b; /* signature pink — "correct" */
    --gold: #f2a93b; /* amber — "present" */
    --slate: #7c748f; /* muted plum-grey — "absent" */
    --tile-line: #dad0c2; /* empty tile border */
    --tile-edge: #b9ae9e; /* filled tile border */
    --err: #d04444; /* invalid-word border + warning text */
    --key-bg: #eae0d2; /* keyboard key */
    --key-text: #3a2e39;
    --shadow: rgba(58, 46, 57, 0.18);
    --divider: #efe8dc; /* soft rounded separators */
}

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

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family:
        "Baloo 2",
        "Quicksand",
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ===== Header ===== */
header {
    width: 100%;
    max-width: 560px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 14px 16px 10px;
    position: relative;
    z-index: 1;
    animation: drop-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

h1 {
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
h1 .jp {
    color: var(--sakura);
}
h1 .en {
    color: var(--turf);
}

header .actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
/* Games dropdown: collapses the three cross-links into one pill so the header
   stays a single tidy row of same-height controls instead of a tall column that
   forces the account controls to wrap onto a disconnected line. */
.games-menu {
    position: relative;
}
.games-menu > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--sakura);
    background: transparent;
    border: 2px solid var(--sakura);
    white-space: nowrap;
    transition:
        background 0.12s ease,
        color 0.12s ease;
}
.games-menu > summary::-webkit-details-marker {
    display: none;
}
.games-menu > summary::marker {
    content: "";
}
.games-menu > summary:hover,
.games-menu[open] > summary {
    background: var(--sakura);
    color: #fff;
}
.games-menu .caret {
    font-size: 0.75rem;
    transition: transform 0.15s ease;
}
.games-menu[open] .caret {
    transform: rotate(180deg);
}
.games-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 100 !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 12px 32px var(--shadow);
    animation: games-pop-in 0.16s ease both;
}
@keyframes games-pop-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Small screens: the actions cluster is dense (cross-links + several buttons +
   the account controls). Shrink the pills/icons so more fit per row and let the
   whole cluster wrap under the title instead of overflowing the viewport. */
@media (max-width: 560px) {
    header {
        padding: 12px 12px 8px;
    }
    header .actions {
        gap: 6px;
    }
    #new-game,
    #pakadb {
        height: 34px;
        padding: 0 12px;
        font-size: 0.85rem;
    }
    .icon-btn {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }
    .cross-link {
        font-size: 0.78rem;
        padding: 5px 10px;
    }
}
.cross-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#new-game,
#pakadb {
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    background: var(--turf);
    border: none;
    border-radius: 999px;
    height: 38px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--turf-dark);
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease;
}

/* PakaDB gets the amber accent so it reads as a separate action from Stats */
#pakadb {
    background: var(--gold);
    box-shadow: 0 3px 0 #cf8a26;
}
#pakadb:hover {
    animation: wiggle 0.4s ease;
}
#pakadb:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #cf8a26;
}

.icon-btn {
    font-family: inherit;
    width: 38px;
    height: 38px;
    flex: none;
    border: none;
    border-radius: 50%;
    background: var(--sakura);
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    cursor: pointer;
    box-shadow: 0 3px 0 #c94a74;
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease;
}
.icon-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #c94a74;
}
#new-game:hover {
    animation: wiggle 0.4s ease;
}
#new-game:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 var(--turf-dark);
}

/* center the board in the space between header and keyboard */
.game {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    z-index: 0;
}

#subtitle {
    margin: 0 0 14px;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.95rem;
    animation: fade-up 0.5s ease 0.15s both;
}
#subtitle b {
    color: var(--sakura);
}

/* ===== Board ===== */
#board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    width: 90vw;
    margin: 0 auto;
    padding: 0 4px;
}

.row {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 6px;
    position: relative;
}

/* Invalid-word marker: red tile borders + an inline badge to the right.
   Triggered by the server rejecting a guess that isn't an Umamusume word. */
.row.invalid .tile {
    border-color: var(--err, #d33);
}
.row-warn {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--err, #d33);
    font-weight: 800;
    font-size: 0.9rem;
    white-space: nowrap;
    pointer-events: none;
    animation: warn-in 0.18s ease both;
}
.row-warn-icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border: 2px solid currentColor;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
}
@keyframes warn-in {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}
/* On narrow screens the label would overflow off-screen; keep the icon only. */
@media (max-width: 640px) {
    .row-warn-text {
        display: none;
    }
    .row-warn {
        left: calc(100% + 4px);
    }
}

.tile {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 6vw, 2rem);
    font-weight: 800;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--panel);
    border: 2px solid var(--tile-line);
    border-radius: 10px;
}

.tile.filled {
    border-color: var(--tile-edge);
}

/* letter states */
.tile.correct,
.tile.present,
.tile.absent {
    color: #fff;
    border-color: transparent;
}
.tile.correct {
    background: var(--sakura);
}
.tile.present {
    background: var(--gold);
}
.tile.absent {
    background: var(--slate);
}

/* ===== Keyboard ===== */
#keyboard {
    width: 100%;
    max-width: 520px;
    padding: 6px 6px 18px;
    position: relative;
    z-index: 1;
    animation: fade-up 0.5s ease 0.25s both;
}
.krow {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}
.key {
    font-family: inherit;
    font-weight: 700;
    font-size: clamp(0.8rem, 3.4vw, 1.05rem);
    color: var(--key-text);
    background: var(--key-bg);
    border: none;
    border-radius: 8px;
    height: 52px;
    flex: 1;
    cursor: pointer;
    text-transform: uppercase;
    transition:
        transform 0.06s ease,
        background 0.15s ease,
        color 0.15s ease;
}
.key.wide {
    flex: 1.6;
    font-size: 0.78rem;
}
.key:active {
    transform: scale(0.92);
}
.key.correct {
    background: var(--sakura);
    color: #fff;
}
.key.present {
    background: var(--gold);
    color: #fff;
}
.key.absent {
    background: var(--slate);
    color: #fff;
}

/* ===== Toast ===== */
#toast-wrap {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    z-index: 30;
    pointer-events: none;
}
.toast {
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 999px;
    box-shadow: 0 4px 14px var(--shadow);
    animation:
        toast-in 0.18s ease,
        toast-out 0.3s ease 1.6s forwards;
}

/* ===== Modal ===== */
#modal {
    position: fixed;
    inset: 0;
    background: rgba(58, 46, 57, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
    z-index: 40;
    padding: 20px;
    perspective: 1400px; /* gives the card real depth when it spins */
}
#modal.open {
    opacity: 1;
    visibility: visible;
}

.card {
    background: var(--panel);
    border-radius: 18px;
    padding: 18px 22px 20px;
    width: 100%;
    max-width: 384px;
    overflow: visible;
    text-align: left;
    position: relative;
    box-shadow: 0 12px 30px var(--shadow);
    transform-style: preserve-3d;
    animation: card-fly-in 0.85s cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

/* glassy highlight that sweeps across the card once it has settled */
.card .shine {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    overflow: hidden; /* clip the sweep to the card surface */
    pointer-events: none;
    z-index: 6;
}
.card .shine::before {
    content: "";
    position: absolute;
    top: -75%;
    left: -30%;
    width: 55%;
    height: 250%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(20deg) translateX(-220%);
    animation: shine-sweep 0.9s ease-in-out 0.6s both;
}
@keyframes shine-sweep {
    from {
        transform: rotate(20deg) translateX(-220%);
    }
    to {
        transform: rotate(20deg) translateX(360%);
    }
}

/* fly up from the bottom while spinning one full turn on the Y axis */
@keyframes card-fly-in {
    0% {
        opacity: 0;
        transform: translateY(95vh) scale(0.78) rotateY(-360deg);
    }
    55% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateY(0deg);
    }
}

/* rotated stamp, top-right */
.card .card-x {
    position: absolute;
    top: 8px;
    left: 12px;
    z-index: 7;
    width: auto;
    margin: 0;
    padding: 2px 6px;
    border: none;
    background: none;
    box-shadow: none;
    border-radius: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--ink-soft);
}
.card .card-x:active {
    transform: none;
    box-shadow: none;
}
.card .card-x:hover {
    color: var(--ink);
}

.card .badge {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    background: var(--sakura);
    padding: 6px 14px;
    border-radius: 999px;
    transform: rotate(4deg);
    box-shadow: 0 3px 0 #c94a74;
    animation: badge-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.6) both;
}
.card .badge.lose {
    background: var(--slate);
    box-shadow: 0 3px 0 #5f5872;
    font-size: 0.85rem;
}
@keyframes badge-pop {
    0% {
        opacity: 0;
        transform: rotate(4deg) scale(0.4);
    }
    60% {
        opacity: 1;
        transform: rotate(4deg) scale(1.18);
    }
    100% {
        transform: rotate(4deg) scale(1);
    }
}

/* two-column hero: character left (bleeds off), info right */
.card .hero {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 26px;
    min-height: 178px;
}
.card .char {
    position: relative;
    flex: 0 0 43%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    align-self: stretch;
}
.card .char.noimg {
    display: none;
}
.card .portrait {
    position: relative;
    z-index: 1;
    height: 218px; /* taller than hero → head pops above the top */
    width: auto;
    max-width: 160px;
    object-fit: contain;
    margin-left: -12px; /* kiss the left edge */
    filter: drop-shadow(0 6px 5px rgba(58, 46, 57, 0.22));
}
.card.lose .portrait {
    filter: grayscale(0.85) drop-shadow(0 6px 5px rgba(58, 46, 57, 0.2));
    opacity: 0.9;
}
.card .info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 4px;
}

.card .answer {
    font-size: 1.6rem;
    line-height: 1.05;
    font-weight: 800;
    color: var(--turf-dark);
    word-break: break-word;
    margin-bottom: 2px;
}
.card .full {
    font-size: 0.92rem;
    color: var(--ink);
    font-weight: 600;
    margin-bottom: 10px;
}
.card .full::after {
    content: "";
    display: block;
    width: 100%;
    height: 4px;
    margin-top: 9px;
    border-radius: 999px;
    background: var(--divider);
}
.card .quote {
    font-size: 0.86rem;
    color: var(--ink-soft);
    font-style: italic;
    line-height: 1.35;
}
.card .quote::before {
    content: "\201C";
}
.card .quote::after {
    content: "\201D";
}
.card .quote::before,
.card .quote::after {
    color: var(--sakura);
    font-weight: 800;
    font-size: 1.15em;
}

.stats {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 16px 4px 16px;
    padding-top: 18px;
}
.stats::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 999px;
    background: var(--divider);
}
.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}
.stat .num {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ink);
}
.stat .lbl {
    font-size: 0.68rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card button {
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    background: var(--sakura);
    border: none;
    border-radius: 999px;
    padding: 12px 28px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 3px 0 #c94a74;
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease;
}
.card button:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #c94a74;
}
.card .share-btn {
    margin-bottom: 10px;
}

/* "next puzzle" countdown shown once today's game is finished */
.card .countdown {
    text-align: center;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--ink-soft);
    background: var(--bg);
    border: 2px dashed var(--tile-line);
    border-radius: 999px;
    padding: 11px 18px;
}

/* ===== How-to-play onboarding ===== */
#howto {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(58, 46, 57, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}
#howto.open {
    opacity: 1;
    visibility: visible;
}

.howto-card {
    background: var(--panel);
    border-radius: 18px;
    width: 100%;
    max-width: 380px;
    max-height: 90vh;
    overflow: auto;
    padding: 24px 22px 16px;
    position: relative;
    box-shadow: 0 12px 30px var(--shadow);
}
.howto-x {
    position: absolute;
    top: 8px;
    right: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.7rem;
    line-height: 1;
    color: var(--ink-soft);
}

.howto-body {
    min-height: 240px;
    animation: step-in 0.28s ease both;
}
@keyframes step-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
.howto-body h2 {
    color: var(--turf-dark);
    font-size: 1.3rem;
    margin-bottom: 8px;
}
.howto-body p {
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.45;
    margin-bottom: 8px;
}
.howto-body p.sub {
    color: var(--ink-soft);
    font-size: 0.88rem;
}
.howto-body p.cap {
    color: var(--ink-soft);
    font-size: 0.84rem;
    margin: 0 0 14px;
}
.howto-body b.pink {
    color: var(--sakura);
}
.howto-body b.gold {
    color: var(--gold);
}
.howto-body b.slate {
    color: var(--slate);
}

/* example tiles — reuse the board's color language */
.ex-row {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin: 12px 0 6px;
}
.ex-tile {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--ink);
    background: #fff;
    border: 2px solid var(--tile-line);
    border-radius: 8px;
}
.ex-tile.correct {
    background: var(--sakura);
    color: #fff;
    border-color: transparent;
}
.ex-tile.present {
    background: var(--gold);
    color: #fff;
    border-color: transparent;
}
.ex-tile.absent {
    background: var(--slate);
    color: #fff;
    border-color: transparent;
}

/* "word hides in a name" illustration */
.namecard {
    text-align: center;
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: 0.3px;
    margin: 16px 0 4px;
}
.namecard .hl {
    color: var(--sakura);
}
.namecard .dim {
    color: var(--tile-edge);
}

.howto-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}
.howto-nav button {
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease;
}
.howto-back {
    background: var(--key-bg);
    color: var(--ink);
}
.howto-back:disabled {
    opacity: 0.4;
    cursor: default;
}
.howto-next {
    background: var(--sakura);
    color: #fff;
    box-shadow: 0 3px 0 #c94a74;
}
.howto-next:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #c94a74;
}
.dots {
    display: flex;
    gap: 7px;
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tile-line);
    transition: background 0.2s ease;
}
.dot.on {
    background: var(--turf);
}

/* ===== Drifting petals (background flair) ===== */
#petals {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.petal {
    position: absolute;
    top: -6vh;
    animation-name: fall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
.petal i {
    display: block;
    border-radius: 0 100% 0 100%; /* leaf / petal silhouette */
    animation-name: sway;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
    animation-direction: alternate;
}
@keyframes fall {
    to {
        transform: translateY(116vh);
    }
}
@keyframes sway {
    from {
        transform: translateX(-14px) rotate(0deg);
    }
    to {
        transform: translateX(14px) rotate(220deg);
    }
}

/* ===== Confetti cannons (win) ===== */
#confetti {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 70; /* above the modal/card */
}
.confetti {
    position: fixed;
    will-change: transform, opacity;
}

/* ===== horse pads (grid sweep) ===== */
.tile.lit {
    background: var(--pad);
    border-color: var(--pad);
    box-shadow: 0 0 16px var(--pad);
}
.grid-horse {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 5vw, 1.7rem);
    line-height: 1;
    pointer-events: none;
    user-select: none;
    z-index: 2;
}
@keyframes horse-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.25);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
.grid-horse.in {
    animation: horse-pop 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}
@keyframes horse-out {
    to {
        transform: scale(0);
        opacity: 0;
    }
}
.grid-horse.out {
    animation: horse-out 0.2s ease-in forwards;
}
.tile.lit {
    transition:
        background-color 0.12s ease,
        box-shadow 0.12s ease,
        border-color 0.12s ease;
}

/* ===== Load-in / idle flair ===== */
@keyframes drop-in {
    from {
        opacity: 0;
        transform: translateY(-18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes wiggle {
    0%,
    100% {
        transform: rotate(0deg);
    }
    30% {
        transform: rotate(-4deg);
    }
    70% {
        transform: rotate(4deg);
    }
}

/* tiles cascade in when the board is (re)built */
@keyframes tile-in {
    from {
        opacity: 0;
        transform: scale(0.4) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}
.tile.enter {
    animation: tile-in 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

/* ===== Animations ===== */
@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}
.tile.pop {
    animation: pop 0.12s ease;
}

@keyframes flip {
    0% {
        transform: rotateX(0deg);
    }
    50% {
        transform: rotateX(-90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}
.tile.flip {
    animation: flip 0.5s ease forwards;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    20%,
    60% {
        transform: translateX(-6px);
    }
    40%,
    80% {
        transform: translateX(6px);
    }
}
.row.shake {
    animation: shake 0.4s ease;
}

@keyframes bounce {
    0% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-20px);
    }
    50% {
        transform: translateY(0);
    }
    70% {
        transform: translateY(-8px);
    }
    85% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(0);
    }
}
.tile.bounce {
    animation: bounce 0.55s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@media (max-width: 420px) {
    .key {
        height: 46px;
    }
}

/* not enough room: stack the title vertically */
@media (max-width: 480px) {
    h1 {
        display: flex;
        flex-direction: column;
        line-height: 1.02;
    }
}

/* respect users who prefer less motion: kill the looping/idle flair */
@media (prefers-reduced-motion: reduce) {
    #petals {
        display: none;
    }
    header,
    #subtitle,
    #keyboard,
    .tile.enter {
        animation: none;
    }
    .card {
        animation: card-fade 0.2s ease both;
    }
    .card .shine {
        display: none;
    }
}
@keyframes card-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* cross-promo link between the two games */
.cross-link {
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--sakura);
    background: transparent;
    border: 2px solid var(--sakura);
    border-radius: 999px;
    padding: 6px 12px;
    white-space: nowrap;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    transition:
        background 0.12s ease,
        color 0.12s ease;
}
.cross-link:hover {
    background: var(--sakura);
    color: #fff;
}
.cross-link.chess {
    color: var(--turf);
    border-color: var(--turf);
}
.cross-link.chess:hover {
    background: var(--turf);
    color: #fff;
}
.cross-link.duel {
    color: var(--gold);
    border-color: var(--gold);
}
.cross-link.duel:hover {
    background: var(--gold);
    color: #fff;
}
.cross-link.tail {
    color: var(--gold);
    border-color: var(--gold);
}
.cross-link.tail:hover {
    background: var(--gold);
    color: #fff;
}
