:root {
    --l8-header-height: 62px;
    --l8-ink: #f6fbfd;
    --l8-muted: #b9d4df;
    --l8-dark: #002c42;
    --l8-green: #87c899;
    --l8-green-light: #015d82;
    --l8-yellow: #fddc01;
    --l8-red: #ed98ac;
    --l8-card-width-base: clamp(54px, calc((100dvh - 190px) * .13), 96px);
    --l8-card-width: var(--l8-card-width-base);
    --l8-card-height-factor: 1.535945;
    --l8-stack-max-offset: 18px;
    --l8-phase-card-min-visible: 30px;
}

body[data-level8-room] {
    --game-ui-accent: var(--l8-yellow);
    --game-ui-panel: #002c42f2;
    --game-ui-header-background: #fddc01;
    --game-ui-header-color: #015d82;
    --game-ui-surface: #f6fbf5ef;
    --game-ui-surface-text: #00364e;
    --game-ui-surface-muted: #486674;
    --game-ui-field-background: #fff;
    --game-ui-field-border: #9db9c5;
    --game-ui-primary-background: #015d82;
    --game-ui-primary-color: #fff;
}

@property --l8-light-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow: hidden;
    background: radial-gradient(ellipse 70% 60% at 0% 10%, #62c1e01c, transparent 72%), radial-gradient(ellipse 65% 65% at 100% 0%, #be87b418, transparent 72%), radial-gradient(ellipse 70% 70% at 0% 100%, #87c89917, transparent 72%), radial-gradient(ellipse 70% 65% at 100% 100%, #f0791715, transparent 72%), #002c42;
    color: var(--l8-ink);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

.l8-header {
    position: relative;
    z-index: 100;
    min-height: calc(var(--l8-header-height) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 16px 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    border-bottom: 1px solid #ffffff1c;
    background: #fddc01;
    backdrop-filter: blur(10px);
}

.l8-back,
.l8-brand {
    color: var(--l8-ink);
    text-decoration: none;
}

.l8-back {
    width: max-content;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: .8rem;
}

.l8-back svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.l8-brand {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.l8-brand img {
    display: block;
    width: auto;
    height: 100%;
    padding: 5px 0;
    object-fit: contain;
}

.l8-info {
    width: 29px;
    height: 29px;
    padding: 0;
    justify-self: end;
    border: 1px solid #c5d9c8;
    border-radius: 50%;
    background: transparent;
    color: var(--l8-ink);
    font-family: Georgia, serif;
    font-size: 1rem;
}

#level8-app {
    height: calc(100vh - var(--l8-header-height) - env(safe-area-inset-top, 0px));
    height: calc(100dvh - var(--l8-header-height) - env(safe-area-inset-top, 0px));
    overflow: auto;
}

.l8-panel {
    width: min(480px, calc(100% - 28px));
    margin: clamp(28px, 8vh, 80px) auto 24px;
    padding: clamp(20px, 5vw, 32px);
    border: 1px solid #ffffff99;
    border-radius: 26px;
    background: #f6fbf5ef;
    color: #00364e;
    text-align: center;
    box-shadow: 0 24px 60px #07130d99;
}

.l8-placeholder-logo {
    min-height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.l8-placeholder-logo img {
    width: auto;
    height: 98px;
    max-width: 72%;
    object-fit: contain;
}

.l8-placeholder-logo strong {
    margin-left: -8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--l8-red);
    color: #fff7d4;
    font-family: Georgia, serif;
    font-size: clamp(1.8rem, 8vw, 2.75rem);
    line-height: 1;
    letter-spacing: -.07em;
    transform: rotate(2deg);
    box-shadow: 0 8px 20px #0006;
}

.l8-panel h1 {
    margin: 8px 0;
    font-size: clamp(1.45rem, 6vw, 2rem);
}

.l8-panel p {
    color: #486674;
}

.l8-form,
.l8-form label {
    display: grid;
    gap: 8px;
}

.l8-form {
    margin-top: 22px;
    text-align: left;
}

.l8-form label {
    color: #486674;
    font-size: .8rem;
}

.l8-form input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #9db9c5;
    border-radius: 10px;
    outline: none;
    background: #fff;
    color: #00364e;
    font-size: 1rem;
}

.l8-form input:focus {
    border-color: var(--l8-yellow);
    box-shadow: 0 0 0 3px #fddc014d;
}

.l8-player-setup {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 11px;
    border: 1px solid #c8dbe2;
    border-radius: 10px;
    background: #eef7f7;
}

.l8-player-setup legend {
    padding: 0 4px;
    color: #486674;
    font-size: .8rem;
}

.l8-player-setup .l8-icon-button {
    justify-self: start;
}

.l8-player-inputs {
    display: grid;
    gap: 8px;
}

.l8-add-player {
    justify-self: start;
    padding: 7px 10px;
    border: 1px solid #015d82;
    border-radius: 8px;
    background: transparent;
    color: #015d82;
    font-weight: 700;
}

.l8-share,
.l8-player-controls {
    display: flex;
    gap: 8px;
    align-items: end;
}

.l8-share input,
.l8-player-controls label {
    flex: 1;
    min-width: 0;
}

.l8-player-shares {
    display: grid;
    gap: 8px;
}

.l8-player-share {
    align-items: center;
}

.l8-player-share-info {
    min-width: 0;
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 11px;
    border: 1px solid #c8dbe2;
    border-radius: 10px;
    background: #fff;
}

.l8-player-share-info > span:last-child {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.l8-player-share-info strong {
    overflow-wrap: anywhere;
}

.l8-player-share-info small {
    white-space: normal;
}

.l8-player-share-info small {
    color: #486674;
    font-size: .72rem;
}

.l8-avatar {
    width: 31px;
    height: 31px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--l8-green-light);
    color: var(--l8-ink);
    font-weight: 900;
}

.l8-icon-button {
    width: 44px;
    min-width: 44px;
    margin: 0;
    margin-top: 0;
    padding: 10px;
    display: grid;
    place-items: center;
}

.l8-icon-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.l8-primary,
.l8-secondary,
.l8-link-button,
.l8-result-card button {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 10px;
}

.l8-primary {
    border: 1px solid #015d82;
    background: #015d82;
    color: #fff;
    font-weight: 800;
}

.l8-primary:disabled {
    opacity: .42;
}

.l8-secondary {
    width: 100%;
    margin-top: 10px;
    border: 1px solid #9db9c5;
    background: #e9f4f5;
    color: #015d82;
}

.l8-secondary.l8-icon-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    margin-top: 0;
    padding: 10px;
    flex: 0 0 44px;
}

.l8-link-button {
    border: 0;
    background: transparent;
    color: #015d82;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.l8-player-list {
    margin: 18px 0;
    padding: 0;
    display: grid;
    gap: 7px;
    list-style: none;
}

.l8-player-list li {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    border-radius: 9px;
    background: #ffffff0b;
}

.l8-player-list small {
    color: var(--l8-yellow);
}

.l8-recent {
    width: min(560px, calc(100% - 28px));
    margin: 0 auto 40px;
}

.l8-recent h2 {
    margin: 0 0 10px;
    font-size: .86rem;
    font-weight: 500;
    color: var(--l8-muted);
}

.l8-recent-session {
    margin-bottom: 8px;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    border: 1px solid #ffffff18;
    border-radius: 12px;
    background: #003b56dd;
}

.l8-recent-session > div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.l8-recent-session strong {
    overflow-wrap: anywhere;
}

.l8-recent-session small {
    color: var(--l8-muted);
}

.l8-recent-players {
    margin-top: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.l8-recent-players button {
    min-height: 44px;
    padding: 8px 11px;
    border: 1px solid #62c1e0;
    border-radius: 7px;
    background: #015d82;
    color: var(--l8-ink);
    font-size: .75rem;
}

.l8-delete-session {
    width: 44px;
    height: 44px;
    padding: 7px;
    border: 0;
    background: transparent;
    color: #ed98ac;
}

.l8-delete-session svg,
.l8-fullscreen svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.l8-board {
    height: 100%;
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) * 5 + 96px);
    padding: 10px max(10px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
    display: grid;
    grid-template-rows: calc(var(--l8-card-width) * var(--l8-card-height-factor) * 2 + 34px) minmax(calc(var(--l8-card-width) * var(--l8-card-height-factor)), 1fr) calc(var(--l8-card-width) * var(--l8-card-height-factor) * 2 + 42px);
    gap: 5px;
    position: relative;
    isolation: isolate;
}

.l8-board::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    opacity: 1;
    transition: opacity .24s ease;
}

.l8-board > * {
    position: relative;
    z-index: 1;
}

.l8-board.l8-active-top::before {
    --l8-light-angle: 0deg;
    background: linear-gradient(var(--l8-light-angle), transparent 22%, #0096e61e 55%, #0096e691 100%);
}

.l8-board.l8-active-bottom::before {
    --l8-light-angle: 180deg;
    background: linear-gradient(var(--l8-light-angle), transparent 22%, #0096e61e 55%, #0096e691 100%);
}

.l8-board.l8-light-to-bottom::before {
    animation: l8-light-rotate-to-bottom 2s cubic-bezier(.35, .75, .25, 1) both;
}

.l8-board.l8-light-to-top::before {
    animation: l8-light-rotate-to-top 2s cubic-bezier(.35, .75, .25, 1) both;
}

@keyframes l8-light-rotate-to-bottom {
    from {
        --l8-light-angle: 0deg;
    }
    to {
        --l8-light-angle: 180deg;
    }
}

@keyframes l8-light-rotate-to-top {
    from {
        --l8-light-angle: 180deg;
    }
    to {
        --l8-light-angle: 0deg;
    }
}

.l8-board.busy button {
    pointer-events: none;
}

.l8-opponents {
    min-width: 0;
    max-width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: safe center;
    gap: clamp(6px, 2vw, 18px);
    overflow-x: auto;
    scrollbar-width: thin;
}

.l8-opponent-slot,
.l8-own-slot {
    position: relative;
    min-width: 0;
    text-align: center;
}

.l8-opponent-slot {
    flex: 0 0 auto;
}

.l8-own-slot {
    align-self: end;
}

.l8-own-area {
    position: relative;
    min-width: 0;
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) * 2 + 42px);
    display: flex;
    align-items: flex-end;
    align-self: end;
}

.l8-own-area .l8-own-slot {
    width: 100%;
}

.l8-opponent {
    position: relative;
    min-width: 0;
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) * 2 + 34px);
    padding: 5px 8px 7px;
    text-align: center;
}

.l8-skip-card {
    position: absolute;
    z-index: 20;
    top: 50%;
    left: 50%;
    width: var(--l8-card-width);
    border-radius: 8.4%;
    pointer-events: none;
    transform: translate(-50%, -50%) rotate(-4deg);
    box-shadow: 0 8px 22px #0009;
    animation: l8-skip-card-in .24s ease-out both;
}

.l8-skip-card.own {
    top: 0;
    animation: none;
    transform: translate(-50%, -35%) rotate(-4deg);
}

.l8-skip-card.own.l8-exchange-marker {
    transform: translate(-50%, -43%) rotate(-4deg);
}

@keyframes l8-skip-card-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(.7) rotate(8deg);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(-4deg);
    }
}

.l8-opponent header {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
}

.l8-opponent header .l8-opponent-name {
    max-width: min(32ch, 45vw);
    overflow-wrap: anywhere;
    font-size: .8rem;
    font-weight: 700;
}

.l8-opponent header small,
.l8-opponent-meta {
    color: var(--l8-muted);
    font-size: .62rem;
}

.l8-opponent-hand {
    height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 4px);
    margin-top: 3px;
    display: flex;
    justify-content: center;
}

.l8-opponent-hand img {
    width: var(--l8-card-width);
    height: auto;
    aspect-ratio: 59.264484 / 91.026985;
    margin-left: -25px;
    border-radius: 8.4%;
}

.l8-opponent-hand img:first-child {
    margin-left: 0;
}

.l8-opponents.two-player .l8-opponent-hand {
    height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 4px);
}

.l8-opponents.two-player .l8-opponent-hand img {
    width: var(--l8-card-width);
    height: auto;
    margin-left: clamp(-52px, -5vw, -27px);
    border-radius: 8.4%;
}

.l8-opponents.two-player .l8-opponent-hand img:first-child {
    margin-left: 0;
}

.l8-table {
    align-self: stretch;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 7px;
}

.l8-turn,
.l8-move {
    min-height: 18px;
    margin: 0;
    text-align: center;
}

.l8-turn {
    color: var(--l8-yellow);
    font-weight: 800;
}

.l8-move {
    max-width: min(520px, 90vw);
    color: var(--l8-muted);
    font-size: .72rem;
}

.l8-piles {
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: safe center;
    gap: clamp(12px, 3vw, 30px);
    max-width: calc(100vw - 24px);
    padding: 4px 22px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.l8-deck,
.l8-discard-piles {
    flex: 0 0 auto;
}

.l8-discard-piles {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    max-width: none;
}

.l8-personal-discard {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    justify-items: center;
    gap: 3px;
    min-width: calc(var(--l8-card-width) + var(--l8-stack-max-offset));
}

.l8-personal-discard small {
    max-width: min(20ch, 52vw);
    color: var(--l8-muted);
    font-size: clamp(.5rem, 1.4vw, .68rem);
    line-height: 1.1;
    text-align: center;
    overflow-wrap: anywhere;
}

.l8-pile {
    position: relative;
    width: calc(var(--l8-card-width) + var(--l8-stack-max-offset));
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 9px);
    padding: 0;
    border: 0;
    background: transparent;
}

.l8-personal-discard .l8-pile {
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 5px);
}

.l8-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 59.264484 / 91.026985;
    display: block;
    border-radius: 8.4%;
    object-fit: contain;
}

.l8-physical-stack {
    position: relative;
    display: block;
    width: calc(var(--l8-card-width) + var(--stack-offset));
    height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + var(--stack-offset));
    isolation: isolate;
}

.l8-pile .l8-stack-card {
    position: absolute;
    top: var(--card-offset);
    left: var(--card-offset);
    width: var(--l8-card-width);
    height: auto;
    aspect-ratio: 59.264484 / 91.026985;
    display: block;
    border: 0;
    border-radius: 8.4%;
    object-fit: contain;
    pointer-events: none;
}

.l8-flying-card {
    position: fixed;
    z-index: 130;
    margin: 0;
    border-radius: 8.4%;
    pointer-events: none;
    transform-origin: top left;
    will-change: transform;
    perspective: 900px;
}

.l8-flying-card-lift {
    transition: transform .07s ease-out;
}

.l8-flying-card-flight {
    transition: transform var(--l8-flight-duration) cubic-bezier(.2, .8, .2, 1);
}

.l8-flying-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.l8-flying-card-front {
    transform: rotateY(180deg);
}

.l8-flying-card-flip .l8-flying-card-back {
    animation: l8-flying-card-back-flip .45s ease-in-out .28s forwards;
}

.l8-flying-card-flip .l8-flying-card-front {
    animation: l8-flying-card-front-flip .45s ease-in-out .28s forwards;
}

.l8-flying-card-fast.l8-flying-card-flip .l8-flying-card-back {
    animation-delay: .16s;
    animation-duration: .3s;
}

.l8-flying-card-fast.l8-flying-card-flip .l8-flying-card-front {
    animation-delay: .16s;
    animation-duration: .3s;
}

.l8-flying-card-quick.l8-flying-card-flip .l8-flying-card-back {
    animation-delay: .25s;
    animation-duration: .35s;
}

.l8-flying-card-quick.l8-flying-card-flip .l8-flying-card-front {
    animation-delay: .25s;
    animation-duration: .35s;
}

.l8-card-arrival-hidden,
.l8-card-departure-hidden {
    opacity: 0 !important;
}

.l8-card-arrived {
    transform-origin: top left;
    animation: l8-card-arrived .1s ease-out;
}

.l8-phase-deal-hidden {
    opacity: 0 !important;
}

.l8-phase-card-dealt {
    animation: l8-phase-card-dealt .24s cubic-bezier(.2, .8, .2, 1);
}

.l8-deck-refilling .l8-stack-card {
    animation: l8-deck-shuffle .48s ease-in-out infinite alternate;
}

.l8-deck-refilling .l8-stack-card:nth-child(2n) {
    animation-delay: -.24s;
}

@keyframes l8-flying-card-back-flip {
    to {
        transform: rotateY(-180deg);
    }
}

@keyframes l8-flying-card-front-flip {
    to {
        transform: rotateY(0);
    }
}

@keyframes l8-card-arrived {
    from {
        filter: brightness(1.45);
        transform: scale(.96);
    }
    to {
        filter: none;
        transform: none;
    }
}

@keyframes l8-phase-card-dealt {
    from {
        opacity: 0;
        transform: translateY(-14px) scale(.97);
        filter: brightness(1.35);
    }
    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

@keyframes l8-deck-shuffle {
    from {
        transform: translate(-4px, -2px) rotate(-3deg);
    }
    to {
        transform: translate(4px, 2px) rotate(3deg);
    }
}

.l8-empty-card {
    width: var(--l8-card-width);
    aspect-ratio: 59.264484 / 91.026985;
    display: grid;
    place-items: center;
    border: 1px solid #ffffff26;
    border-radius: 8.4%;
    background: transparent;
}

.l8-required-suit {
    position: absolute;
    right: -14px;
    bottom: -10px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 2px solid #fff7de;
    border-radius: 50%;
    background: #fff7de;
    color: #1a211c;
    font-size: 1.35rem;
    box-shadow: 0 4px 12px #0007;
    transition: opacity .16s ease, transform .16s ease;
}

.l8-board.conceal-required-suit .l8-required-suit {
    opacity: 0;
    transform: scale(.7);
}

.l8-required-suit.hearts,
.l8-required-suit.diamonds {
    color: #c63232;
}

.l8-keep {
    margin-top: 8px;
    padding: 7px 11px;
    border: 1px solid #a7c6ad;
    border-radius: 8px;
    background: #173a29;
    color: var(--l8-ink);
    font-size: .76rem;
}

.l8-own {
    position: relative;
    min-width: 0;
    padding: 7px 8px 0;
    align-self: end;
}

.l8-own.active {
    overflow: visible;
}

.l8-player-announcement {
    position: absolute;
    z-index: 30;
    display: block;
    width: fit-content;
    margin: 0;
    padding: 8px 14px;
    border: 2px solid #ffe27a;
    border-radius: 999px;
    background: #351f18f2;
    color: #ffe27a;
    font-family: Georgia, serif;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: .02em;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 5px 18px #0009, 0 0 0 3px #ffe27a2b;
    transform: translateX(-50%);
    animation: l8-call-confirmation .2s ease-out both;
}

.l8-opponent-slot .l8-player-announcement {
    top: calc(100% + 5px);
    left: 50%;
}

.l8-own-slot .l8-player-announcement {
    bottom: calc(100% + 5px);
    left: 50%;
}

.l8-own-header {
    position: relative;
    padding: 0 4px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    color: var(--l8-muted);
    font-size: .72rem;
    max-width: 700px;
    width: 100%;
}

.l8-own-header small {
    margin-left: auto;
    text-align: right;
    font-size: .84rem;
}

.l8-phase-info-wrap {
    position: relative;
    margin-left: 2px;
}

.l8-own-meta {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--l8-muted);
    font-size: .84rem;
    text-align: right;
}

.l8-opponent-meta {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--l8-muted);
    font-size: .62rem;
    cursor: pointer;
}

.l8-master-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin: 10px 0;
}

.l8-master-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    cursor: pointer;
}

.l8-master-option:has(input:disabled) {
    opacity: .55;
    cursor: default;
}

.l8-master-switch input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
}

.l8-master-switch-control {
    position: relative;
    flex: 0 0 42px;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: rgb(255 255 255 / 20%);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 28%);
    transition: background .2s ease, box-shadow .2s ease;
}

.l8-master-switch-control::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px #0008;
    transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}

.l8-master-switch input:checked + .l8-master-switch-control {
    background: #173a29;
    box-shadow: inset 0 0 0 1px #fff7;
}

.l8-master-switch input:checked + .l8-master-switch-control::after {
    transform: translateX(18px);
}

.l8-master-switch input:focus-visible + .l8-master-switch-control {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.l8-phase-tooltip {
    position: fixed;
    z-index: 1000;
    width: max-content;
    max-width: min(300px, calc(100vw - 24px));
    padding: 8px 11px;
    border: 1px solid #ffe681;
    border-radius: 9px;
    background: #102319f2;
    color: #ffe681;
    font-size: .82rem;
    line-height: 1.25;
    text-align: left;
    box-shadow: 0 5px 18px #0008;
    visibility: hidden;
}

.l8-hand-sorts {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.l8-hand-sorts button {
    height: 24px;
    padding: 0 4px;
    border: 1px solid rgb(255 255 255 / 30%);
    border-radius: 5px;
    background: rgb(0 0 0 / 24%);
    color: var(--l8-ink);
    font-size: .69rem;
    font-weight: 800;
    line-height: 1;
}

.l8-hand-sorts button:last-child {
    display: grid;
    grid-template-columns: repeat(6, 7px);
    place-content: center;
    gap: 2px;
}

.l8-hand-sorts i {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 1px;
}

.l8-hand-sorts i:nth-child(1) {
    background: #fed500;
}

.l8-hand-sorts i:nth-child(2) {
    background: #f07917;
}

.l8-hand-sorts i:nth-child(3) {
    background: #ed98ac;
}

.l8-hand-sorts i:nth-child(4) {
    background: #be87b4;
}

.l8-hand-sorts i:nth-child(5) {
    background: #62c1e0;
}

.l8-hand-sorts i:nth-child(6) {
    background: #87c899;
}

.l8-own-name-wrap {
    position: relative;
}

.l8-player-name {
    min-width: 0;
    max-width: min(180px, 48vw);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--l8-ink);
    font-size: .9rem;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.l8-opponent-name::before,
.l8-player-name::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin: 0 .42em .08em 0;
    border-top: .34em solid transparent;
    border-bottom: .34em solid transparent;
    border-left: .52em solid transparent;
}

.l8-opponent.active .l8-opponent-name::before,
.l8-own-header.active .l8-player-name::before {
    border-left-color: #37c965;
}

.l8-call-buttons {
    position: absolute;
    z-index: 12;
    top: -6px;
    right: 7px;
    display: flex;
    gap: 5px;
    transform: translateY(-100%);
}

.l8-call-buttons button {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid #fff5c5;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
}

.l8-call-buttons button.rejected {
    border-color: #ef6257;
    color: #ef6257;
}

.l8-call-confirmation {
    align-self: center;
    padding: 4px 7px;
    color: #fff4b0;
    font-family: Georgia, serif;
    font-size: .82rem;
    font-weight: 800;
    white-space: nowrap;
    animation: l8-call-confirmation .2s ease-out both;
}

.l8-own-hand {
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 12px);
    padding: 8px 8px 5px;
    display: flex;
    align-items: flex-end;
    justify-content: safe center;
    overflow: visible;
    scrollbar-width: none;
}

.l8-own-hand::-webkit-scrollbar {
    display: none;
}

.l8-card {
    position: relative;
    z-index: var(--card-order);
    width: var(--l8-card-width);
    min-width: var(--l8-card-width);
    padding: 0;
    border: 0;
    background: transparent;
    transition: transform .16s ease;
}

.l8-own-card {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.l8-own-card img {
    -webkit-user-drag: none;
    user-drag: none;
}

.l8-own-card.dragging {
    opacity: .38;
    cursor: grabbing;
    transform: translateY(-16px) scale(.96);
}

.l8-card + .l8-card {
    margin-left: clamp(-52px, -5vw, -27px);
}

.l8-card:not(:disabled):hover,
.l8-card:not(:disabled):focus-visible {
    outline: none;
}

.l8-card.rejected {
    animation: l8-card-rejected .52s ease-in-out;
    transform-origin: 50% 85%;
}

.l8-announcement {
    position: fixed;
    z-index: 900;
    top: 45%;
    left: 50%;
    padding: 13px 22px;
    border: 2px solid #fff2af;
    border-radius: 14px;
    background: var(--l8-red);
    color: #fff;
    font-family: Georgia, serif;
    font-size: clamp(2rem, 10vw, 4rem);
    font-weight: 900;
    letter-spacing: -.06em;
    pointer-events: none;
    transform: translate(-50%, -50%) rotate(-3deg);
    box-shadow: 0 18px 50px #0009;
    animation: l8-pop .3s ease-out both;
}

.l8-flying-card {
    position: fixed;
    z-index: 850;
    border-radius: 8px;
    pointer-events: none;
    transform-origin: top left;
    transition: transform .9s cubic-bezier(.2, .8, .2, 1), opacity .08s ease .9s;
    perspective: 900px;
    will-change: transform, opacity;
}

.l8-flying-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.l8-flying-card-front {
    transform: rotateY(180deg);
}

.l8-flying-card.flip .l8-flying-card-back {
    animation: l8-card-back-flip .52s ease-in-out calc(var(--l8-fly-delay, 0ms) + .2s) forwards;
}

.l8-flying-card.flip .l8-flying-card-front {
    animation: l8-card-front-flip .52s ease-in-out calc(var(--l8-fly-delay, 0ms) + .2s) forwards;
}

.l8-card-arrival-hidden {
    visibility: hidden !important;
}

.l8-overlay,
.l8-result-overlay,
.l8-rules-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 18px;
    display: grid;
    place-items: center;
    background: #07130dba;
    backdrop-filter: blur(5px);
}

.l8-dialog,
.l8-result-card,
.l8-rules-card {
    width: min(420px, 100%);
    padding: 24px;
    border: 1px solid #ffffff28;
    border-radius: 18px;
    background: #11291f;
    text-align: center;
    box-shadow: 0 24px 70px #000a;
}

.l8-suit-overlay {
    align-items: end;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--l8-card-width) * var(--l8-card-height-factor) + 76px);
    background: transparent;
    backdrop-filter: none;
}

.l8-result-overlay {
    inset: calc(var(--l8-header-height) + env(safe-area-inset-top, 0px) + 10px) 12px auto;
    padding: 0;
    display: flex;
    justify-content: center;
    background: transparent;
    backdrop-filter: none;
    pointer-events: none;
}

.l8-result-overlay .l8-result-card {
    width: min(340px, 100%);
    padding: 12px 16px;
    pointer-events: auto;
    background: #11291ff2;
    box-shadow: 0 10px 28px #0009;
}

.l8-result-overlay .l8-result-symbol {
    font-size: 1.6rem;
}

.l8-result-overlay .l8-result-card h2 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.l8-suit-overlay .l8-dialog {
    width: min(360px, 100%);
    padding: 14px 16px 10px;
    background: #11291ff2;
}

.l8-suit-overlay .l8-dialog h2 {
    margin-bottom: 10px;
}

.l8-suit-overlay .l8-suit-options button {
    height: 52px;
    aspect-ratio: auto;
}

.l8-dialog h2,
.l8-result-card h2,
.l8-rules-card h2 {
    margin: 0 0 18px;
}

.l8-suit-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
}

.l8-suit-options button {
    aspect-ratio: 1;
    border: 1px solid #d9dacd;
    border-radius: 12px;
    background: #f8f1d9;
    color: #161b17;
    font-size: 2.2rem;
}

.l8-suit-options .hearts,
.l8-suit-options .diamonds {
    color: #c63232;
}

.l8-result-symbol {
    color: var(--l8-red);
    font-size: 3rem;
}

.l8-result-card button {
    border: 0;
}

.l8-result-card button:disabled {
    background: #244536;
    color: var(--l8-muted);
}

.l8-rules-overlay {
    z-index: 2000;
    overflow-y: auto;
}

.l8-rules-card {
    position: relative;
    max-height: min(720px, calc(100dvh - 36px));
    overflow-y: auto;
    text-align: left;
}

.l8-rules-card h2 {
    color: var(--l8-yellow);
    font-family: Georgia, serif;
    font-size: 2rem;
}

.l8-rules-card h3 {
    margin: 20px 0 5px;
    font-size: .95rem;
}

.l8-rules-card p,
.l8-rules-card li {
    color: #d2ded2;
    font-size: .86rem;
    line-height: 1.5;
}

.l8-rules-card ul {
    padding-left: 20px;
}

.l8-rules-card a {
    color: var(--l8-yellow);
    font-size: .78rem;
}

.l8-rules-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--l8-ink);
    font-size: 1.7rem;
}

.l8-reaction-bubble {
    position: absolute;
    z-index: 80;
    top: calc(100% + 6px);
    left: 50%;
    min-width: 38px;
    max-width: min(280px, calc(100vw - 30px));
    padding: 7px 10px;
    border: 0;
    border-radius: 14px;
    background: #fff;
    color: #213227;
    font-size: 1.3rem;
    line-height: 1;
    box-shadow: 0 5px 18px #0007;
    transform: translateX(-50%);
}

.l8-reaction-bubble.own {
    top: auto;
    bottom: calc(100% + 7px);
    left: 0;
    transform: none;
}

.l8-reaction-bubble.message {
    width: max-content;
    overflow-wrap: anywhere;
    font-size: .82rem;
    line-height: 1.25;
    text-align: left;
}

.l8-reaction-picker,
.l8-reaction-composer {
    position: fixed;
    z-index: 1500;
    left: 50%;
    bottom: max(84px, calc(env(safe-area-inset-bottom, 0px) + 66px));
    transform: translateX(-50%);
    border: 1px solid #ffffff38;
    border-radius: 13px;
    background: #10271ff5;
    box-shadow: 0 8px 28px #0009;
}

.l8-reaction-picker {
    padding: 7px;
    display: flex;
    gap: 5px;
}

.l8-reaction-picker > div {
    display: grid;
    grid-template-columns: repeat(7, 34px);
    gap: 3px;
}

.l8-reaction-picker button {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 1.12rem;
}

.l8-reaction-picker button:hover,
.l8-reaction-picker button:focus-visible {
    background: #ffffff20;
}

.l8-reaction-composer {
    width: min(360px, calc(100vw - 24px));
    padding: 7px;
    display: flex;
    gap: 6px;
}

.l8-reaction-composer input {
    min-width: 0;
    padding: 9px 10px;
    flex: 1;
    border: 0;
    border-radius: 8px;
    background: #fff9e5;
    color: #18271d;
}

.l8-reaction-composer button {
    padding: 8px 11px;
    border: 0;
    border-radius: 8px;
    background: var(--l8-red);
    color: #fff;
    font-weight: 700;
}

#level8-status {
    position: fixed;
    z-index: 3000;
    right: 14px;
    bottom: 14px;
    max-width: min(360px, calc(100vw - 28px));
    padding: 10px 13px;
    border: 1px solid #f4d868;
    border-radius: 10px;
    background: #10251bf2;
    color: #ffe885;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity .18s ease, transform .18s ease;
}

#level8-status.visible {
    opacity: 1;
    transform: none;
}

.l8-fullscreen {
    position: fixed;
    z-index: 120;
    right: max(3px, env(safe-area-inset-right, 0px));
    bottom: max(3px, env(safe-area-inset-bottom, 0px));
    width: 38px;
    height: 38px;
    padding: 8px;
    border: 0;
    background: #10251b99;
    color: var(--l8-muted);
}

.l8-fullscreen.active {
    color: var(--l8-yellow);
}

@keyframes l8-pop {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(-8deg) scale(.5);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(-3deg) scale(1);
    }
}

@keyframes l8-card-back-flip {
    to {
        transform: rotateY(-180deg);
    }
}

@keyframes l8-card-front-flip {
    to {
        transform: rotateY(0);
    }
}

@keyframes l8-card-rejected {
    0%, 100% {
        transform: rotate(0);
    }
    18% {
        transform: rotate(-5deg);
    }
    36% {
        transform: rotate(5deg);
    }
    54% {
        transform: rotate(-4deg);
    }
    72% {
        transform: rotate(4deg);
    }
    88% {
        transform: rotate(-2deg);
    }
}

@keyframes l8-call-confirmation {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px) scale(.9);
    }
    to {
        opacity: 1;
        transform: translateX(-50%);
    }
}

@media (max-width: 620px) {
    :root {
        --l8-card-width-base: clamp(66px, 20vw, 82px);
    }

    .l8-header {
        padding-inline: 10px;
    }

    .l8-back span {
        display: none;
    }

    .l8-board {
        grid-template-rows: minmax(79px, auto) minmax(155px, 1fr) minmax(132px, auto);
        padding-inline: 5px;
    }

    .l8-opponents {
        gap: 1px;
    }

    .l8-opponent {
        padding-inline: 3px;
    }

    .l8-opponent header .l8-opponent-name {
        font-size: .68rem;
    }

    .l8-opponent-hand img {
        margin-left: -23px;
    }

    .l8-piles {
        gap: 30px;
    }

    .l8-call-buttons button {
        min-height: 31px;
        padding: 5px 8px;
        font-size: .66rem;
    }

    .l8-card + .l8-card {
        margin-left: -36px;
    }

    .l8-opponents.two-player .l8-opponent-hand img {
        margin-left: -36px;
    }

    .l8-reaction-picker {
        gap: 3px;
    }

    .l8-reaction-picker > div {
        grid-template-columns: repeat(7, 30px);
    }

    .l8-reaction-picker button {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
}

@media (orientation: landscape) and (max-height: 620px) {
    :root {
        --l8-header-height: 50px;
        --l8-card-width-base: clamp(58px, 11vh, 74px);
    }

    .l8-board {
        grid-template-rows: minmax(66px, auto) minmax(108px, 1fr) 100px;
        gap: 1px;
        padding-top: 3px;
    }

    .l8-opponent {
        padding-block: 2px;
    }

    .l8-opponent-hand img {
        margin-left: -21px;
    }

    .l8-table {
        grid-template-columns: auto auto auto;
        grid-template-rows: auto auto;
        column-gap: 14px;
    }

    .l8-turn {
        grid-column: 1 / -1;
    }

    .l8-piles {
        grid-column: 2;
        grid-row: 2;
    }

    .l8-keep {
        grid-column: 3;
        grid-row: 2;
    }

    .l8-move {
        grid-column: 1;
        grid-row: 2;
        max-width: 160px;
    }

    .l8-own {
        padding-top: 3px;
    }

    .l8-own-hand {
        min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 3px);
        padding-top: 2px;
    }

    .l8-card + .l8-card {
        margin-left: -31px;
    }

    .l8-opponents.two-player .l8-opponent-hand img {
        margin-left: -31px;
    }

    .l8-call-buttons {
        transform: none;
    }

    .l8-suit-overlay {
        align-items: start;
        padding-top: calc(var(--l8-header-height) + env(safe-area-inset-top, 0px) + 7px);
        padding-bottom: 0;
    }

    .l8-suit-overlay .l8-dialog {
        width: min(330px, 62vw);
    }

    .l8-suit-overlay .l8-suit-options button {
        height: 40px;
        font-size: 1.7rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Level 8 additions */
.l8-board {
    grid-template-rows: minmax(92px, auto) minmax(210px, 1fr) auto;
}

.l8-table {
    min-width: 0;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    align-content: center;
    overflow: visible;
    padding-top: 0;
}

.l8-table .l8-piles {
    grid-column: 1;
    grid-row: 1;
}

.l8-laid-phases {
    display: grid;
    gap: 8px;
    width: min(100%, 760px);
    margin: 10px auto 0;
}

.l8-laid-phases section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.l8-laid-phases section > strong {
    width: 92px;
    flex: 0 0 92px;
    overflow-wrap: anywhere;
}

.l8-laid-phases section > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.l8-laid-group {
    padding: 5px 8px;
    border: 1px solid rgb(255 255 255 / 22%);
    border-radius: 10px;
    background: rgb(0 0 0 / 22%);
    color: var(--l8-ink);
}

.l8-laid-group small {
    display: block;
    margin-bottom: 4px;
}

.l8-laid-cards {
    display: inline-flex;
    align-items: flex-end;
    padding: 1px 0;
}

.l8-laid-group img {
    width: var(--l8-card-width);
    margin-left: -15px;
    border-radius: 8.4%;
    vertical-align: bottom;
    box-shadow: 0 1px 3px #0008;
}

.l8-laid-group img:first-child {
    margin-left: 0;
}

.l8-no-phases {
    margin: 8px 0;
    color: var(--l8-muted);
    font-size: .82rem;
}

.l8-phase-builder {
    position: relative;
    margin: 0 0 3px;
    padding: 8px;
    border: 1px solid rgb(255 255 255 / 16%);
    border-radius: 12px;
    background: rgb(0 0 0 / 18%);
    opacity: 0.7;
}

.l8-phase-builder > div {
    display: flex;
    justify-content: center;
    gap: 7px;
}

.l8-group-choice {
    display: grid;
    width: calc(var(--l8-card-width) * (.5 + var(--l8-group-card-count) * .5));
    height: calc(var(--l8-card-width) * var(--l8-card-height-factor));
    justify-items: center;
    gap: 3px;
    min-width: 0;
}

.l8-group-slot {
    display: grid;
    gap: 2px;
    padding: 6px 9px;
    border: 1px dashed rgb(255 255 255 / 35%);
    border-radius: 8px;
    background: rgb(255 255 255 / 7%);
    color: var(--l8-ink);
    width: 100%;
    height: 100%;
    min-width: 0;
    align-items: center;
}

.l8-group-slot strong {
    word-wrap: anywhere;
}

.l8-phase-actions {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.l8-phase-actions button {
    position: absolute;
    pointer-events: auto;
    width: 25px;
    height: 25px;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 38%);
    border-radius: 50%;
    background: #111d19e8;
    color: var(--l8-ink);
    font-size: 1.1rem;
    line-height: 1;
}

.l8-phase-actions button[data-clear-groups] {
    bottom: -5px;
    left: -5px;
    font-size: 1.2rem;
}

.l8-phase-actions button[data-lay-phase] {
    top: -5px;
    right: -5px;
}

.l8-group-slot small {
    color: var(--l8-muted);
}

.l8-group-choice.has-cards {
    height: auto;
}

.l8-phase-builder .l8-group-choice.has-cards {
    width: max-content;
}

.l8-group-choice.has-cards .l8-group-slot {
    height: auto;
    width: max-content;
    padding: 0;
    border: 0;
    background: transparent;
}

.l8-group-cards {
    display: flex;
    align-items: flex-start;
    height: calc(var(--l8-card-width) * var(--l8-card-height-factor));
    padding-top: 1px;
    transform: translateY(-12px);
    margin-bottom: -12px;
    min-width: 0;
}

.l8-group-cards img {
    width: var(--l8-card-width);
    margin-left: 0;
    border-radius: 8.4%;
    box-shadow: 0 1px 3px #0008;
}

.l8-phase-card {
    display: block;
    touch-action: none;
    user-select: none;
}

.l8-phase-card + .l8-phase-card {
    margin-left: max(calc(var(--l8-phase-card-min-visible) - var(--l8-card-width)), clamp(-52px, -5vw, -27px));
}

/* Auf schmalen Displays dürfen Zwillingspaare kompakter stehen. */
@media (max-width: 509px) {
    .l8-group-cards:has(.l8-phase-card:nth-child(2):last-child) .l8-phase-card + .l8-phase-card {
        margin-left: calc(var(--l8-card-width) * -.8);
    }
}

.l8-phase-card.dragging {
    opacity: .4;
}

.l8-phase-card.selected {
    z-index: 3;
    border-radius: 8.4%;
    transform: translateY(-15px);
}

.l8-group-choice.has-cards .l8-group-cards {
    transform: none;
    margin-bottom: 0;
}

.l8-own-phase {
    z-index: 4;
    width: max-content;
    max-width: min(100vw - 12px, 760px);
    justify-self: center;
    align-self: end;
}

.l8-player-phase {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
}

.l8-player-phase-group {
    display: flex;
    align-items: flex-end;
}

.l8-player-phase-card {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    line-height: 0;
    vertical-align: bottom;
}

.l8-player-phase-card > span {
    display: flex;
    align-items: flex-end;
}

.l8-player-phase-group img {
    width: var(--l8-card-width);
    border-radius: 8.4%;
    box-shadow: 0 1px 3px #0008;
}

.l8-player-phase-card + .l8-player-phase-card,
.l8-player-phase-card img + img {
    margin-left: clamp(-52px, -5vw, -27px);
}

.l8-opponent-phase {
    margin-top: 6px;
}

.l8-clear-groups {
    display: block;
    width: auto;
    margin: 1px auto 5px;
    padding: 4px 9px;
}

.l8-lay-controls {
    position: absolute;
    z-index: 5;
    bottom: calc(100% + var(--l8-card-width) * var(--l8-card-height-factor) + 14px);
    left: 50%;
    transform: translate(-50%, -100%);
}

.l8-lay-controls .l8-primary {
    width: auto;
    padding: 7px 12px;
    white-space: nowrap;
}

.l8-action-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 7px;
}

.l8-action-bar .l8-primary, .l8-action-bar .l8-secondary {
    width: auto;
    padding: 8px 12px;
}

.l8-action-bar small {
    color: var(--l8-muted);
}

.l8-card {
    position: relative;
}

.l8-card.selected {
    transform: translateY(-15px);
    border-radius: 5px;
}

.l8-card.group-1 {
    box-shadow: 0 0 0 4px #f2d15f;
}

.l8-card.group-2 {
    box-shadow: 0 0 0 4px #56a8ef;
}

.l8-skip-mark {
    color: var(--l8-yellow);
    font-size: .72rem;
}

.l8-score-table p {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin: 5px 0;
}

.l8-score-table span {
    color: var(--l8-muted);
}

.l8-result-card > .l8-primary[href] {
    display: inline-block;
    margin-top: 10px;
    text-decoration: none;
}

@media (max-width: 699px) {
    .l8-board {
        grid-template-rows: auto minmax(185px, 1fr) auto;
    }

    .l8-laid-phases section {
        align-items: flex-start;
    }

    .l8-laid-phases section > strong {
        width: 66px;
        flex-basis: 66px;
        font-size: .72rem;
    }

    .l8-group-slot {
        padding: 4px 6px;
        font-size: .67rem;
    }
}

@media (max-width: 620px) {
    .l8-piles {
        gap: 8px;
    }

    .l8-discard-piles {
        gap: 5px;
    }
}

@media (orientation: landscape) and (max-height: 620px) {
    .l8-discard-piles {
        gap: 5px;
    }
}

@media (max-height: 899px) {
    .l8-game-active .l8-header {
        min-height: 0;
        height: 0;
        padding: 0;
        border: 0;
        background: transparent;
        backdrop-filter: none;
    }

    .l8-game-active .l8-header .l8-brand {
        display: none;
    }

    .l8-game-active .l8-header .l8-back,
    .l8-game-active .l8-header .l8-info {
        position: absolute;
        z-index: 200;
        top: max(8px, env(safe-area-inset-top, 0px));
    }

    .l8-game-active .l8-header .l8-back {
        left: max(8px, env(safe-area-inset-left, 0px));
        width: 29px;
        height: 29px;
        justify-content: center;
        border: 1px solid #c5d9c8;
        border-radius: 50%;
        background: #050505d9;
    }

    .l8-game-active .l8-header .l8-back span {
        display: none;
    }

    .l8-game-active .l8-header .l8-back svg {
        width: 20px;
        height: 20px;
        margin-left: -2px;
    }

    .l8-game-active .l8-header .l8-info {
        right: max(8px, env(safe-area-inset-right, 0px));
    }

    .l8-game-active #level8-app {
        height: 100vh;
        height: 100dvh;
    }
}

/* Sechs feste Ebenen: gegnerische Hand/Phase, Stapel, eigene Phase, Header und Hand. */
.l8-board {
    grid-template-rows:
        minmax(calc(var(--l8-card-width) * var(--l8-card-height-factor) * 2 + 34px), auto)
        minmax(max-content, 1fr)
        minmax(calc(var(--l8-card-width) * var(--l8-card-height-factor)), auto)
        minmax(28px, auto)
        calc(var(--l8-card-width) * var(--l8-card-height-factor) + 24px);
}

.l8-own-area {
    min-height: calc(var(--l8-card-width) * var(--l8-card-height-factor) + 24px);
}

/* Nur Reihen, die den sichtbaren Bereich überschreiten, werden enger gelegt. */
.l8-own-hand.l8-fit-compact .l8-card + .l8-card,
.l8-opponent-hand.l8-fit-compact img + img,
.l8-fit-compact .l8-player-phase-card + .l8-player-phase-card,
.l8-fit-compact .l8-player-phase-card img + img,
.l8-fit-compact .l8-group-cards img + img {
    margin-left: clamp(-67px, -7vw, -39px);
}

.l8-group-cards.l8-fit-compact .l8-phase-card + .l8-phase-card,
.l8-fit-compact .l8-group-cards .l8-phase-card + .l8-phase-card {
    margin-left: max(calc(var(--l8-phase-card-min-visible) - var(--l8-card-width)), clamp(-67px, -7vw, -39px));
}

.l8-own-hand.l8-fit-tight .l8-card + .l8-card,
.l8-opponent-hand.l8-fit-tight img + img,
.l8-fit-tight .l8-player-phase-card + .l8-player-phase-card,
.l8-fit-tight .l8-player-phase-card img + img,
.l8-fit-tight .l8-group-cards img + img {
    margin-left: clamp(-78px, -9vw, -48px);
}

.l8-group-cards.l8-fit-tight .l8-phase-card + .l8-phase-card,
.l8-fit-tight .l8-group-cards .l8-phase-card + .l8-phase-card {
    margin-left: max(calc(var(--l8-phase-card-min-visible) - var(--l8-card-width)), clamp(-78px, -9vw, -48px));
}

.l8-player-phase.l8-fit-compact {
    gap: 3px;
}

.l8-player-phase.l8-fit-tight {
    gap: 0;
}

/* Reicht selbst die engste Kartenstaffelung nicht, werden ganze ausgelegte
   Gruppen versetzt gestapelt. Die geringere Kartenbreite lässt den nötigen
   Platz für die angehobenen Gruppen innerhalb der Phasenfläche. */
.l8-player-phase.l8-fit-groups {
    --l8-laid-card-width: var(--l8-card-width);
    gap: 0;
    align-items: flex-end;
    padding-top: calc(var(--l8-laid-card-width) * .16);
}

.l8-player-phase.l8-fit-groups .l8-player-phase-group {
    position: relative;
    z-index: var(--l8-phase-group-index);
}

.l8-player-phase.l8-fit-groups .l8-player-phase-group + .l8-player-phase-group {
    margin-left: calc(var(--l8-laid-card-width) * -.46);
}

.l8-player-phase.l8-fit-groups .l8-player-phase-group:nth-child(even) {
    transform: translateY(calc(var(--l8-laid-card-width) * -.16));
}

.l8-player-phase.l8-fit-groups .l8-player-phase-group img {
    width: var(--l8-laid-card-width);
}

.l8-board .l8-opponents .l8-player-phase.l8-fit-groups .l8-player-phase-group img {
    width: var(--l8-laid-card-width);
}

.l8-board.l8-fit-groups-active {
    --l8-card-width: calc(var(--l8-card-width-base) * .9);
}

/* Die Zwei-Spieler-Ansicht nutzt größere verdeckte Karten und braucht daher
   eine ebenso spezifische Überschreibung für die dynamische Verdichtung. */
.l8-opponents.two-player .l8-opponent-hand.l8-fit-compact img + img {
    margin-left: clamp(-67px, -7vw, -39px);
}

.l8-opponents.two-player .l8-opponent-hand.l8-fit-tight img + img {
    margin-left: clamp(-78px, -9vw, -48px);
}

@media (max-width: 620px) {
    .l8-board {
        grid-template-rows:
            minmax(79px, auto)
            minmax(max-content, 1fr)
            minmax(calc(var(--l8-card-width) * var(--l8-card-height-factor)), auto)
            minmax(28px, auto)
            calc(var(--l8-card-width) * var(--l8-card-height-factor) + 24px);
    }
}

@media (orientation: landscape) and (max-height: 620px) {
    .l8-board {
        grid-template-rows:
            minmax(66px, auto)
            minmax(max-content, 1fr)
            minmax(calc(var(--l8-card-width) * var(--l8-card-height-factor)), auto)
            minmax(28px, auto)
            calc(var(--l8-card-width) * var(--l8-card-height-factor) + 24px);
    }
}

.l8-sound, .l8-fullscreen, .l8-reaction-toggle {
    position: fixed;
    z-index: 190;
    bottom: max(3px, env(safe-area-inset-bottom, 0px));
    width: 38px;
    height: 38px;
    padding: 9px;
    border: 0;
    color: var(--l8-muted);
    background: transparent;
}

.l8-reaction-toggle svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.l8-fullscreen {
    right: max(3px, env(safe-area-inset-right, 0px));
}

.l8-sound {
    right: max(44px, calc(env(safe-area-inset-right, 0px) + 44px));
}

.l8-reaction-toggle {
    right: max(85px, calc(env(safe-area-inset-right, 0px) + 85px));
    font-size: 1rem;
}

.l8-sound.active, .l8-fullscreen.active, .l8-reaction-toggle.active {
    color: var(--l8-yellow);
}

.l8-reaction-panel {
    position: fixed;
    z-index: 201;
    right: max(85px, calc(env(safe-area-inset-right, 0px) + 85px));
    bottom: max(46px, calc(env(safe-area-inset-bottom, 0px) + 46px));
    display: flex;
    width: min(390px, calc(100vw - 20px));
    flex-direction: column;
    gap: 9px;
    padding: 10px;
    border: 1px solid #ffffff35;
    border-radius: 12px;
    background: #10271ff5;
    box-shadow: 0 10px 30px #0008;
}

.l8-reaction-panel header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.l8-reaction-panel header button {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.2rem;
}

.l8-chat-history {
    display: flex;
    min-height: 72px;
    max-height: min(34dvh, 240px);
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
}

.l8-chat-message {
    align-self: flex-start;
    max-width: 82%;
    padding: 5px 8px;
    border-radius: 11px 11px 11px 3px;
    color: #122219;
    background: #eef5ea;
    overflow-wrap: anywhere;
}

.l8-chat-message.yours {
    align-self: flex-end;
    border-radius: 11px 11px 3px 11px;
    background: var(--l8-yellow);
}

.l8-chat-message small {
    display: block;
    opacity: .7;
    font-size: .66rem;
    font-weight: 700;
}

.l8-chat-message p, .l8-chat-empty {
    margin: 0;
    white-space: pre-wrap;
}

.l8-chat-empty {
    margin: auto;
    color: var(--l8-muted);
}

.l8-reaction-emojis {
    display: grid;
    grid-template-columns:repeat(7, 1fr);
    gap: 5px;
}

.l8-reaction-panel form {
    display: flex;
    gap: 6px;
}

.l8-reaction-panel input {
    min-width: 0;
    flex: 1;
    padding: 8px;
    border: 1px solid #ffffff45;
    border-radius: 7px;
}

.l8-reaction-panel form button, .l8-reaction-emojis button {
    min-height: 35px;
    border: 0;
    border-radius: 7px;
    background: #ffffff18;
    color: #fff;
}

.l8-reaction-panel form button {
    padding: 0 10px;
    background: var(--l8-green-light);
}

@media (max-width: 699px) {
    .l8-reaction-panel {
        right: 0;
        bottom: max(42px, calc(env(safe-area-inset-bottom, 0px) + 42px));
        left: 0;
        width: 100%;
        max-width: none;
        padding: 11px max(10px, env(safe-area-inset-right, 0px)) 11px max(10px, env(safe-area-inset-left, 0px));
        border-right: 0;
        border-left: 0;
        border-radius: 12px 12px 0 0;
    }
}

.l8-board > .l8-own-area:has(.l8-special-actions),
.l8-board > .l8-own-area:has(.l8-take-three-marker) {
    z-index: 6;
}

.l8-special-actions {
    position: absolute;
    z-index: 100;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 440px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
}

.l8-special-actions span, .l8-special-actions button, .l8-special-wait {
    padding: .6rem .8rem;
    border: 1px solid #f6d568;
    border-radius: 8px;
    background: #173a29;
    color: #fff;
    font-weight: 700;
}

.l8-special-actions button, .l8-special-wait button {
    min-height: 44px;
    cursor: pointer;
}

.l8-special-actions button:disabled {
    opacity: .6;
    cursor: default;
}

.l8-special-actions button:focus-visible, .l8-offer-hand:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.l8-special-wait {
    position: absolute;
    z-index: 20;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.l8-personal-discard:has(.l8-special-wait) {
    z-index: 5;
}

.l8-personal-discard .l8-special-wait {
    top: 50%;
    width: max-content;
    max-width: min(280px, 85vw);
}

.l8-exchange-confirm {
    min-height: 44px;
}

.l8-offer-confirm:disabled {
    opacity: .5;
}

.l8-special-wait [data-decline-offer] {
    display: block;
    margin: .5rem auto 0;
    padding: 3px 10px;
    color: #f6d568;
    background: transparent;
    border: 1px solid white;
    border-radius: 8px;
}

.l8-bonus-marker {
    width: 20px;
    height: 18px;
    object-fit: contain;
    flex: 0 0 auto;
}

.l8-bonus-marker.is-inactive {
    opacity: 0.5;
}

.l8-opponent-hand-wrap {
    position: relative;
}

.l8-opponent-hand-wrap:has(.l8-offer-hand-row) {
    z-index: 10;
}

.l8-offer-hand-row {
    position: absolute;
    z-index: 2;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 4px;
}

.l8-offer-hand {
    flex: 0 0 var(--l8-card-width);
    width: var(--l8-card-width);
    min-width: var(--l8-card-width);
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.l8-offer-hand:disabled {
    opacity: 1;
    cursor: default;
}

.l8-offer-hand > img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 224 / 344;
}

/* Hände und ausgelegte Phasen belegen getrennte Zeilen; keine Phase wird
   durch den horizontal scrollbar gehaltenen Handbereich abgeschnitten. */
.l8-board,
.l8-board.l8-fit-groups-active {
    --l8-card-width: min(var(--l8-card-width-base), var(--l8-height-fit-width, 100vw), max(38px, (100dvh - var(--l8-header-height) - 145px) / 8));
    height: auto;
    min-height: 100%;
    grid-template-rows: auto auto minmax(max-content, 1fr) auto auto auto;
}

.l8-opponents {
    overflow-y: hidden;
}

.l8-board > .l8-opponents:has(.l8-offer-hand-row) {
    z-index: 3;
    overflow: visible;
}

.l8-opponent {
    min-height: 0;
}

.l8-opponent-phases {
    display: grid;
    grid-template-columns: repeat(var(--l8-opponent-count), minmax(0, 1fr));
    align-items: end;
    min-width: 0;
    overflow: visible;
}

.l8-opponent-phase-slot {
    position: relative;
    min-width: 0;
}

.l8-opponent-phase-slot .l8-skip-card {
    top: 0;
}

.l8-opponent-phase {
    margin-top: 0;
}

.l8-opponent-phase.l8-fit-groups {
    padding-top: calc(var(--l8-card-width) * .16 + 2px);
}
