body {
    margin: 0;
    color: #1c1f2b;
    background:
        radial-gradient(circle at 16% 22%, rgba(255, 189, 89, 0.34), transparent 32%),
        radial-gradient(circle at 86% 82%, rgba(32, 123, 140, 0.3), transparent 34%),
        linear-gradient(145deg, #f9f4ea, #e8f2f4);
}

.domino-hero {
    background:
        radial-gradient(circle at 20% 18%, rgba(255, 219, 167, 0.34), transparent 45%),
        linear-gradient(42deg, #1f3a5f, #0f766e 60%, #155e75);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.domino-stage {
    --tile-w: 98px;
    --tile-h: 56px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(31, 58, 95, 0.16);
    border-radius: 22px;
    box-shadow: 0 20px 42px rgba(18, 29, 51, 0.16);
    backdrop-filter: blur(6px);
    padding: 2rem;
    margin-bottom: 3rem;
    overflow: hidden;
}

.difficulty-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.difficulty-label {
    font-weight: 700;
    color: #1f3a5f;
}

.difficulty-buttons {
    display: inline-flex;
    gap: 0.45rem;
}

.difficulty-btn {
    border: 1px solid #8ecae6;
    border-radius: 10px;
    padding: 0.48rem 0.8rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f3a5f;
    background: #ffffff;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.difficulty-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 14px rgba(31, 58, 95, 0.16);
}

.difficulty-btn.active {
    border-color: transparent;
    background: linear-gradient(135deg, #0ea5a4, #2563eb);
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.2);
}

.hud-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.1rem;
}

.hud-chip {
    border-radius: 14px;
    padding: 0.75rem;
    border: 1px solid rgba(21, 94, 117, 0.3);
    background: linear-gradient(150deg, #ffffff, #edf8f9);
    text-align: center;
}

.hud-chip span {
    display: block;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #1f3a5f;
}

.hud-chip strong {
    font-size: 1.2rem;
    color: #0b3a43;
}

.status-message {
    margin: 0 0 1.2rem;
    text-align: center;
    font-weight: 800;
    color: #1f3a5f;
}

.table-wrap {
    border-radius: 18px;
    border: 1px solid rgba(31, 58, 95, 0.14);
    padding: 1rem;
    background:
        linear-gradient(145deg, #124b57, #0f766e),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0 6px, rgba(255, 255, 255, 0.02) 6px 12px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.table-end {
    color: #f3f7ef;
    text-align: center;
}

.table-end span {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.table-end strong {
    display: block;
    font-size: 1.2rem;
}

.domino-chain {
    min-height: clamp(78px, 12vh, 130px);
    max-width: 100%;
    margin: 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow-x: auto;
    padding: 0.3rem 0.15rem 0.4rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.domino-chain.empty::before {
    content: 'No tiles on table yet';
    color: rgba(255, 255, 255, 0.92);
    font-weight: 700;
    margin: 0 auto;
}

.domino-tile {
    width: var(--tile-w);
    min-width: var(--tile-w);
    height: var(--tile-h);
    border-radius: 12px;
    background: #fffdf8;
    border: 2px solid #1f2937;
    box-shadow: 0 8px 16px rgba(17, 24, 39, 0.3);
    display: grid;
    grid-template-rows: 1fr;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-items: center;
    font-weight: 800;
    font-size: clamp(0.95rem, 2.4vw, 1.1rem);
    color: #111827;
}

.domino-tile .divider {
    width: 2px;
    height: 78%;
    background: #0f172a;
    opacity: 0.65;
}

.domino-tile.horizontal {
    width: var(--tile-w);
    min-width: var(--tile-w);
    height: var(--tile-h);
    grid-template-rows: 1fr;
    grid-template-columns: 1fr auto 1fr;
}

.domino-tile.horizontal .divider {
    width: 2px;
    height: 78%;
}

.domino-tile.vertical {
    width: var(--tile-h);
    min-width: var(--tile-h);
    height: var(--tile-w);
    grid-template-rows: 1fr auto 1fr;
    grid-template-columns: 1fr;
}

.domino-tile.vertical .divider {
    width: 78%;
    height: 2px;
}

.controls-row {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.65rem;
}

.action-btn {
    border: none;
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fffef9;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 18px rgba(239, 68, 68, 0.26);
    filter: saturate(1.05);
}

.action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.action-btn.subtle {
    background: linear-gradient(135deg, #4b5563, #1f2937);
}

.action-btn.restart {
    background: linear-gradient(135deg, #0ea5a4, #2563eb);
}

.hand-area {
    margin-top: 1.6rem;
}

.hand-area h2 {
    margin: 0;
    color: #1f3a5f;
}

.hand-tip {
    margin: 0.35rem 0 0.85rem;
    color: #344054;
    text-align: center;
}

.player-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.new-game-wrap {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

.new-game-wrap .action-btn {
    min-width: 170px;
}

.hand-tile {
    border: 2px solid #1f2937;
    border-radius: 12px;
    width: var(--tile-w);
    height: var(--tile-h);
    background: linear-gradient(170deg, #fffdf9, #f4ead8);
    display: grid;
    grid-template-rows: 1fr;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    justify-items: center;
    font-weight: 800;
    font-size: clamp(0.95rem, 2.4vw, 1.1rem);
    color: #111827;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.hand-tile .divider {
    width: 2px;
    height: 72%;
    background: #0f172a;
    opacity: 0.7;
}

.hand-tile.vertical {
    width: var(--tile-h);
    height: var(--tile-w);
    grid-template-rows: 1fr auto 1fr;
    grid-template-columns: 1fr;
}

.hand-tile.vertical .divider {
    width: 72%;
    height: 2px;
}

.hand-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 16px rgba(17, 24, 39, 0.22);
}

.hand-tile.selected {
    border-color: #ea580c;
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.2);
    transform: translateY(-4px);
}

.hand-tile.unplayable {
    opacity: 0.44;
}

.internal-nav {
    text-align: center;
    margin-bottom: 3rem;
}

.internal-nav h3 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #1f3a5f;
    margin-top: 0;
    margin-bottom: 2rem;
}

.game-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.6rem;
}

.game-btn {
    background: #f8f9fa;
    border-radius: 10px;
    text-align: center;
    padding: 1.2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e9ecef;
    color: #343a40;
    text-decoration: none;
}

.game-btn:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.game-btn img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.game-btn span {
    font-size: 1.2rem;
    font-weight: 600;
}

.info-section {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 2.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.info-card h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #1f3a5f;
    margin-top: 0;
    margin-bottom: 1rem;
}

.info-card p,
.info-card li {
    color: #334155;
}

.info-card ul {
    margin: 0;
    padding-left: 1.2rem;
}

.info-card.full-width {
    grid-column: 1 / -1;
}

@keyframes tileDrop {
    from {
        transform: translateY(-6px);
        opacity: 0.4;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.domino-chain .domino-tile {
    animation: tileDrop 240ms ease;
}

@media (max-width: 900px) {
    .domino-stage {
        --tile-w: 92px;
        --tile-h: 52px;
    }

    .info-section {
        grid-template-columns: 1fr;
    }

    .domino-tile {
        width: var(--tile-w);
        min-width: var(--tile-w);
        height: var(--tile-h);
    }

    .domino-tile.horizontal {
        width: var(--tile-w);
        min-width: var(--tile-w);
        height: var(--tile-h);
    }
}

@media (max-width: 768px) {
    .domino-stage {
        --tile-w: clamp(74px, 22vw, 88px);
        --tile-h: clamp(42px, 12.8vw, 50px);
    }

    main {
        padding: 2rem 1rem;
    }

    .domino-stage,
    .info-section {
        padding: 1.3rem;
    }

    .domino-chain {
        min-height: min(18vh, 120px);
    }

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

    .action-btn {
        min-height: 46px;
    }

    .difficulty-bar {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .difficulty-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .new-game-wrap .action-btn {
        width: min(100%, 260px);
    }
}

@media (max-width: 480px) {
    .domino-stage {
        --tile-w: clamp(68px, 24vw, 80px);
        --tile-h: clamp(40px, 14vw, 48px);
        padding: 1.05rem;
    }

    .domino-chain {
        gap: 0.35rem;
    }

    .player-hand {
        gap: 0.38rem;
    }
}

@media (max-width: 360px) {
    main {
        padding: 1.5rem 0.8rem;
    }

    .domino-stage,
    .info-section {
        padding: 1rem;
    }

    .hand-tile {
        width: clamp(64px, 25vw, 74px);
        height: clamp(38px, 14vw, 44px);
        font-size: 0.9rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    main {
        padding: 1.2rem 1rem;
    }

    .domino-stage {
        --tile-w: 74px;
        --tile-h: 42px;
        padding: 1rem;
    }

    .domino-chain {
        min-height: 72px;
    }
}
