:root {
    --p10-header-height: 62px;
    --p10-ink: #fff8dd;
    --p10-muted: #b9c8b8;
    --p10-dark: #10251b;
    --p10-green: #1d4d35;
    --p10-green-light: #387352;
    --p10-yellow: #f2d15f;
    --p10-red: #ba3e37;
    --p10-card-width-base: clamp(54px, calc((100dvh - 190px) * .13), 96px);
    --p10-card-width: var(--p10-card-width-base);
    --p10-card-height-factor: 1.536;
    --p10-phase-card-min-visible: 30px;
}

body[data-phase10-room] {
    --game-ui-accent: var(--p10-yellow);
    --game-ui-panel: #142c50f2;
    --game-ui-primary-background: var(--p10-yellow);
    --game-ui-primary-color: #172033;
}

@property --p10-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 90% 80% at 0% 0%, #585dee30, transparent 72%), radial-gradient(ellipse 90% 80% at 100% 0%, #fa262030, transparent 72%), radial-gradient(ellipse 90% 80% at 0% 100%, #fbd70d2b, transparent 72%), radial-gradient(ellipse 90% 80% at 100% 100%, #02b8492b, transparent 72%), #050505;
    color: var(--p10-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;
}

.p10-header {
    position: relative;
    z-index: 100;
    min-height: calc(var(--p10-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: #050505e8;
    backdrop-filter: blur(10px);
}

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

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

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

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

.p10-brand img {
    display: block;
    width: auto;
    height: 48px;
    object-fit: contain;
}

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

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

.p10-panel {
    width: min(440px, calc(100% - 28px));
    margin: clamp(28px, 8vh, 80px) auto 24px;
    padding: clamp(20px, 5vw, 32px);
    border: 1px solid #ffffff21;
    border-radius: 22px;
    background: linear-gradient(145deg, #1b1b1beb, #050505f2);
    text-align: center;
    box-shadow: 0 24px 60px #07130d99;
}

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

.p10-placeholder-logo img {
    width: min(220px, 72%);
    max-height: 225px;
    object-fit: contain;
    filter: drop-shadow(0 10px 18px #000a);
}

.p10-placeholder-logo strong {
    margin-left: -8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--p10-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;
}

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

.p10-panel p {
    color: var(--p10-muted);
}

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

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

.p10-form label {
    color: var(--p10-muted);
    font-size: .8rem;
}

.p10-form input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #7fa18a;
    border-radius: 10px;
    outline: none;
    background: #f7f0d9;
    color: #17251b;
    font-size: 1rem;
}

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

.p10-player-setup {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 11px;
    border: 1px solid #7fa18a;
    border-radius: 10px;
    background: #173a29;
}

.p10-player-setup legend {
    padding: 0 4px;
    color: var(--p10-muted);
    font-size: .8rem;
}

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

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

.p10-add-player {
    justify-self: start;
    padding: 7px 10px;
    border: 1px solid #f9e89a;
    border-radius: 8px;
    background: transparent;
    color: var(--p10-ink);
    font-weight: 700;
}

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

.p10-share input,
.p10-player-controls label {
    flex: 1;
}

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

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

.p10-player-share-info {
    min-width: 0;
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 11px;
    border: 1px solid #7fa18a;
    border-radius: 10px;
    background: #173a29;
}

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

.p10-player-share-info strong,
.p10-player-share-info small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p10-player-share-info small {
    color: var(--p10-muted);
    font-size: .72rem;
}

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

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

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

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

.p10-primary {
    border: 1px solid #f9e89a;
    background: var(--p10-yellow);
    color: #24331f;
    font-weight: 800;
}

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

.p10-secondary {
    width: 100%;
    margin-top: 10px;
    border: 1px solid #75967f;
    background: #234c36;
    color: var(--p10-ink);
}

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

.p10-link-button {
    border: 0;
    background: transparent;
    color: var(--p10-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

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

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

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

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

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

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

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

.p10-recent-session strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

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

.p10-recent-players button {
    padding: 5px 9px;
    border: 1px solid #769781;
    border-radius: 7px;
    background: #244b37;
    color: var(--p10-ink);
    font-size: .75rem;
}

.p10-delete-session {
    width: 34px;
    height: 34px;
    padding: 7px;
    border: 0;
    background: transparent;
    color: #d9b0a8;
}

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

.p10-board {
    height: 100%;
    min-height: calc(var(--p10-card-width) * var(--p10-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(--p10-card-width) * var(--p10-card-height-factor) * 2 + 34px) minmax(calc(var(--p10-card-width) * var(--p10-card-height-factor)), 1fr) calc(var(--p10-card-width) * var(--p10-card-height-factor) * 2 + 42px);
    gap: 5px;
    position: relative;
    isolation: isolate;
}

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

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

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

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

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

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

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

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

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

.p10-opponents {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(6px, 2vw, 18px);
}

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

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

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

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

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

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

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

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

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

.p10-opponent header span {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    font-weight: 700;
}

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

.p10-opponent-hand {
    height: 55px;
    margin-top: 3px;
    display: flex;
    justify-content: center;
}

.p10-opponent-hand img {
    width: 38px;
    height: 55px;
    margin-left: -25px;
    border-radius: 8.4%;
}

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

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

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

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

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

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

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

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

.p10-piles {
    display: flex;
    align-items: center;
    gap: clamp(22px, 8vw, 56px);
}

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

.p10-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 224 / 344;
    display: block;
    border-radius: 8.4%;
    object-fit: cover;
}

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

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

.p10-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;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.p10-empty-card {
    width: 100%;
    aspect-ratio: 224 / 344;
    display: grid;
    place-items: center;
    border: 1px solid #ffffff26;
    border-radius: 8.4%;
    background: transparent;
}

.p10-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;
}

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

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

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

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

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

.p10-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: p10-call-confirmation .2s ease-out both;
}

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

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

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

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

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

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

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

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

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

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

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

.p10-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;
}

.p10-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);
}

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

.p10-master-switch input:checked + .p10-master-switch-control::after { transform: translateX(18px); }
.p10-master-switch input:focus-visible + .p10-master-switch-control { outline: 2px solid #fff; outline-offset: 3px; }

.p10-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;
}

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

.p10-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(--p10-ink);
    font-size: .69rem;
    font-weight: 800;
    line-height: 1;
}

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

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

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

.p10-hand-sorts i:nth-child(2) {
    background: #03b94b;
}

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

.p10-hand-sorts i:nth-child(4) {
    background: #585eed;
}

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

.p10-player-name {
    max-width: 180px;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
    color: var(--p10-ink);
    font-size: .9rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p10-opponent-name::before,
.p10-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;
}

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

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

.p10-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;
}

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

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

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

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

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

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

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

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

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

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

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

.p10-announcement {
    position: fixed;
    z-index: 900;
    top: 45%;
    left: 50%;
    padding: 13px 22px;
    border: 2px solid #fff2af;
    border-radius: 14px;
    background: var(--p10-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: p10-pop .3s ease-out both;
}

.p10-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;
}

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

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

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

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

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

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

.p10-dialog,
.p10-result-card,
.p10-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;
}

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

.p10-result-overlay {
    inset: calc(var(--p10-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;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.p10-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%);
}

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

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

.p10-reaction-picker,
.p10-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;
}

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

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

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

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

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

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

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

#phase-10-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;
}

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

.p10-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(--p10-muted);
}

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

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

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

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

@keyframes p10-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 p10-call-confirmation {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px) scale(.9);
    }
    to {
        opacity: 1;
        transform: translateX(-50%);
    }
}

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

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

    .p10-back span {
        display: none;
    }

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

    .p10-opponents {
        gap: 1px;
    }

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

    .p10-opponent header span {
        max-width: 72px;
        font-size: .68rem;
    }

    .p10-opponent-hand img {
        width: 31px;
        height: 44px;
        margin-left: -23px;
    }

    .p10-piles {
        gap: 30px;
    }

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

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

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

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

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

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

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

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

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

    .p10-opponent-hand {
        height: 38px;
    }

    .p10-opponent-hand img {
        width: 28px;
        height: 40px;
        margin-left: -21px;
    }

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

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

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

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

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

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

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

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

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

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

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

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

    .p10-suit-overlay .p10-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;
    }
}

/* Phase 10 additions */
.p10-board {
    grid-template-rows: minmax(92px, auto) minmax(210px, 1fr) auto;
}

.p10-table {
    grid-template-rows: auto;
    align-content: center;
    overflow: visible;
    padding-top: 0;
}

.p10-table .p10-piles {
    grid-row: 1;
}

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

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

.p10-laid-phases section > strong {
    width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

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

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

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

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

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

.p10-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;
}

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

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

.p10-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(--p10-ink);
    width: 100%;
    height: 100%;
    min-width: 0;
    align-items: center;
}

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

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

.p10-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(--p10-ink);
    font-size: 1.1rem;
    line-height: 1;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.p10-card {
    position: relative;
}

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

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

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

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

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

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

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

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

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

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

    .p10-laid-group img {
        width: 29px;
    }

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

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

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

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

    .p10-game-active .p10-header .p10-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;
    }

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

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

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

    .p10-game-active #phase-10-app {
        height: 100vh;
        height: 100dvh;
    }
}

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

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

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

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

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

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

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

.p10-player-phase.p10-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. */
.p10-player-phase.p10-fit-groups {
    --p10-laid-card-width: var(--p10-card-width);
    gap: 0;
    align-items: flex-end;
    padding-top: calc(var(--p10-laid-card-width) * .16);
}

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

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

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

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

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

.p10-board.p10-fit-groups-active {
    --p10-card-width: calc(var(--p10-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. */
.p10-opponents.two-player .p10-opponent-hand.p10-fit-compact img + img {
    margin-left: clamp(-67px, -7vw, -39px);
}

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

@media (max-width: 620px) {
    .p10-opponents.three-player .p10-opponent-phase .p10-player-phase-group img {
        width: clamp(34px, 11vw, 54px);
    }

    .p10-board {
        grid-template-rows:
            minmax(79px, auto)
            minmax(155px, 1fr)
            minmax(calc(var(--p10-card-width) * var(--p10-card-height-factor)), auto)
            minmax(28px, auto)
            calc(var(--p10-card-width) * var(--p10-card-height-factor) + 24px);
    }
}

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

.p10-sound, .p10-fullscreen, .p10-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(--p10-muted);
    background: transparent;
}

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

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

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

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

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

.p10-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;
}

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

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

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

.p10-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;
}

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

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

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

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

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

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

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

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

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

@media (max-width: 699px) {
    .p10-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;
    }
}

.p10-special-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; max-height: 55dvh; overflow: auto; }
.p10-special-choices button { border: 0; background: transparent; padding: .25rem; cursor: pointer; }
.p10-special-choices img { display: block; width: clamp(60px, 13vw, 100px); height: auto; }
/* Die Kartenhand und der Phasen-Builder bilden eigene Ebenen. Nur während
   eine Sonderaktion sichtbar ist, muss ihre gesamte Ebene über dem Builder liegen. */
.p10-board > .p10-own-area:has(.p10-special-actions) {
    z-index: 5;
}

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

.p10-special-actions button {
    min-height: 44px;
    max-width: 100%;
    padding: .5rem .8rem;
    border: 1px solid #f6d568;
    border-radius: 8px;
    background: #173a29;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.p10-special-actions button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}
.p10-special-wait { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: #222; border-radius: .6rem; padding: .7rem 1rem; z-index: 5; }
.p10-effect-marker { width: 18px; height: 18px; flex: 0 0 18px; object-fit: contain; vertical-align: middle; }

.p10-offer-actions span {
    padding: .5rem .7rem;
    border-radius: 8px;
    background: #173a29;
    color: #fff;
    font-weight: 700;
}
.p10-offer-actions button:disabled { opacity: .6; cursor: default; }

/* Angebote liegen vor der unveränderten verdeckten Hand. */
.p10-opponent-hand-wrap { position: relative; }
.p10-opponent-hand-wrap:has(.p10-offer-hand-row) { z-index: 10; }
.p10-offer-hand-row {
    position: absolute;
    z-index: 2;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 4px;
}
.p10-offer-hand {
    flex: 0 0 clamp(38px, 12vw, var(--p10-card-width));
    width: clamp(38px, 12vw, var(--p10-card-width));
    min-width: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.p10-offer-hand:disabled { opacity: 1; cursor: default; }
.p10-offer-hand > img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    aspect-ratio: 224 / 344;
}
.p10-offer-hand:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.p10-offer-reveal img { animation: p10-offer-reveal .4s ease-out; }
@keyframes p10-offer-reveal { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }
@media (prefers-reduced-motion: reduce) { .p10-offer-reveal img { animation: none; } }

/* Sprechblasen müssen die Ebenen der Hände und ausgelegten Phasen überragen. */
.p10-board > .p10-opponents:has(.p10-reaction-bubble),
.p10-board > .p10-own-header:has(.p10-reaction-bubble) { z-index: 100; }
.p10-opponent header .p10-reaction-bubble {
    max-width: min(280px, calc(100vw - 30px));
    overflow: visible;
    white-space: normal;
}
.p10-special-wait { pointer-events: none; }

.p10-piles { position: relative; }
.p10-board > .p10-table:has(.p10-draw-selection) { z-index: 8; }
.p10-draw-selection {
    position: absolute;
    z-index: 20;
    width: max-content;
    max-width: calc(100vw - 8px);
    text-align: center;
}
.p10-draw-selection > span {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: #173a29;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}
.p10-draw-selection-cards { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.p10-draw-selection-card {
    width: clamp(44px, 16vw, 96px);
    min-width: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.p10-draw-selection-card:disabled { opacity: 1; cursor: default; }
.p10-draw-selection-card img { display: block; width: 100%; height: auto; aspect-ratio: 224 / 344; border-radius: 8.4%; }
.p10-draw-selection-card:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
