/* Harfiyen: a dark, playful stage whose colour follows the category being played (--cat, set from game.js). */
:root {
    color-scheme: dark;
    --bg-1: #0c0b22;
    --bg-2: #1b1650;
    --ink: #f6f4ff;
    --ink-2: rgba(246, 244, 255, 0.74);
    --ink-3: rgba(246, 244, 255, 0.5);
    --glass: rgba(255, 255, 255, 0.07);
    --glass-2: rgba(255, 255, 255, 0.13);
    --line: rgba(255, 255, 255, 0.14);
    --ok: #3ddc84;
    --bad: #ff5d6c;
    --gold: #ffd166;
    --cat: #8b7bff;
    --cat-dark: #5a46e0;
    --cat-ink: #ffffff;
    --font: 'Baloo 2', ui-rounded, 'Segoe UI', system-ui, sans-serif;
    --top: calc(64px + env(safe-area-inset-top));
}

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

html,
body {
    height: 100%;
}

body {
    overflow: hidden;
    background: var(--bg-1);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

button {
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

h1:focus {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Background: two slow, blurred blobs in the category colour */
.bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% -10%, var(--bg-2) 0%, var(--bg-1) 62%);
}

.bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
}

.bg i {
    position: absolute;
    width: 56vmax;
    height: 56vmax;
    border-radius: 50%;
    background-color: var(--cat);
    opacity: 0.26;
    filter: blur(80px);
    transition: background-color 0.9s ease;
    animation: drift 26s ease-in-out infinite alternate;
    will-change: transform;
}

.bg i:first-child {
    top: -26vmax;
    left: -18vmax;
}

.bg i:last-child {
    right: -22vmax;
    bottom: -30vmax;
    background-color: var(--cat-dark);
    animation-duration: 32s;
    animation-delay: -10s;
}

@keyframes drift {
    to {
        transform: translate(7vmax, 5vmax) scale(1.12);
    }
}

/* Top bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--top);
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}

.icon-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--glass);
    transition: background-color 0.2s, transform 0.12s, opacity 0.2s;
}

.icon-btn:hover {
    background: var(--glass-2);
}

.icon-btn:active {
    transform: scale(0.93);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.icon-btn .slash {
    display: none;
}

.icon-btn[aria-pressed='false'] {
    opacity: 0.55;
}

.icon-btn[aria-pressed='false'] .slash {
    display: inline;
}

.icon-btn[aria-pressed='false'] .waves {
    display: none;
}

.icon-btn[hidden] {
    display: grid;
    visibility: hidden;
}

.tb-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.tb-sound {
    display: flex;
    gap: 8px;
}

.tb-brand {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--ink-2);
}

.tb-play {
    display: none;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

body[data-screen='lang'] .tb-brand,
body[data-screen='play'] .tb-brand {
    display: none;
}

body[data-screen='play'] .tb-play {
    display: flex;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    height: 42px;
    padding: 0 16px 0 6px;
    border-radius: 99px;
    background: var(--cat);
    color: var(--cat-ink);
    font-weight: 800;
    font-size: 1.02rem;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.16);
}

.chip .ci {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.24);
}

.chip svg {
    width: 18px;
    height: 18px;
}

.chip b {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.timer {
    position: relative;
    flex: none;
    width: 50px;
    height: 50px;
}

.timer svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer .track {
    fill: rgba(0, 0, 0, 0.28);
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 4;
}

.timer .ring {
    fill: none;
    stroke: var(--cat);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
    transition: stroke 0.3s;
}

.timer span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.timer.waiting span {
    color: var(--ink-3);
}

.timer.urgent .ring {
    stroke: var(--bad);
}

.timer.urgent {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    50% {
        transform: scale(1.1);
    }
}

/* Screens */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    padding: var(--top) 16px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;   /* a screen fading out must not catch taps meant for the next one */
    transform: translateY(18px) scale(0.985);
    transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.5s;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition-delay: 0s;
}

.screen-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    width: 100%;
    max-width: 900px;
    margin: auto;
    padding-block: 12px;
}

.head {
    text-align: center;
}

.head h1 {
    font-size: clamp(1.9rem, 4.6vw, 2.8rem);
    font-weight: 800;
    line-height: 1.08;
}

.head p {
    margin-top: 6px;
    color: var(--ink-2);
    font-size: 1.08rem;
}

/* 1. Language */
.brand {
    display: flex;
    gap: clamp(4px, 1.1vw, 9px);
}

.brand span {
    --c: #5b8cff;
    display: grid;
    place-items: center;
    width: clamp(34px, 9.2vw, 70px);
    aspect-ratio: 1 / 1.14;
    border-radius: clamp(9px, 2vw, 16px);
    background: var(--c);
    color: #fff;
    font-size: clamp(1.45rem, 5.6vw, 2.9rem);
    font-weight: 800;
    line-height: 1;
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2), 0 12px 26px -12px var(--c);
    animation: tile-in 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both, bob 3.2s ease-in-out infinite;
    animation-delay: calc(var(--i) * 80ms), calc(0.9s + var(--i) * 140ms);
}

.brand span:nth-child(7n + 1) { --c: #5b8cff; }
.brand span:nth-child(7n + 2) { --c: #2fd27a; color: #062a19; }
.brand span:nth-child(7n + 3) { --c: #ff5fa2; }
.brand span:nth-child(7n + 4) { --c: #22c7e8; color: #04262e; }
.brand span:nth-child(7n + 5) { --c: #ff8a3d; color: #2e1300; }
.brand span:nth-child(7n + 6) { --c: #f6c343; color: #2e2000; }
.brand span:nth-child(7n + 7) { --c: #a66bff; }

@keyframes tile-in {
    from {
        opacity: 0;
        transform: translateY(-40px) rotateX(80deg) scale(0.6);
    }
}

@keyframes bob {
    50% {
        transform: translateY(-5px);
    }
}

.tagline {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 10px;
    margin-top: -8px;
    color: var(--ink-2);
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
}

.tagline .dot {
    color: var(--ink-3);
}

.choices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    width: 100%;
}

.choice {
    display: flex;
    align-items: center;
    gap: 16px;
    width: min(100%, 300px);
    padding: 16px 20px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--glass);
    text-align: left;
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.2s, border-color 0.2s;
}

.choice:hover {
    border-color: rgba(255, 255, 255, 0.32);
    background: var(--glass-2);
    transform: translateY(-3px);
}

.choice:active {
    transform: scale(0.98);
}

.choice .badge {
    flex: none;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(150deg, #ff5d6c, #d6304a);
    font-size: 1.2rem;
    font-weight: 800;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
}

.choice[data-lang='en'] .badge {
    background: linear-gradient(150deg, #5b8cff, #3456d1);
}

.choice b {
    display: block;
    font-size: 1.4rem;
    line-height: 1.1;
}

.choice small {
    display: block;
    color: var(--ink-2);
    font-size: 0.95rem;
}

.credit {
    color: var(--ink-3);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
}

.credit:hover {
    color: var(--ink);
}

/* 2. Mode */
.modes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 680px;
}

.mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 26px 20px 24px;
    border: 1px solid var(--line);
    border-radius: 26px;
    background: var(--glass);
    text-align: center;
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.2s, border-color 0.2s;
}

.mode-card:hover {
    border-color: rgba(255, 255, 255, 0.32);
    background: var(--glass-2);
    transform: translateY(-4px);
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-art {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    margin-bottom: 6px;
    border-radius: 28px;
    background: rgba(0, 0, 0, 0.22);
}

.mode-art svg {
    width: 68px;
    height: 68px;
}

.mode-card[data-mode='wheel'] .mode-art svg g {
    transform: translate(32px, 34px);
    transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mode-card[data-mode='wheel']:hover .mode-art svg g {
    transform: translate(32px, 34px) rotate(160deg);
}

.mode-card b {
    font-size: 1.4rem;
    line-height: 1.15;
}

.mode-card small {
    color: var(--ink-2);
    font-size: 0.98rem;
    line-height: 1.35;
}

/* 3a. Categories */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    width: 100%;
}

.cat-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    min-height: 138px;
    padding: 18px;
    overflow: hidden;
    border-radius: 24px;
    background: linear-gradient(150deg, var(--c), var(--c2));
    color: var(--ci);
    text-align: left;
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.16), 0 16px 32px -18px var(--c);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
    animation: rise 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) both;
    animation-delay: calc(var(--i) * 45ms);
}

.cat-tile::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.22) 45%, transparent 60%);
    transform: translateX(-120%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.cat-tile:hover {
    transform: translateY(-4px) rotate(-0.5deg);
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.16), 0 22px 40px -18px var(--c);
}

.cat-tile:hover::after {
    transform: translateX(120%);
}

.cat-tile:active,
.cat-tile.chosen {
    transform: scale(0.97);
}

.cat-tile .mark {
    display: block;
    position: absolute;
    right: -14px;
    bottom: -18px;
    width: 116px;
    height: 116px;
    opacity: 0.16;
    transform: rotate(-12deg);
}

.cat-tile .mark svg {
    display: block;
    width: 100%;
    height: 100%;
}

.cat-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.24);
}

.cat-icon svg {
    width: 28px;
    height: 28px;
}

.cat-name {
    position: relative;
    font-size: 1.32rem;
    font-weight: 800;
    line-height: 1.1;
}

.cat-tile.bonus {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-height: 96px;
}

.cat-tile.bonus .cat-name::after {
    content: ' ✦';
    color: var(--gold);
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.96);
    }
}

.score {
    display: flex;
    gap: 10px;
}

.score:empty {
    display: none;
}

.score span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--glass);
    color: var(--ink-2);
    font-weight: 700;
}

.score b {
    color: var(--ink);
    font-size: 1.1rem;
}

.score .ok::before,
.score .no::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--ok);
}

.score .no::before {
    background: var(--bad);
}

/* 3b. Wheel */
.wheel-wrap {
    position: relative;
    width: min(88vw, 58vh, 500px);
    aspect-ratio: 460 / 466;
}

.wheel {
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 26px 40px rgba(0, 0, 0, 0.45));
    cursor: pointer;
}

.wheel .seg {
    transition: opacity 0.35s;
}

.wheel.done .seg:not(.picked) {
    opacity: 0.3;
}

.wheel text {
    font-family: var(--font);
    font-weight: 800;
}

.wheel .pointer {
    transform-box: fill-box;
    transform-origin: 50% 20%;
}

.hub {
    position: absolute;
    left: 50%;
    top: 50.64%;
    width: 25%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #ffffff, #ece8ff 55%, #c6befa);
    color: #1b1640;
    font-size: clamp(0.95rem, 3.4vw, 1.35rem);
    font-weight: 800;
    letter-spacing: 0.03em;
    box-shadow: 0 6px 0 #9a91d6, 0 16px 30px rgba(0, 0, 0, 0.45);
    transform: translate(-50%, -50%);
    transition: transform 0.12s, box-shadow 0.12s, filter 0.2s;
}

.hub:hover {
    filter: brightness(1.05);
}

.hub:active,
.hub:disabled {
    box-shadow: 0 2px 0 #9a91d6, 0 8px 18px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, calc(-50% + 4px));
}

.hub:disabled {
    cursor: default;
}

.wheel-result {
    min-height: 1.3em;
    margin-top: -10px;
    color: var(--cat);
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    font-weight: 800;
    line-height: 1.3;
    text-align: center;
    transition: color 0.4s;
}

.wheel-result.show {
    animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.6);
    }
}

/* 4. The round */
.screen-play {
    padding: var(--top) 0 0;
    overflow: hidden;
}

.timebar {
    flex: none;
    height: 5px;
    margin: 0 16px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
}

.timebar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--cat);
    transform-origin: left;
    transition: background-color 0.3s;
}

.timebar.urgent i {
    background: var(--bad);
}

.board {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 16px 4px;
    overflow-y: auto;
}

.board-inner {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
}

.q-card {
    padding: clamp(16px, 2.4vw, 26px) clamp(16px, 3vw, 34px);
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 20px 40px -28px rgba(0, 0, 0, 0.6);
}

.stage {
    flex: 1 1 0;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage.shake {
    animation: shake 0.42s;
}

@keyframes shake {
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

.gallows {
    height: min(240px, 100%);
    aspect-ratio: 120 / 150;
    overflow: visible;
}

.gallows .man {
    transform-origin: 88px 28px;
}

.gallows.lost .man {
    animation: swing 1.8s ease-in-out 0.4s infinite;
}

@keyframes swing {
    25% { transform: rotate(5deg); }
    75% { transform: rotate(-5deg); }
}

.gallows path,
.gallows circle {
    fill: none;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.gallows .frame {
    stroke: rgba(255, 255, 255, 0.28);
}

.gallows .part {
    stroke: var(--ink);
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    opacity: 0;   /* an undrawn part would still show its round cap as a dot */
    transition: stroke-dashoffset 0.45s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s, opacity 0.1s;
}

.gallows .part.on {
    stroke-dashoffset: 0;
    opacity: 1;
}

.gallows.danger .part.on {
    stroke: #ffb0b7;
}

.gallows.lost .part {
    stroke: var(--bad);
}

.q-text {
    font-size: clamp(1.12rem, 1.1vw + 0.9rem, 1.8rem);
    font-weight: 700;
    line-height: 1.32;
    text-wrap: pretty;
}

.q-text .w {
    white-space: nowrap;
}

.q-text .ch {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.35em) scale(0.7);
    transition: opacity 0.16s, transform 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.q-text .ch.in {
    opacity: 1;
    transform: none;
}

.slots {
    --slot: 40px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px calc(var(--slot) * 0.85);
    perspective: 600px;
}

.word {
    display: flex;
    gap: calc(var(--slot) * 0.14);
}

.slot {
    display: grid;
    place-items: center;
    width: var(--slot);
    height: calc(var(--slot) * 1.22);
    border-radius: calc(var(--slot) * 0.22);
    border-bottom: 3px solid var(--cat);
    background: rgba(255, 255, 255, 0.09);
    font-size: calc(var(--slot) * 0.68);
    font-weight: 800;
    line-height: 1;
    opacity: 0;
    transform: translateY(14px) scale(0.3);
    transition: opacity 0.2s, transform 0.4s cubic-bezier(0.2, 1.6, 0.4, 1), background-color 0.25s;
}

.slot.dealt {
    opacity: 1;
    transform: none;
}

.slot.on {
    border-color: transparent;
    background: var(--cat);
    color: var(--cat-ink);
    animation: flip 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.slot.missed {
    border-color: var(--bad);
    background: rgba(255, 93, 108, 0.16);
    color: #ff97a1;
}

.slot.fixed {
    border-color: transparent;
    background: transparent;
}

@keyframes flip {
    from {
        transform: rotateX(90deg) scale(0.9);
    }
}

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 18px;
    color: var(--ink-2);
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.3s;
}

.meta.show {
    opacity: 1;
}

.pips {
    display: inline-flex;
    gap: 6px;
}

.pips i {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-radius: 50%;
    transition: background-color 0.2s, border-color 0.2s, transform 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.pips i.used {
    border-color: var(--bad);
    background: var(--bad);
    transform: scale(1.15);
}

/* Keyboard */
.kb {
    --cols: 10;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 12px max(6px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0));
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    width: 100%;
    max-width: 800px;
}

.key {
    flex: 0 0 min(64px, calc((100% - (var(--cols) - 1) * 5px) / var(--cols)));
    height: clamp(46px, 7.2vh, 62px);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.14);
    font-size: clamp(1.08rem, 2.6vw, 1.45rem);
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.38);
    transition: background-color 0.15s, color 0.15s, transform 0.08s, box-shadow 0.08s, opacity 0.25s;
}

.key:hover {
    background: rgba(255, 255, 255, 0.22);
}

.key:active {
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.38);
    transform: translateY(2px);
}

.key.hit {
    background: var(--cat);
    color: var(--cat-ink);
}

.key.miss {
    background: rgba(255, 93, 108, 0.14);
    color: rgba(255, 255, 255, 0.32);
    box-shadow: none;
    text-decoration: line-through;
    text-decoration-color: var(--bad);
}

.key:disabled {
    cursor: default;
}

.kb.locked .key {
    opacity: 0.4;
    pointer-events: none;
}

/* End of round */
.result {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(8, 7, 26, 0.6);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s;
}

.result[hidden] {
    display: none;
}

.result.show {
    opacity: 1;
}

.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: min(100%, 460px);
    padding: 26px 22px 22px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 30px;
    background: linear-gradient(165deg, #2a2366, #15123a);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    text-align: center;
    transform: translateY(24px) scale(0.85);
    transition: transform 0.5s cubic-bezier(0.2, 1.5, 0.4, 1);
}

.result.show .result-card {
    transform: none;
}

.result-badge {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin-top: -64px;
    border: 5px solid #15123a;
    border-radius: 50%;
    background: linear-gradient(150deg, var(--gold), #ff9f43);
    color: #2e1d00;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.result.lose .result-badge {
    background: linear-gradient(150deg, #ff7a86, #d6304a);
    color: #fff;
}

.result-badge svg {
    width: 36px;
    height: 36px;
}

.result-title {
    font-size: clamp(2.5rem, 10vw, 3.6rem);
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(100deg, var(--gold), #fff 45%, var(--cat));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.result.lose .result-title {
    background: none;
    color: #ff8a95;
}

.result.show .result-title {
    animation: title-in 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) 0.1s both;
}

@keyframes title-in {
    from {
        opacity: 0;
        transform: scale(0.4) rotate(-6deg);
    }
}

.result-sub {
    color: var(--ink-2);
    font-size: 1.08rem;
    font-weight: 600;
}

.result-answer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    margin: 4px 0 10px;
}

.result-answer .word {
    gap: 4px;
}

.result-answer .slot {
    --slot: clamp(24px, 6.4vw, 34px);
    opacity: 1;
    transform: none;
    border-color: transparent;
    background: var(--cat);
    color: var(--cat-ink);
}

.result.lose .result-answer .slot {
    background: rgba(255, 255, 255, 0.12);
    color: var(--ink);
}

.continue {
    position: relative;
    width: 100%;
    max-width: 280px;
    padding: 13px 20px;
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
    color: #1b1640;
    font-size: 1.2rem;
    font-weight: 800;
    box-shadow: 0 5px 0 #a9a0e6;
    transition: transform 0.1s, box-shadow 0.1s;
}

.continue:active {
    box-shadow: 0 1px 0 #a9a0e6;
    transform: translateY(4px);
}

.continue i {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 5px;
    background: var(--cat);
    transform-origin: left;
}

.result.show .continue i {
    animation: drain var(--auto, 5s) linear forwards;
}

@keyframes drain {
    to {
        transform: scaleX(0);
    }
}

.confetti {
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Phones */
@media (max-width: 640px) {
    .screen-inner {
        gap: 22px;
    }

    .modes {
        grid-template-columns: minmax(0, 1fr);
        max-width: 420px;
    }

    .mode-card {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-items: center;
        gap: 2px 16px;
        padding: 16px;
        text-align: left;
    }

    .mode-art {
        grid-row: 1 / 3;
        width: 72px;
        height: 72px;
        margin: 0;
        border-radius: 22px;
    }

    .mode-art svg {
        width: 52px;
        height: 52px;
    }

    .mode-card b {
        align-self: end;
        font-size: 1.25rem;
    }

    .mode-card small {
        align-self: start;
        font-size: 0.92rem;
    }

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

    .cat-tile {
        gap: 12px;
        min-height: 112px;
        padding: 14px;
        border-radius: 20px;
    }

    .cat-tile .mark {
        width: 92px;
        height: 92px;
    }

    .cat-icon {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }

    .cat-icon svg {
        width: 24px;
        height: 24px;
    }

    .cat-name {
        font-size: 1.12rem;
    }

    .cat-tile.bonus {
        min-height: 76px;
    }

    .chip {
        height: 38px;
        padding-right: 12px;
        font-size: 0.95rem;
    }

    .chip .ci {
        width: 28px;
        height: 28px;
    }

    .timer {
        width: 46px;
        height: 46px;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .tb-sound {
        gap: 6px;
    }

    .topbar {
        gap: 8px;
    }

    .board-inner {
        gap: 14px;
    }

    .q-card {
        border-radius: 20px;
    }

    .gallows {
        height: min(200px, 100%);
    }
}

@media (max-height: 640px) {
    .key {
        height: 42px;
    }

    .kb {
        gap: 5px;
        padding-top: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg i,
    .brand span,
    .timer.urgent,
    .gallows.lost .man {
        animation: none;
    }

    .screen,
    .cat-tile,
    .slot,
    .q-text .ch {
        transition-duration: 0.01s;
        animation-duration: 0.01s;
    }
}
