:root {
    --navy: #17245f;
    --navy-deep: #101a49;
    --orange: #fb7a11;
    --gold: #e2b35e;
    --cream: #f5f2eb;
    --cream-soft: #efe6d2;
    --ink: #101010;
    --line: rgba(255, 255, 255, 0.16);
    --panel: rgba(12, 20, 60, 0.86);
    --panel-light: rgba(255, 255, 255, 0.08);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.30);
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--cream);
    background:
        radial-gradient(circle at top left, rgba(251, 122, 17, 0.22), transparent 30rem),
        radial-gradient(circle at right center, rgba(226, 179, 94, 0.16), transparent 24rem),
        linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
}

button {
    border: 0;
    border-radius: 999px;
    padding: 0.9rem 1.15rem;
    font-weight: 800;
    cursor: pointer;
    color: var(--navy-deep);
    background: linear-gradient(180deg, #ffd08f 0%, var(--gold) 100%);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
    transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.game-shell {
    width: min(1200px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.hero,
.score-strip,
.status-card,
.table-card,
.hand-card,
footer {
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    border-radius: 2rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -2rem -2rem auto;
    width: 16rem;
    height: 16rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251, 122, 17, 0.16), transparent 68%);
    pointer-events: none;
}

.hero-brand {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 0;
}

.brand-logo {
    width: clamp(110px, 16vw, 180px);
    height: auto;
    border-radius: 1.5rem;
    background: rgba(255,255,255,0.04);
    padding: 0.35rem;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18);
    flex-shrink: 0;
}

.eyebrow,
.label {
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 900;
    color: var(--gold);
}

h1 {
    margin: 0;
    font-size: clamp(2.3rem, 6vw, 4.8rem);
    line-height: 0.95;
    color: #ffffff;
    text-shadow: 4px 4px 0 rgba(251, 122, 17, 0.25);
}

.tagline {
    max-width: 48rem;
    margin: 0.8rem 0 0;
    color: rgba(245, 242, 235, 0.84);
    font-size: 1.05rem;
}

.primary-btn {
    z-index: 1;
    white-space: nowrap;
}

.score-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
    border-radius: 1.4rem;
    padding: 1rem;
}

.score-strip div {
    border-radius: 1rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.05));
    padding: 1rem;
}

.score-strip strong {
    display: block;
    font-size: 1.9rem;
}

.status-card,
.table-card,
.hand-card,
footer {
    margin-top: 1rem;
    border-radius: 1.4rem;
    padding: 1.25rem;
}

.status-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

#message {
    margin: 0;
    font-size: 1.05rem;
}

.ends {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.ends span,
.turn-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.55rem 0.85rem;
    color: var(--navy-deep);
    background: var(--cream);
    font-weight: 900;
}

.table-header,
.hand-heading,
.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.table-header p,
.hand-heading p,
footer p {
    margin: 0;
    color: rgba(245, 242, 235, 0.8);
}

.table-controls-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.toggle-card {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    font-weight: 700;
    color: var(--cream);
}

.toggle-card input {
    accent-color: var(--orange);
    width: 18px;
    height: 18px;
}

.turn-badge.cpu {
    background: var(--orange);
    color: white;
}

.board {
    min-height: 180px;
    margin-top: 1rem;
    border-radius: 1.1rem;
    padding: 1rem;
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    overflow-x: auto;
    background:
        repeating-linear-gradient(45deg, rgba(255,255,255,0.03) 0 10px, transparent 10px 20px),
        rgba(0, 0, 0, 0.18);
}

.board-track {
    min-width: min(620px, 100%);
    flex: 1;
    min-height: 150px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.4rem;
}

.empty-board {
    width: 100%;
    text-align: center;
    color: rgba(245, 242, 235, 0.70);
    font-weight: 800;
}

.drop-hint {
    margin: 0.8rem 0 0;
    color: rgba(245, 242, 235, 0.68);
    font-size: 0.92rem;
}

.controls {
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.hand {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.hand-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    border-radius: 1.2rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    user-select: none;
    transition: transform 160ms ease, outline-color 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.hand-tile.playable {
    background: rgba(251, 122, 17, 0.12);
    border-color: rgba(251, 122, 17, 0.55);
}

.hand-tile.hints-off {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.10);
}

.hand-tile[draggable="true"] {
    cursor: grab;
}

.hand-tile[draggable="true"]:active {
    cursor: grabbing;
}

.hand-tile.selected {
    outline: 3px solid var(--gold);
    outline-offset: 4px;
    transform: translateY(-3px);
}

.hand-tile.dragging {
    opacity: 0.48;
    transform: rotate(-2deg) scale(0.98);
}

.tile-actions {
    min-height: 2.2rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tile-actions button {
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
}

.tile-actions.hidden-by-toggle {
    display: none;
}

.domino {
    width: 104px;
    min-width: 104px;
    height: 52px;
    border-radius: 0.75rem;
    border: 3px solid #101010;
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    background: var(--cream-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45), 0 10px 20px rgba(0,0,0,0.24);
}

.domino.vertical {
    width: 56px;
    min-width: 56px;
    height: 112px;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}

.domino-half {
    position: relative;
    display: grid;
    place-items: center;
    padding: 0.25rem;
}

.domino:not(.vertical) .domino-half:first-child {
    border-right: 2px solid #101010;
}

.domino.vertical .domino-half:first-child {
    border-right: 0;
    border-bottom: 2px solid #101010;
}

.pipface {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
    place-items: center;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: transparent;
}

.dot.on {
    background: var(--ink);
}

.pips-1 .dot:nth-child(5),
.pips-2 .dot:nth-child(1),
.pips-2 .dot:nth-child(9),
.pips-3 .dot:nth-child(1),
.pips-3 .dot:nth-child(5),
.pips-3 .dot:nth-child(9),
.pips-4 .dot:nth-child(1),
.pips-4 .dot:nth-child(3),
.pips-4 .dot:nth-child(7),
.pips-4 .dot:nth-child(9),
.pips-5 .dot:nth-child(1),
.pips-5 .dot:nth-child(3),
.pips-5 .dot:nth-child(5),
.pips-5 .dot:nth-child(7),
.pips-5 .dot:nth-child(9),
.pips-6 .dot:nth-child(1),
.pips-6 .dot:nth-child(3),
.pips-6 .dot:nth-child(4),
.pips-6 .dot:nth-child(6),
.pips-6 .dot:nth-child(7),
.pips-6 .dot:nth-child(9) {
    background: var(--ink);
}

.pip-count {
    border-radius: 999px;
    padding: 0.55rem 0.85rem;
    background: rgba(255, 255, 255, 0.08);
}

.drop-zone {
    width: clamp(96px, 13vw, 140px);
    min-height: 150px;
    border-radius: 1rem;
    border: 2px dashed rgba(255, 255, 255, 0.32);
    color: rgba(245, 242, 235, 0.78);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: none;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.35rem;
    padding: 1rem;
}

.drop-zone span {
    font-size: 1rem;
    color: var(--cream);
}

.drop-zone small {
    color: rgba(245, 242, 235, 0.72);
}

.drop-zone.ready {
    border-color: var(--gold);
    background: rgba(251, 122, 17, 0.20);
    color: var(--cream);
    box-shadow: inset 0 0 0 2px rgba(226, 179, 94, 0.12), 0 12px 24px rgba(0,0,0,0.18);
}

.drop-zone.drag-over {
    transform: scale(1.04);
    background: rgba(251, 122, 17, 0.52);
    border-color: var(--cream);
}

.drop-zone.not-allowed {
    border-color: rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.04);
}

footer {
    text-align: center;
}

@media (max-width: 860px) {
    .hero,
    .status-card,
    .table-header,
    .hand-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-brand {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-controls-right {
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    .score-strip {
        grid-template-columns: repeat(2, 1fr);
    }

    .board {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .board-track {
        grid-column: 1 / -1;
        order: 2;
        min-width: 100%;
    }

    .drop-zone {
        width: 100%;
        min-height: 90px;
    }
}
