:root {
    color-scheme: dark;
    --bg: #0d1110;
    --surface: #151b18;
    --surface-2: #1d2520;
    --surface-3: #263129;
    --felt: #174734;
    --felt-2: #0f3024;
    --ink: #f4efe6;
    --muted: #aeb8ad;
    --line: rgba(244, 239, 230, .12);
    --gold: #d6a84f;
    --green: #4ba36d;
    --green-strong: #70ce92;
    --red: #c95454;
    --blue: #5f97c9;
    --purple: #9a7ad4;
    --shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 20% 0%, rgba(75, 163, 109, .16), transparent 32rem),
        radial-gradient(circle at 84% 10%, rgba(214, 168, 79, .12), transparent 28rem),
        linear-gradient(180deg, #101511 0%, #080b0a 100%);
    font-family: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(1540px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 42px;
}

.app-header {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1b1210;
    background:
        radial-gradient(circle at 50% 32%, #fff8ea 0 18%, transparent 19%),
        linear-gradient(150deg, #f0ca75, #ba4b46 72%);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 12px;
    font-size: 1.35rem;
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(0, 0, 0, .24);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 1.12rem;
    line-height: 1.1;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.top-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    background: rgba(21, 27, 24, .78);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.top-nav a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    color: var(--muted);
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 800;
}

.top-nav a:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, .07);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.control-panel,
.main-panel,
.hand-detail-card,
.strategy-card {
    background: linear-gradient(180deg, rgba(25, 33, 29, .94), rgba(17, 22, 19, .94));
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.control-panel {
    position: sticky;
    top: 14px;
    display: grid;
    gap: 16px;
    padding: 16px;
}

.panel-heading h1,
.toolbar h2,
.strategy-card h2 {
    margin: 4px 0 0;
}

.panel-heading h1 {
    font-size: clamp(1.6rem, 4vw, 2.25rem);
    line-height: 1;
}

.panel-heading p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.eyebrow,
.control-label {
    color: var(--gold);
    font-size: .75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.control-group {
    display: grid;
    gap: 8px;
}

.segment-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 5px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.segment-control button,
.position-tabs button {
    min-height: 40px;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 850;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.segment-control button:hover,
.position-tabs button:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, .06);
}

.segment-control button.is-active,
.position-tabs button.is-active {
    color: #141511;
    background: var(--gold);
    border-color: rgba(255, 255, 255, .18);
}

.position-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.position-tabs button {
    display: grid;
    gap: 2px;
    padding: 7px 8px;
    text-align: left;
}

.position-tabs small {
    color: inherit;
    opacity: .72;
    font-size: .72rem;
    font-weight: 700;
}

.search-box {
    display: grid;
    gap: 8px;
}

.search-box > span {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.search-box div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.search-box input,
.search-box button {
    min-height: 42px;
    border-radius: 8px;
}

.search-box input {
    min-width: 0;
    padding: 0 12px;
    color: var(--ink);
    background: #0f1412;
    border: 1px solid var(--line);
    text-transform: uppercase;
}

.search-box input:focus {
    outline: 3px solid rgba(214, 168, 79, .2);
    border-color: rgba(214, 168, 79, .56);
}

.search-box button {
    padding: 0 13px;
    color: #15120c;
    background: var(--green-strong);
    border: 1px solid transparent;
    font-weight: 900;
}

.readout-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.metric-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.metric {
    display: grid;
    gap: 2px;
    padding: 10px;
    background: rgba(0, 0, 0, .14);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metric span {
    color: var(--muted);
    font-size: .7rem;
    font-weight: 850;
    text-transform: uppercase;
}

.metric strong {
    font-size: 1.1rem;
}

.readout-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.main-panel {
    min-width: 0;
    padding: 14px;
}

.toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.toolbar h2 {
    font-size: clamp(1.35rem, 3vw, 2rem);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.legend span {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 9px;
    color: var(--muted);
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
}

.swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.swatch.premium {
    background: var(--red);
}

.swatch.value {
    background: var(--green);
}

.swatch.speculative {
    background: var(--blue);
}

.swatch.steal {
    background: var(--purple);
}

.range-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 14px;
    align-items: start;
}

.matrix-wrap {
    min-width: 0;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    grid-template-rows: 28px minmax(0, 1fr);
    gap: 6px;
}

.rank-axis {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 900;
}

.rank-axis.top {
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(13, minmax(34px, 1fr));
    gap: 4px;
    text-align: center;
}

.rank-axis.side {
    grid-row: 2;
    display: grid;
    grid-template-rows: repeat(13, minmax(34px, 1fr));
    gap: 4px;
    align-items: center;
    text-align: center;
}

.hand-matrix {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(13, minmax(34px, 1fr));
    gap: 4px;
}

.hand-cell {
    min-width: 0;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    padding: 0;
    color: rgba(244, 239, 230, .3);
    background: rgba(255, 255, 255, .025);
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 7px;
    font-size: clamp(.64rem, .8vw, .86rem);
    font-weight: 900;
    letter-spacing: 0;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, opacity .12s ease;
}

.hand-cell:hover,
.hand-cell.is-selected {
    transform: translateY(-1px);
    border-color: rgba(244, 239, 230, .58);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .26);
}

.hand-cell.in-range {
    color: #fff8ec;
    opacity: 1;
}

.hand-cell.out-range {
    opacity: .74;
}

.hand-cell.tier-premium {
    background: linear-gradient(145deg, #ca4e4e, #7e2c34);
    border-color: rgba(255, 182, 155, .4);
}

.hand-cell.tier-value {
    background: linear-gradient(145deg, #3f9b65, #1e5f40);
    border-color: rgba(136, 227, 164, .36);
}

.hand-cell.tier-speculative {
    background: linear-gradient(145deg, #4d8fbd, #245274);
    border-color: rgba(143, 201, 244, .34);
}

.hand-cell.tier-steal {
    background: linear-gradient(145deg, #8c67c6, #4a3479);
    border-color: rgba(207, 184, 255, .3);
}

.hand-cell.is-selected {
    outline: 3px solid rgba(214, 168, 79, .36);
    outline-offset: 1px;
}

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

.table-visual,
.position-ladder {
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.table-visual {
    padding: 12px;
}

.felt {
    position: relative;
    min-height: 280px;
    overflow: hidden;
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 255, .1), transparent 58%),
        linear-gradient(145deg, var(--felt), var(--felt-2));
    border: 10px solid #2b1d16;
    border-radius: 44%;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .08), inset 0 26px 60px rgba(0, 0, 0, .24);
}

.felt-core {
    position: absolute;
    inset: 35% 22%;
    display: grid;
    place-items: center;
    text-align: center;
    color: rgba(255, 248, 232, .9);
}

.felt-core strong {
    font-size: 1.9rem;
    line-height: 1;
}

.felt-core span {
    color: rgba(255, 248, 232, .62);
    font-size: .78rem;
    font-weight: 850;
    text-transform: uppercase;
}

.seat {
    position: absolute;
    width: 58px;
    min-height: 48px;
    display: grid;
    place-items: center;
    gap: 1px;
    padding: 6px;
    color: #141511;
    background: #f1e7d3;
    border: 2px solid rgba(0, 0, 0, .16);
    border-radius: 10px;
    text-align: center;
    transform: translate(-50%, -50%);
    box-shadow: 0 12px 24px rgba(0, 0, 0, .24);
}

.seat strong {
    font-size: .8rem;
    line-height: 1;
}

.seat span {
    color: rgba(20, 21, 17, .66);
    font-size: .66rem;
    font-weight: 850;
}

.seat.is-active {
    color: #141511;
    background: var(--gold);
    border-color: rgba(255, 255, 255, .4);
}

.position-ladder {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.ladder-item {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    gap: 8px;
    align-items: center;
    padding: 8px;
    background: rgba(0, 0, 0, .12);
    border: 1px solid var(--line);
    border-radius: 9px;
}

.ladder-item.is-active {
    border-color: rgba(214, 168, 79, .5);
    background: rgba(214, 168, 79, .12);
}

.ladder-item strong {
    font-size: .84rem;
}

.ladder-bar {
    height: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
}

.ladder-bar span {
    height: 100%;
    display: block;
    background: linear-gradient(90deg, var(--red), var(--gold), var(--green-strong));
    border-radius: inherit;
}

.ladder-item em {
    color: var(--muted);
    font-size: .76rem;
    font-style: normal;
    font-weight: 850;
    text-align: right;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
    gap: 14px;
    margin-top: 14px;
}

.hand-detail-card,
.strategy-card {
    padding: 16px;
}

.hand-detail-card {
    min-height: 260px;
}

.hand-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.cards {
    display: inline-flex;
    gap: 8px;
}

.card-face {
    width: 74px;
    height: 104px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: 9px;
    color: #181514;
    background: #f5eddd;
    border-radius: 10px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, .24);
}

.card-face.red {
    color: #b33434;
}

.card-face strong {
    font-size: 1.25rem;
    line-height: 1;
}

.card-face span {
    align-self: center;
    justify-self: center;
    font-size: 2rem;
}

.card-face small {
    justify-self: end;
    transform: rotate(180deg);
    font-size: 1.25rem;
    font-weight: 900;
}

.hand-summary {
    display: grid;
    gap: 7px;
    text-align: right;
}

.hand-summary h2 {
    margin: 0;
    font-size: 2.2rem;
}

.hand-summary p {
    margin: 0;
    color: var(--muted);
}

.position-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.position-chip {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    color: var(--muted);
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 850;
}

.position-chip.is-open {
    color: #141511;
    background: var(--green-strong);
    border-color: transparent;
}

.strategy-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.strategy-list p {
    margin: 0;
    padding: 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
    border-radius: 9px;
    line-height: 1.5;
}

.strategy-list strong {
    color: var(--ink);
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    padding: 14px 2px 0;
    color: var(--muted);
    font-size: .86rem;
}

.app-footer p {
    margin: 0;
}

.app-footer a {
    color: var(--gold);
    font-weight: 850;
}

@media (max-width: 1180px) {
    .workspace,
    .range-layout,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .control-panel {
        position: static;
    }

    .insight-panel {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 18px, 1540px);
        padding-top: 10px;
    }

    .app-header,
    .toolbar,
    .app-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .top-nav,
    .legend {
        justify-content: stretch;
        width: 100%;
    }

    .top-nav a,
    .legend span {
        justify-content: center;
        flex: 1;
    }

    .position-tabs {
        grid-template-columns: 1fr;
    }

    .insight-panel {
        grid-template-columns: 1fr;
    }

    .matrix-wrap {
        grid-template-columns: 22px minmax(0, 1fr);
        gap: 4px;
    }

    .rank-axis.top,
    .hand-matrix {
        grid-template-columns: repeat(13, minmax(22px, 1fr));
        gap: 2px;
    }

    .rank-axis.side {
        grid-template-rows: repeat(13, minmax(22px, 1fr));
        gap: 2px;
    }

    .hand-cell {
        border-radius: 5px;
        font-size: .56rem;
    }

    .hand-display {
        align-items: flex-start;
        flex-direction: column;
    }

    .hand-summary {
        text-align: left;
    }

    .card-face {
        width: 62px;
        height: 88px;
    }
}
