:root {
    --bg: #0f1115;
    --panel: #191d24;
    --panel-2: #202630;
    --line: rgba(255, 255, 255, 0.11);
    --text: #f7f8fb;
    --muted: #aeb7c4;
    --red: #e63e32;
    --yellow: #f4c430;
    --green: #2ead5f;
    --blue: #2276d2;
    --wild: #111318;
    --danger: #d74747;
    --focus: #f4c430;
    --font: "Nunito", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
}

body.mode-game {
    height: 100dvh;
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
    padding: 10px 20px;
    background: rgba(15, 17, 21, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand-lockup,
.user-pill,
.top-actions {
    display: flex;
    align-items: center;
    min-width: 0;
}

.brand-lockup {
    gap: 12px;
}

.brand-lockup img {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    object-fit: cover;
}

.brand-lockup strong,
.brand-lockup span {
    display: block;
    white-space: nowrap;
}

.brand-lockup strong {
    font-size: 1.08rem;
    font-weight: 900;
}

.brand-lockup span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.top-actions {
    gap: 10px;
}

.user-pill {
    gap: 9px;
    max-width: 270px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.user-pill img,
.user-card img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-pill span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 900;
}

.user-pill small,
.user-card small {
    margin-left: 6px;
    color: var(--muted);
    font-size: 0.72em;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button {
    min-height: 42px;
    border-radius: 8px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 10px 14px;
    color: var(--text);
    font-weight: 900;
    text-decoration: none;
}

.icon-button {
    width: 42px;
    padding: 0;
    background: var(--panel);
    border-color: var(--line);
}

.primary-button {
    background: var(--yellow);
    color: #171406;
    border-color: rgba(0, 0, 0, 0.2);
}

.secondary-button {
    background: var(--panel-2);
    border-color: var(--line);
}

.danger-button {
    background: rgba(215, 71, 71, 0.18);
    border-color: rgba(215, 71, 71, 0.38);
    color: #ffb7b7;
}

.danger-button.is-idle {
    background: var(--panel-2);
    border-color: var(--line);
    color: var(--muted);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.icon-button:hover {
    filter: brightness(1.08);
}

.app-view {
    display: none;
}

.app-view.is-active {
    display: block;
}

.menu-view {
    min-height: calc(100dvh - 68px);
    padding: 28px;
    background:
        linear-gradient(135deg, rgba(230, 62, 50, 0.09), transparent 28%),
        linear-gradient(225deg, rgba(34, 118, 210, 0.11), transparent 32%);
}

.menu-panel {
    width: min(100%, 560px);
    margin: 0 auto;
    display: grid;
    gap: 16px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background:
        linear-gradient(90deg, rgba(230, 62, 50, 0.08), rgba(244, 196, 48, 0.08), rgba(46, 173, 95, 0.08), rgba(34, 118, 210, 0.08)),
        var(--panel);
    box-shadow: 0 22px 46px rgba(0, 0, 0, 0.26);
}

.menu-logo {
    width: min(100%, 210px);
    aspect-ratio: 1;
    justify-self: center;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.26);
}

.menu-copy {
    text-align: center;
}

.menu-copy h1,
.landing-copy h1 {
    margin: 0;
    font-size: clamp(2.2rem, 6vw, 4.8rem);
    line-height: 0.95;
    font-weight: 900;
}

.menu-copy p,
.landing-copy p {
    color: var(--muted);
    font-weight: 800;
    line-height: 1.45;
}

.join-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #11151b;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    font-weight: 900;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--focus);
}

#lobbyCode {
    text-transform: uppercase;
    letter-spacing: 0;
}

.lobby-view {
    padding: 22px;
}

.lobby-code-card {
    width: min(100%, 520px);
    margin: 0 auto 22px;
    position: relative;
}

.lobby-code-card button {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    padding: 16px;
}

.lobby-code-card span,
.lobby-code-card small {
    display: block;
    color: var(--muted);
    font-weight: 900;
}

.lobby-code-card strong {
    display: block;
    margin: 2px 0;
    color: var(--yellow);
    font-size: clamp(2rem, 7vw, 3.4rem);
    letter-spacing: 5px;
}

#copy-feedback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(46, 173, 95, 0.96);
    color: white;
    font-weight: 900;
}

#copy-feedback.is-visible {
    display: flex;
}

.lobby-grid {
    width: min(100%, 1320px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(260px, 0.88fr) minmax(360px, 1.35fr);
    gap: 18px;
    align-items: start;
}

.panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.players-panel,
.settings-panel,
.game-players-panel,
.chat-panel {
    padding: 16px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-heading h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1.15rem;
}

.count-pill,
.host-badge {
    flex: 0 0 auto;
    border-radius: 8px;
    padding: 5px 9px;
    background: #11151b;
    color: var(--muted);
    font-weight: 900;
    font-size: 0.85rem;
}

.players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
}

.player-tile {
    position: relative;
    min-width: 0;
    min-height: 116px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 7px;
    padding: 12px 8px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid transparent;
}

.player-tile.is-host {
    border-color: rgba(244, 196, 48, 0.45);
}

.player-tile img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
}

.player-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 900;
    font-size: 0.9rem;
}

.player-meta {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
}

.kick-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(215, 71, 71, 0.35);
    border-radius: 8px;
    background: rgba(215, 71, 71, 0.18);
    color: #ffd1d1;
}

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

.setting-row {
    display: grid;
    gap: 6px;
}

.setting-row label,
.setting-block legend {
    color: var(--muted);
    font-weight: 900;
    font-size: 0.82rem;
}

.setting-row label,
.toggle-grid label {
    min-width: 0;
}

.setting-info {
    width: 22px;
    height: 22px;
    min-height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #11151b;
    color: var(--yellow);
    font-size: 0.72rem;
    vertical-align: middle;
}

.setting-block {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 9px;
}

.setting-block legend {
    padding: 0 6px;
}

.color-check,
.toggle-grid label {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    background: #11151b;
    font-weight: 900;
}

.color-check input,
.toggle-grid input {
    width: 18px;
    height: 18px;
    accent-color: var(--yellow);
}

.color-red { border-left: 5px solid var(--red); }
.color-yellow { border-left: 5px solid var(--yellow); }
.color-green { border-left: 5px solid var(--green); }
.color-blue { border-left: 5px solid var(--blue); }

.toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-summary {
    display: none;
    color: var(--muted);
    line-height: 1.45;
    font-weight: 800;
}

.settings-summary.is-visible {
    display: grid;
    gap: 7px;
}

.settings-summary div {
    padding: 9px 10px;
    border-radius: 8px;
    background: #11151b;
}

.lobby-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.game-view {
    height: calc(100dvh - 68px);
    min-height: 0;
    padding: 14px;
    overflow: hidden;
}

.game-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 330px;
    gap: 14px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.table-panel {
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(260px, 1fr) auto auto;
    gap: 14px;
    overflow: hidden;
}

.turn-status {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    font-weight: 900;
}

.table-center {
    min-height: 300px;
    display: grid;
    grid-template-columns: minmax(92px, 132px) minmax(140px, 240px) minmax(110px, 160px);
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(230, 62, 50, 0.15), rgba(244, 196, 48, 0.13), rgba(46, 173, 95, 0.14), rgba(34, 118, 210, 0.15)),
        var(--panel);
    padding: 20px;
}

.deck-pile {
    aspect-ratio: 0.68;
    border-radius: 8px;
    border: 5px solid #f4f7fb;
    background: repeating-linear-gradient(135deg, #151a22 0 12px, #242b36 12px 24px);
    color: white;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.deck-pile span {
    font-size: 2.4rem;
    font-weight: 900;
}

.deck-pile small,
.discard-meta small {
    color: var(--muted);
    font-weight: 900;
}

.card-preview,
.play-card {
    aspect-ratio: 0.68;
    border-radius: 8px;
    border: 5px solid #f4f7fb;
    color: white;
    display: grid;
    grid-template-rows: minmax(18px, auto) minmax(0, 1fr) minmax(18px, auto);
    place-items: center;
    gap: 8px;
    padding: 11px;
    text-align: center;
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.26);
    overflow: hidden;
    min-width: 0;
    position: relative;
    isolation: isolate;
}

.card-preview::before,
.play-card::before {
    content: "";
    position: absolute;
    inset: 17% 12%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
    transform: rotate(-16deg);
    z-index: 0;
}

.card-preview {
    width: min(100%, 220px);
    min-height: 240px;
    justify-self: center;
}

.play-card {
    flex: 0 0 clamp(82px, 10vw, 132px);
    width: clamp(82px, 10vw, 132px);
    min-height: 122px;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.play-card.is-playable:hover,
.play-card.is-playable:focus {
    transform: translateY(-10px);
    outline: 3px solid rgba(244, 196, 48, 0.55);
}

.play-card:not(.is-playable) {
    opacity: 0.58;
}

.card-red { background: var(--red); }
.card-yellow { background: #d7a900; color: #191100; }
.card-green { background: var(--green); }
.card-blue { background: var(--blue); }
.card-wild {
    background:
        conic-gradient(from 45deg, var(--red), var(--yellow), var(--green), var(--blue), var(--red));
    color: white;
}

.card-wild::before {
    background: rgba(17, 19, 24, 0.34);
}

.card-kind {
    width: 100%;
    font-size: clamp(0.7rem, 1.4vw, 0.9rem);
    font-weight: 900;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.38);
    line-height: 1.05;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    max-width: 100%;
    min-width: 0;
}

.card-kind,
.card-value,
.card-symbol {
    position: relative;
    z-index: 1;
}

.card-value {
    font-size: clamp(2.2rem, 7vw, 4.5rem);
    line-height: 0.9;
    font-weight: 900;
    text-shadow: 0 3px 5px rgba(0, 0, 0, 0.34);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.card-symbol {
    width: 100%;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 3.6rem;
    line-height: 1;
    font-weight: 900;
    text-shadow: 0 3px 5px rgba(0, 0, 0, 0.34);
}

.card-symbol-plus {
    flex-direction: column;
    gap: 3px;
}

.card-symbol-plus b {
    font-size: 1.45rem;
    line-height: 1;
}

.play-card .card-value {
    font-size: clamp(1.65rem, 4vw, 3.2rem);
}

.play-card .card-symbol {
    font-size: 2.35rem;
}

.play-card .card-symbol-plus b {
    font-size: 1rem;
}

.card-value-text,
.play-card .card-value-text,
.card-preview .card-value-text {
    font-size: clamp(1.15rem, 2.6vw, 2.25rem);
    line-height: 0.92;
    letter-spacing: 0;
    padding-inline: 2px;
}

.play-card .card-value-text {
    font-size: clamp(0.92rem, 1.8vw, 1.35rem);
}

.card-kind-wild .card-value-text,
.card-kind-wild4 .card-value-text {
    font-size: clamp(1rem, 2.2vw, 1.8rem);
}

.play-card.card-kind-wild .card-value-text,
.play-card.card-kind-wild4 .card-value-text {
    font-size: clamp(0.82rem, 1.35vw, 1.02rem);
}

.play-card .card-kind {
    font-size: clamp(0.58rem, 1.05vw, 0.78rem);
    text-wrap: balance;
}

.discard-meta {
    display: grid;
    justify-items: center;
    gap: 7px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(17, 21, 27, 0.72);
    border: 1px solid var(--line);
}

.color-dot {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid #f4f7fb;
}

.dot-red { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-green { background: var(--green); }
.dot-blue { background: var(--blue); }
.dot-wild { background: conic-gradient(var(--red), var(--yellow), var(--green), var(--blue), var(--red)); }

.action-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.action-bar .danger-button {
    min-width: 148px;
}

.turn-timer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    margin-left: 10px;
    padding: 4px 9px;
    border-radius: 8px;
    background: var(--yellow);
    color: #171406;
    font-weight: 900;
}

.hand {
    min-height: 178px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 14px 8px 20px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.hand.is-action-locked .play-card {
    pointer-events: none;
    cursor: wait;
}

.card-placed {
    animation: cardPlace 0.52s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.deck-draw-anim {
    animation: deckDraw var(--deck-draw-duration, 1050ms) ease-out;
}

.deck-card-ghost {
    position: fixed;
    z-index: 110;
    pointer-events: none;
    border-radius: 8px;
    border: 5px solid #f4f7fb;
    background: repeating-linear-gradient(135deg, #151a22 0 12px, #242b36 12px 24px);
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
    animation: deckCardFly var(--deck-card-duration, 1050ms) ease-out forwards;
}

.hand-draw-anim .play-card:last-child {
    animation: handReceive 0.5s ease-out;
}

.game-player-list {
    display: grid;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
}

.game-player-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid transparent;
}

.game-player-row.is-current {
    border-color: var(--yellow);
}

.game-player-row img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.game-player-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 900;
}

.game-player-stats {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
}

.chat-panel {
    display: grid;
    grid-template-rows: auto minmax(160px, 1fr) minmax(80px, 0.5fr) auto;
    min-height: 0;
    overflow: hidden;
}

.event-log,
.chat-messages {
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 8px;
    border-radius: 8px;
    background: #11151b;
}

.draw-preview {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.18);
}

.draw-preview.is-visible {
    display: flex;
}

.draw-preview-box {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(25, 29, 36, 0.94);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
    animation: drawPreviewPop 0.16s ease-out;
}

.draw-preview-kicker {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 900;
    text-transform: uppercase;
}

.draw-preview .card-preview {
    width: min(210px, 48vw);
    min-height: 250px;
}

.chaos-shout {
    position: fixed;
    inset: 0;
    z-index: 140;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 22% 24%, rgba(230, 62, 50, 0.55), transparent 24%),
        radial-gradient(circle at 78% 22%, rgba(34, 118, 210, 0.58), transparent 24%),
        radial-gradient(circle at 28% 78%, rgba(46, 173, 95, 0.55), transparent 25%),
        radial-gradient(circle at 74% 76%, rgba(244, 196, 48, 0.58), transparent 24%),
        rgba(0, 0, 0, 0.72);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}

.chaos-shout.is-visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.chaos-burst {
    min-width: min(760px, 92vw);
    min-height: min(420px, 58vh);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 6px solid #fff;
    border-radius: 18px;
    background: conic-gradient(from 35deg, var(--red), var(--yellow), var(--green), var(--blue), var(--red));
    color: white;
    text-align: center;
    box-shadow: 0 34px 90px rgba(0, 0, 0, 0.58), inset 0 0 0 10px rgba(0, 0, 0, 0.16);
}

.chaos-burst.is-animating {
    animation: chaosBurst 1.55s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.chaos-burst small,
.chaos-burst span,
.chaos-burst strong {
    display: block;
    text-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
}

.chaos-burst small {
    font-size: clamp(1rem, 2.6vw, 1.8rem);
    font-weight: 900;
    text-transform: uppercase;
}

.chaos-burst span {
    font-size: clamp(3rem, 10vw, 8rem);
    font-weight: 900;
    line-height: 0.88;
}

.chaos-burst strong {
    font-size: clamp(3.5rem, 12vw, 9.5rem);
    line-height: 0.86;
}

@keyframes drawPreviewPop {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chaosBurst {
    0% { opacity: 1; transform: scale(0.72) rotate(-8deg); filter: saturate(1.7); }
    16% { opacity: 1; transform: scale(1.08) rotate(2deg); }
    42% { transform: scale(1) rotate(-1deg); }
    78% { opacity: 1; transform: scale(1.02) rotate(1deg); }
    100% { opacity: 1; transform: scale(1.06) rotate(0deg); filter: saturate(1.2); }
}

@keyframes cardPlace {
    0% { transform: translateY(46px) scale(1.18) rotate(-6deg); opacity: 0.2; }
    58% { transform: translateY(-8px) scale(1.03) rotate(1deg); opacity: 1; }
    100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}

@keyframes deckDraw {
    0% { transform: translateY(0) scale(1); }
    45% { transform: translateY(-12px) scale(1.05) rotate(-2deg); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes deckCardFly {
    0% { opacity: 0.95; transform: translate(0, 0) rotate(0deg) scale(1); }
    55% { opacity: 0.95; transform: translate(42px, -34px) rotate(8deg) scale(0.9); }
    100% { opacity: 0; transform: translate(78px, -58px) rotate(14deg) scale(0.76); }
}

@keyframes handReceive {
    from { transform: translateY(-38px) scale(0.82) rotate(5deg); opacity: 0; }
    to { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}

.event-item,
.chat-msg {
    line-height: 1.35;
    color: #dce2eb;
    font-size: 0.9rem;
    word-break: break-word;
}

.event-item strong,
.chat-msg strong {
    color: var(--yellow);
}

.chat-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    margin-top: 10px;
}

.chat-input button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--blue);
    color: white;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.72);
}

.modal-overlay.is-active {
    display: flex;
}

.modal-box {
    width: min(100%, 430px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 20px;
}

.modal-box h2 {
    margin: 0 0 8px;
}

.modal-box p {
    margin: 0 0 16px;
    color: var(--muted);
    font-weight: 800;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

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

.color-choice {
    min-height: 84px;
    border-radius: 8px;
    border: 4px solid #f4f7fb;
    color: white;
    font-weight: 900;
}

.score-result {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 14px;
    margin: 16px 0;
    padding: 12px;
    border-radius: 8px;
    background: #11151b;
}

.score-result span {
    color: var(--muted);
    font-weight: 900;
}

.score-result strong {
    color: var(--yellow);
    font-size: 1.2rem;
}

.landing-page {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: 28px;
    background:
        linear-gradient(145deg, rgba(230, 62, 50, 0.1), transparent 30%),
        linear-gradient(220deg, rgba(34, 118, 210, 0.12), transparent 34%),
        var(--bg);
}

.landing-shell {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: minmax(280px, 430px) minmax(300px, 420px);
    gap: 24px;
    align-items: center;
}

.landing-hero,
.login-panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    background:
        linear-gradient(90deg, rgba(230, 62, 50, 0.08), rgba(244, 196, 48, 0.08), rgba(46, 173, 95, 0.08), rgba(34, 118, 210, 0.08)),
        var(--panel);
    padding: 24px;
    box-shadow: 0 22px 46px rgba(0, 0, 0, 0.26);
}

.landing-logo {
    width: min(100%, 230px);
    aspect-ratio: 1;
    display: block;
    margin: 0 auto 16px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.26);
}

.login-panel {
    display: grid;
    gap: 14px;
}

.landing-card-fan,
.menu-card-fan {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 6px;
    min-height: 94px;
    margin: 0 auto 10px;
}

.menu-card-fan {
    min-height: 70px;
    margin-top: -6px;
}

.mini-card {
    width: 52px;
    aspect-ratio: 0.68;
    border-radius: 8px;
    border: 3px solid #f4f7fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 900;
    font-size: 1.5rem;
    box-shadow: 0 12px 18px rgba(0, 0, 0, 0.24);
    transform: rotate(var(--tilt, 0deg));
}

.mini-card:nth-child(1) { --tilt: -16deg; }
.mini-card:nth-child(2) { --tilt: -7deg; }
.mini-card:nth-child(3) { --tilt: 0deg; }
.mini-card:nth-child(4) { --tilt: 7deg; }
.mini-card:nth-child(5) { --tilt: 16deg; }

.menu-card-fan .mini-card {
    width: 42px;
    font-size: 1.15rem;
}

.mini-red { background: var(--red); }
.mini-yellow { background: var(--yellow); color: #191100; }
.mini-green { background: var(--green); }
.mini-blue { background: var(--blue); }
.mini-wild {
    background: conic-gradient(from 45deg, var(--red), var(--yellow), var(--green), var(--blue), var(--red));
}

.discord-floating {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 60;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #5865f2;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-decoration: none;
    font-size: 1.65rem;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.32);
}

.discord-floating:hover,
.discord-floating:focus {
    filter: brightness(1.08);
    outline: 3px solid rgba(244, 196, 48, 0.46);
}

.mode-lobby .app-discord,
.mode-game .app-discord {
    display: none;
}

.link-button {
    width: 100%;
}

.guest-form {
    display: grid;
    gap: 10px;
}

.guest-form input {
    text-transform: none;
}

.divider-line {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-weight: 900;
}

.divider-line::before,
.divider-line::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    background: var(--panel-2);
}

.user-card span,
.rules-list p {
    display: block;
    margin: 0;
    color: var(--muted);
    font-weight: 800;
}

.user-card strong {
    display: block;
    font-size: 1.05rem;
}

.rules-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.rules-list h2 {
    margin: 0;
    font-size: 1.1rem;
}

@media (max-width: 1100px) {
    .game-shell {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .chat-panel {
        grid-column: 1 / -1;
        grid-template-rows: auto minmax(90px, 150px) minmax(70px, 120px) auto;
    }
}

@media (max-width: 860px) {
    body.mode-game {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto;
    }

    .top-bar {
        padding: 8px 12px;
    }

    .brand-lockup span,
    .user-pill {
        display: none;
    }

    .menu-view,
    .lobby-view,
    .game-view {
        padding: 12px;
        height: auto;
        min-height: calc(100dvh - 68px);
        overflow: visible;
    }

    .lobby-grid,
    .game-shell,
    .landing-shell {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .settings-form,
    .toggle-grid,
    .lobby-actions {
        grid-template-columns: 1fr;
    }

    .table-center {
        grid-template-columns: 92px minmax(128px, 170px) 92px;
        gap: 10px;
        padding: 12px;
    }

    .card-preview {
        min-height: 190px;
    }

    .hand {
        min-height: 150px;
    }

    .play-card {
        flex: 0 0 86px;
        width: 86px;
        min-height: 126px;
    }

    .play-card .card-symbol {
        font-size: 2.15rem;
    }

    .game-players-panel {
        order: 2;
    }
}

@media (max-width: 520px) {
    .menu-panel,
    .landing-hero,
    .login-panel {
        padding: 16px;
    }

    .join-row {
        grid-template-columns: 1fr;
    }

    .players-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-center {
        grid-template-columns: 78px minmax(112px, 145px) 78px;
        min-height: 240px;
    }

    .deck-pile span {
        font-size: 1.8rem;
    }

    .discard-meta {
        padding: 8px;
    }

    .color-dot {
        width: 32px;
        height: 32px;
    }

    .card-kind {
        font-size: 0.68rem;
    }

    .landing-card-fan {
        min-height: 76px;
    }

    .mini-card {
        width: 42px;
        font-size: 1.15rem;
    }

    .discord-floating {
        width: 46px;
        height: 46px;
        border-radius: 12px;
        font-size: 1.45rem;
    }
}
