:root {
    --bg-top: #152728;
    --bg-bottom: #0b1718;
    --line: rgba(255, 255, 255, 0.1);
    --ink: #f6f5ef;
    --muted: rgba(246, 245, 239, 0.72);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
    background:
        radial-gradient(circle at top, rgba(255, 196, 77, 0.12), transparent 22%),
        radial-gradient(circle at 78% 18%, rgba(90, 182, 255, 0.12), transparent 22%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    color: var(--ink);
    font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
}

.phone-shell {
    min-height: 100vh;
    padding: 1rem 0.9rem 1.4rem;
    display: grid;
    gap: 0.9rem;
    width: 100%;
    max-width: 100%;
}

.hero-card,
.players-card,
.hand-card,
.controls-card {
    border-radius: 1.3rem;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
    box-shadow: 0 1rem 2.3rem rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(14px);
}

.hero-card {
    padding: 1rem;
    display: grid;
    gap: 0.85rem;
}

.hero-header,
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: flex-start;
    min-width: 0;
}

.eyebrow {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.76rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.hero-card h1,
.section-title {
    margin: 0.28rem 0 0;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.hero-card h1 {
    font-size: clamp(2rem, 8vw, 3rem);
    text-transform: uppercase;
}

.section-title {
    font-size: 1.05rem;
}

.pill-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pill {
    padding: 0.48rem 0.78rem;
    border-radius: 999px;
    background: rgba(7, 20, 21, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--ink);
    font-size: 0.88rem;
    text-align: center;
    white-space: nowrap;
}

.status-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.name-field {
    display: grid;
    gap: 0.4rem;
}

.name-field input {
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 0.95rem;
    border-radius: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(4, 9, 10, 0.28);
    color: var(--ink);
    font: inherit;
}

.table-state {
    display: block;
    padding: 0.8rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.05);
}

.players-card,
.hand-card,
.controls-card {
    padding: 0.95rem;
}

.scoreboard {
    margin-top: 0.8rem;
    display: grid;
    gap: 0.55rem;
}

.score-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.7rem;
    align-items: center;
    padding: 0.7rem 0.8rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
}

.score-row.is-current {
    border: 1px solid rgba(255, 196, 77, 0.34);
    background: linear-gradient(180deg, rgba(255, 196, 77, 0.17), rgba(255, 196, 77, 0.06));
}

.score-row.is-turn {
    box-shadow: 0 0 0 1px rgba(90, 182, 255, 0.25);
}

.score-row.is-waiting {
    opacity: 0.7;
}

.score-main {
    min-width: 0;
}

.score-name {
    font-weight: 700;
}

.score-meta {
    margin-top: 0.16rem;
    color: var(--muted);
    font-size: 0.86rem;
}

.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.2rem;
    padding: 0.46rem 0.72rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.22);
    font-weight: 800;
}

.hand-scroller {
    margin-top: 0.95rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(4.75rem, 1fr));
    gap: 0.58rem;
    overflow-x: hidden;
    padding: 0.5rem 0 0.65rem;
    align-items: start;
}

.hand-motion-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 50;
}

.hand-motion-card {
    position: fixed;
    left: 0;
    top: 0;
    aspect-ratio: 1 / 1.45;
    filter: drop-shadow(0 1rem 1.8rem rgba(0, 0, 0, 0.28));
    transform-origin: top left;
    will-change: transform, opacity;
}

.hand-motion-card svg {
    width: 100%;
    height: 100%;
    display: block;
}

.hand-card-button {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1.45;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease;
}

.hand-card-button.is-instant-show {
    transition: none;
}

.hand-card-button svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 0.7rem 1.4rem rgba(0, 0, 0, 0.24));
}

.hand-card-button.is-selected {
    transform: translateY(-0.45rem) scale(1.02);
}

.hand-card-button.is-playable {
    transform: translateY(-0.08rem);
}

.hand-card-button.is-playable svg {
    filter:
        drop-shadow(0 0 0.2rem rgba(255, 226, 148, 0.9))
        drop-shadow(0 0 0.6rem rgba(255, 196, 77, 0.7))
        drop-shadow(0 0.7rem 1.4rem rgba(0, 0, 0, 0.24));
}

.hand-card-button.is-disabled {
    opacity: 0.45;
}

.hand-card-button.is-launching {
    opacity: 0.02;
    pointer-events: none;
}

.hand-card-button.is-pending-arrival {
    opacity: 0;
    pointer-events: none;
}

.hand-card-button.is-arriving {
    pointer-events: none;
}

.hand-card-button.is-drawn::after {
    content: "DRAWN";
    position: absolute;
    left: 0.35rem;
    right: 0.35rem;
    bottom: 0.35rem;
    padding: 0.2rem 0.35rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.48);
    color: #ffffff;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-align: center;
}

.hand-hint {
    max-width: 11rem;
    color: var(--muted);
    font-size: 0.86rem;
    text-align: right;
}

.controls-card {
    display: grid;
    gap: 0.8rem;
}

.selected-summary {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.4;
}

.selected-summary:empty {
    display: none;
}

.color-chooser {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.color-chip {
    min-width: 4.3rem;
    min-height: 2.6rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.color-chip.is-selected {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.34);
}

.action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.action-button {
    min-height: 3.1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 1rem;
    border: 0;
    color: #061011;
    font: inherit;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: normal;
    cursor: pointer;
    transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
}

.action-button:active {
    transform: translateY(1px);
}

.action-button:disabled {
    cursor: default;
    opacity: 0.46;
}

.action-button.primary {
    background: linear-gradient(180deg, #ffd363, #ffb11f);
}

.action-button.secondary {
    background: linear-gradient(180deg, #89ffba, #31c97f);
}

.action-button.warn {
    background: linear-gradient(180deg, #ffd365, #ff9d2f);
}

.action-button.ghost {
    background: rgba(255, 255, 255, 0.11);
    color: var(--ink);
}

.feedback-toast {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    width: min(calc(100% - 1.6rem), 28rem);
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    background: rgba(5, 10, 12, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--ink);
    text-align: center;
    box-shadow: 0 0.8rem 2.2rem rgba(0, 0, 0, 0.24);
}

@media (max-width: 520px) {
    .hero-header,
    .section-head {
        flex-wrap: wrap;
    }

    .pill-row {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .table-state {
        display: block;
    }

    .hand-scroller {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.42rem;
        padding-bottom: 0.35rem;
    }

    .hand-card-button.is-selected {
        transform: translateY(-0.28rem) scale(1.01);
    }

    .hand-hint {
        max-width: none;
        width: 100%;
        text-align: left;
        font-size: 0.8rem;
    }

    .score-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.45rem;
        padding: 0.62rem 0.7rem;
    }

    .score-pill {
        justify-self: start;
    }

    .players-card,
    .hand-card,
    .controls-card,
    .hero-card {
        padding: 0.82rem;
    }

    .selected-summary {
        font-size: 0.92rem;
    }

    .action-row {
        gap: 0.5rem;
    }

    .action-button {
        min-height: 2.9rem;
        padding: 0.62rem 0.7rem;
        font-size: 0.88rem;
    }
}

@media (min-width: 760px) {
    .phone-shell {
        width: min(42rem, 100%);
        margin: 0 auto;
    }

    .hand-scroller {
        grid-template-columns: repeat(auto-fit, minmax(5.8rem, 1fr));
    }

    .action-row {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
