:root {
    /* --- Wordle Colors --- */
    --color-green-wordle: #6aaa64;
    --color-yellow-wordle: #c9b458;
    --color-grey-wordle: #787c7e;
    /* "Known" cards (your hand / the board) — muted red, distinct from the
       grey "rank not in their hand" result. */
    --color-known: #bd6e6e;
    
    /* --- Light Theme (New Default) --- */
    --color-background: #f3f3f3;
    --color-container-bg: #ffffff;
    --color-container-bg-inner: #f9f9f9; 
    --color-text-primary: #333;
    --color-text-secondary: #787c7e;
    --color-border: #d3d6da;
    --color-header-green: #4CAF50;

    /* --- Dark Theme (Old) --- */
    --color-primary-bg: #1f1f1f;
    --color-secondary-bg: #2d2d2d;
    --color-text-light: #f0f0f0;

    /* --- Shared Colors --- */
    --color-table-felt: #2d6b5e;
    --color-table-felt-dark: #1a4a3e;
    --color-table-outline: #5c3a21;
    --color-card-bg: #f8f8f8;
    --color-card-border: #999;
    --color-card-red: #D90000;
    --color-card-black: #222;
    --color-button-submit: #4CAF50;
    --color-button-submit-hover: #45a049;
    --color-button-next: #555;
    --color-button-next-hover: #666;
    --color-disabled-btn: #a7a7a7;
    --color-error: #dc3545;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}
body.game-active {
    display: block;
    justify-content: unset;
    align-items: unset;
}
.game-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: none;
    flex-direction: column;
    gap: 20px;
}
header {
    text-align: center;
}
header h1 {
    font-size: 2.5em;
    color: var(--color-header-green);
    margin: 0;
    font-weight: 600;
}
.game-zone {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 20px;
}
.hidden {
    visibility: hidden;
}
#villain-stack-chips,
#hero-stack-chips {
    height: 56px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
/* --- Finished-hand panel (replaces the picker once the game is over) --- */
.post-game-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 16px;
    min-height: 240px;
    text-align: center;
}
.post-game-panel.show { display: flex; }
.post-game-eyebrow {
    margin: 0;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}
.post-game-result {
    margin: 0;
    font-size: 1.7em;
    font-weight: 800;
    letter-spacing: 0.01em;
}
.post-game-result.win  { color: #2e7d32; }
.post-game-result.loss { color: var(--color-text-primary); }
.post-game-sub {
    margin: 6px 0 0;
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}
.post-game-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.post-game-cards .card {
    width: 58px;
    height: 82px;
}
#view-results-btn {
    margin-top: 12px;
    min-width: 170px;
}
/* Action badge — describes the play (check / bet / call / raise / all-in / fold) */
.action-badge {
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.action-check { background: #607d8b; }
.action-call  { background: #1e88e5; }
.action-bet,
.action-raise { background: #43a047; }
.action-fold  { background: #9e9e9e; }
.action-allin { background: #e53935; }
.action-blind { background: #6d4c41; }
/* Money committed, shown next to the chips in a bet zone */
.bet-amount {
    font-size: 0.78em;
    font-weight: 700;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.32);
    padding: 3px 9px;
    border-radius: 11px;
    white-space: nowrap;
}
/* Red triangle marker for all-in */
.allin-tri {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 9px solid #fff;
    display: inline-block;
}
/* A chip pile = several single-denomination stacks side by side */
.chip-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.chip-pile {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 4px;
}
.chip-stack {
    position: relative;
    flex-shrink: 0;
}
/* Each chip is a disc; stacks overlap vertically via inline `bottom` offsets */
.chip-disc {
    position: absolute;
    left: 0;
    border-radius: 50%;
    border: 2px solid;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.45), inset 0 1px 1px rgba(255,255,255,0.28);
}
/* Rim dashes (the classic chip edge spots) */
.chip-disc::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    border: 2px dashed rgba(255,255,255,0.55);
}
/* Center hub */
.chip-disc::before {
    content: '';
    position: absolute;
    inset: 32%;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.chip-lg { width: 30px; height: 30px; }
.chip-sm { width: 22px; height: 22px; }
.chip-label {
    font-size: 0.75em;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
    white-space: nowrap;
    letter-spacing: 0.03em;
}
/* --- Chip animation keyframes --- */

/* Bet zone chips slide in from the player's direction */
@keyframes chipSlideDown {
    from { opacity: 0; transform: translateY(-22px) scale(0.7); }
to   { opacity: 1; transform: translateY(0)      scale(1);   }
}

@keyframes chipSlideUp {
    from { opacity: 0; transform: translateY(22px) scale(0.7); }
to   { opacity: 1; transform: translateY(0)     scale(1);   }
}

/* Pot grows */
@keyframes chipPop {
    0%   { transform: scale(0.6); opacity: 0.4; }
60%  { transform: scale(1.15); opacity: 1; }
100% { transform: scale(1);    opacity: 1; }
}

/* Stack text pulse when chips leave */
@keyframes stackPulse {
    0%   { opacity: 1;   }
35%  { opacity: 0.4; }
100% { opacity: 1;   }
}

/* Applied by JS */
.chip-slide-down  { animation: chipSlideDown  0.55s cubic-bezier(0.22,1,0.36,1) forwards; }
.chip-slide-up    { animation: chipSlideUp    0.55s cubic-bezier(0.22,1,0.36,1) forwards; }
.chip-pop         { animation: chipPop        0.6s cubic-bezier(0.34,1.56,0.64,1); }
.stack-pulse      { animation: stackPulse     0.6s ease; }
.card {
    background-color: var(--color-card-bg);
    border: 2px solid var(--color-card-border);
    border-radius: 6px;
    color: var(--color-text-dark);
    font-weight: bold;
    font-size: 1.2em;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    box-sizing: border-box;
}
.card-placeholder {
    background-color: rgba(255, 255, 255, 0.4); 
    border: 2px dashed var(--color-text-secondary);
    opacity: 0.6;
    border-radius: 6px;
}
/* Normal Card Styles */

.card-rank-display {
    font-size: 1.3em;
    line-height: 1;
}
/* "10" is two characters — same size as other ranks, just tighter tracking.
   The trailing letter-spacing + the "1"'s wide left bearing make the ink lean
   right, so nudge it left to optically center under the suit. */
.card-rank-display.is-ten {
    letter-spacing: -0.08em;
    text-indent: -0.08em;
}
.card-symbol-display {
    font-size: 1.1em;
    line-height: 1;
}
.card-suit-red {
    color: var(--color-card-red);
}
.card-suit-black {
    color: var(--color-card-black);
}
#guess-history-zone h2,
#selection-grid-zone h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--color-text-primary);
    font-weight: 500;
}
.legend-item {
    display: flex;
    align-items: flex-start;
    text-align: left;
}
.legend-color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 10px;
    border: 1px solid var(--color-text-secondary);
    flex-shrink: 0;
}
.legend-color-box.green {
    background-color: var(--color-green-wordle);
}
.legend-color-box.yellow {
    background-color: var(--color-yellow-wordle);
}
.legend-color-box.grey {
    background-color: var(--color-grey-wordle);
}
.legend-color-box.known {
    background-color: var(--color-known);
}
#guess-history-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.guess-street-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 15px;
}
.guess-street-column {
    flex-basis: 32%;
    background-color: var(--color-container-bg-inner);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px;
    min-height: 80px;
}
.guess-street-column h4 {
    margin: 0 0 10px 0;
    text-align: center;
    color: var(--color-text-secondary);
    font-weight: 600;
}
.guess-street-column.river-column {
    flex-basis: 100%;
    max-width: 100%;
}
.guess-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
.guess-street-column.river-column .guess-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    justify-items: center;
}
.guess-row {
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInUp 0.25s ease both;
}
.guess-cards {
    display: flex;
    gap: 8px;
}
.guess-cards .card {
    width: 45px;
    height: 65px;
    font-size: 1.1em;
}
.guess-row .card.green {
    background-color: var(--color-green-wordle);
    border-color: var(--color-green-wordle);
    color: var(--color-text-light);
}
.guess-row .card.yellow {
    background-color: var(--color-yellow-wordle);
    border-color: var(--color-yellow-wordle);
    color: var(--color-text-light);
}
.guess-row .card.grey {
    background-color: var(--color-grey-wordle);
    border-color: var(--color-grey-wordle);
    color: var(--color-text-light);
    opacity: 0.8;
}
#selection-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: stretch;
}
.card-slot {
    flex-grow: 1;
    height: 65px;
    background-color: var(--color-container-bg-inner);
    border: 2px dashed var(--color-border);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 0.9em;
}
.card-slot .card {
    width: 45px;
    height: 65px;
    font-size: 1.1em;
    margin: -2px;
}
#selection-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.btn {
    padding: 10px 15px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    height: 100%;
    min-height: 40px;
}
.btn.btn-primary {
    background-color: var(--color-button-submit);
    color: white;
}
.btn.btn-primary:hover:not(:disabled) {
    background-color: var(--color-button-submit-hover);
}
.btn:disabled {
    background-color: var(--color-disabled-btn);
    color: #f9f9f9;
    cursor: not-allowed;
}
#card-grid {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 5px;
}
.card-wrapper {
    cursor: pointer;
    border-radius: 6px;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.card-wrapper .card {
    width: 100%;
    height: 65px;
    font-size: 1.1em;
    padding-top: 5px;
    transition: all 0.2s ease;
}
.card-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}
.card-wrapper.selected .card {
    border-color: var(--color-button-submit);
    animation: selectionPulse 0.4s ease forwards;
}
.card-wrapper.known-card .card {
    background-color: var(--color-known);
    border-color: var(--color-known);
    color: var(--color-text-light);
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.card-wrapper.rank-miss .card {
    background-color: var(--color-grey-wordle);
    border-color: var(--color-grey-wordle);
    color: var(--color-text-light);
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}
.card-wrapper.rank-match .card {
    background-color: var(--color-yellow-wordle);
    border-color: var(--color-yellow-wordle);
    color: var(--color-text-light);
    box-shadow: none;
}
.card-wrapper.rank-match:hover .card {
    border-color: var(--color-yellow-wordle);
}
.card-wrapper.exact-match .card {
    background-color: var(--color-green-wordle);
    border-color: var(--color-green-wordle);
    color: var(--color-text-light);
    opacity: 1;
    cursor: not-allowed;
    pointer-events: none;
}
.card-wrapper.known-card:hover,
.card-wrapper.rank-miss:hover,
.card-wrapper.exact-match:hover {
    transform: none;
    box-shadow: none;
}
/* --- Animations --- */

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(12px); }
to   { opacity: 1; transform: translateY(0); }
}

@keyframes flipIn {
    from { opacity: 0; transform: rotateY(90deg) scale(0.8); }
to   { opacity: 1; transform: rotateY(0deg) scale(1); }
}

@keyframes selectionPulse {
    0%   { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6); }
60%  { box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
100% { box-shadow: 0 0 10px var(--color-button-submit); }
}


/* Board cards flip in when revealed */
.board-card-reveal {
    animation: flipIn 0.35s ease both;
}
/* Suppress animations during localStorage restore */
body.restoring .guess-row {
    animation: none;
}
.error-message {
    color: var(--color-error);
    font-weight: 500;
    text-align: center;
}
/* --- Responsive Layout for Wide, Landscape Screens --- */

@media (min-width: 1100px) and (orientation: landscape) {
    .game-container {
        max-width: 1600px;
    }
.game-zone {
        grid-template-columns: 55fr 45fr;
        grid-template-areas:
            "gameplay-top      history"
            "gameplay-main     history"
            "gameplay-main     tools";

        align-items: start;
        gap: 30px;
    }
.selection-grid-container {
        grid-area: tools;
    }
.guess-history-container {
        grid-area: history;
    }
.guess-street-column.river-column .guess-list {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}


/* --- Intro Screen Styles --- */

#intro-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90vh;
    text-align: center;
    padding: 20px;
}
.intro-content {
    max-width: 450px;
    width: 100%;
}
#intro-screen h1 {
    font-size: 3.5em;
    color: var(--color-text-primary);
    margin: 0 0 10px 0;
    font-weight: 600;
}
.intro-tagline {
    font-size: 1.25em;
    color: var(--color-text-primary);
    margin-bottom: 30px;
}
.intro-description {
    font-size: 0.95em;
    color: var(--color-text-secondary);
    line-height: 1.5;
    max-width: 400px;
    margin: 15px auto 30px auto;
    text-align: center;
}
.intro-legend-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 400px;
    margin: 0 auto 30px auto;
}
.intro-legend-preview .legend-item {
    color: var(--color-text-secondary);
    font-size: 0.9em;
    margin-bottom: 8px;
}
.intro-legend-preview .legend-item p {
    margin: 0;
    text-align: left;
}
.intro-legend-preview .legend-item strong {
    color: var(--color-text-primary);
}
.intro-legend-preview .legend-color-box {
    border: none;
}
#play-game-btn {
    border-radius: 30px;
    padding: 15px 50px;
    font-size: 1.2em;
    font-weight: 600;
    background-color: var(--color-button-submit);
    color: white;
    border: none;
    transition: background-color 0.2s ease;
    height: auto;
}
#play-game-btn:hover {
    background-color: var(--color-button-submit-hover);
}
.intro-date {
    margin-top: 20px;
    color: var(--color-text-secondary);
    font-size: 0.9em;
}
/* --- Legend Popup Styles --- */

.guess-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
#guess-history-zone h2 {
    margin: 0;
}
.btn-icon {
    background-color: var(--color-container-bg);
    color: var(--color-text-secondary);
    border: 2px solid var(--color-border);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}
.btn-icon:hover {
    background-color: var(--color-container-bg-inner);
    color: var(--color-text-primary);
    border-color: var(--color-text-secondary);
}
#feedback-legend {
    display: none;
    position: absolute;
    top: 60px;
    right: 20px;
    z-index: 10;

    background-color: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--color-border);
    backdrop-filter: blur(4px);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 0;
    width: 350px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
#feedback-legend.show {
    display: block;
}
#feedback-legend p {
    color: var(--color-text-secondary);
    margin: 0;
}
#feedback-legend strong {
    color: var(--color-text-primary);
}
#feedback-legend .legend-item {
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}
#feedback-legend .legend-item:last-child {
    margin-bottom: 0;
}
#feedback-legend .legend-color-box {
    border-color: var(--color-border);
}
/* --- End Game Modal Styles --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
/* The blur lives on a pseudo-element rather than on .modal-overlay itself.
   A backdrop-filter promotes the element AND ITS WHOLE SUBTREE onto a
   composited layer, and text rasterised on that layer gets its glyph edges
   shaved — most visibly on the big suit symbols in the results modal, where
   the heart lost the outside of its left lobe. Filtering a sibling layer
   instead keeps the identical blur while the modal's content renders normally.
   .modal-overlay is position:fixed, so inset:0 covers exactly the overlay. */
.modal-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
/* This class will be added by JS to show the modal */
.modal-overlay.show {
    display: flex;
}
.modal-content {
    background-color: var(--color-container-bg);
    color: var(--color-text-primary);
    border-radius: 12px;
    padding: 48px 40px 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 550px;
    position: relative;
    z-index: 1;   /* sit above the ::before blur layer */
    text-align: center;
}
.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 4px;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--color-text-secondary);
    cursor: pointer;
    line-height: 1;
}
.modal-close-btn .back-x {
    font-size: 1.7em;
    font-weight: 300;
}
.modal-close-btn:hover {
    color: var(--color-text-primary);
}
.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 600;
}
.modal-content h2.win {
    color: var(--color-green-wordle);
}
.modal-content h2.loss {
    color: var(--color-error);
}
.modal-content p {
    color: var(--color-text-secondary);
    font-size: 1.1em;
    margin-bottom: 10px;
}
.modal-solution-cards {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}
/* Override for bigger cards in the modal */
.modal-solution-cards .card {
    width: 90px;
    height: 130px;
    font-size: 2.2em; /* Bigger rank */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.modal-solution-cards .card-symbol-display {
    font-size: 1.8em; /* Bigger suit */
}
.modal-context {
    font-size: 0.95em !important;
    font-style: italic;
    line-height: 1.55;
    color: var(--color-text-secondary);
    padding: 4px 8px;
    margin: 4px 0 4px;
}
/* --- Progressive stats in the results modal --- */
.modal-stats {
    border-top: 1px solid var(--color-border);
    padding-top: 22px;
    margin-bottom: 24px;
    text-align: center;
}
.stats-heading {
    margin: 0 0 16px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-primary);
}
.stats-summary {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 26px;
}
.stat {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.stat-num {
    font-size: 2.2em;
    font-weight: 400;
    line-height: 1;
    color: var(--color-text-primary);
}
.stat-label {
    font-size: 0.72em;
    font-weight: 500;
    line-height: 1.2;
    color: var(--color-text-primary);
}
.stats-dist-title {
    margin: 0 0 10px;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-primary);
    text-align: center;
}
.stats-distribution {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.dist-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.dist-label {
    flex: 0 0 56px;
    text-align: right;
    font-size: 0.82em;
    font-weight: 500;
    color: var(--color-text-primary);
}
.dist-track {
    flex: 1;
    min-width: 0;
    display: flex;
    height: 24px;
    background-color: #edeff1;   /* full-width track gives each row structure */
    border-radius: 5px;
    overflow: hidden;
}
.dist-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 30px;
    height: 100%;
    padding: 0 9px;
    border-radius: 5px;
    background-color: #a6abae;
    transition: width 0.5s ease;
}
.dist-bar.current { background-color: #6aaa64; }
.dist-count {
    font-size: 0.82em;
    font-weight: 700;
    color: #fff;
}
.modal-buttons {
    display: flex;
    gap: 15px;
}
.modal-buttons .btn {
    flex-grow: 1;
    font-size: 1.1em;
    padding: 12px;
    text-decoration: none;
    height: auto;
}
.btn-youtube {
    background-color: transparent;
    color: var(--color-text-primary);
    border: 1.5px solid var(--color-border);
}
.btn-youtube:hover {
    background-color: var(--color-container-bg-inner);
}
.btn-share {
    background-color: #2e9e5b;
    color: white;
}
.btn-share:hover {
    background-color: #278a4f;
}
/* ============================================================
   iOS / Touch — remove tap highlight, handle safe area insets
   ============================================================ */
.card-wrapper {
    -webkit-tap-highlight-color: transparent;
}
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* ============================================================
   Phone Portrait  ≤ 480px  (all iPhone models portrait)
   ============================================================ */
@media (max-width: 480px) {

    body {
        padding: 8px;
    }
/* Header */
    header h1 {
        font-size: 1.8em;
        margin: 6px 0;
    }
.game-container {
        gap: 10px;
    }
.card-rank-display { font-size: 1.05em; }
.card-symbol-display { font-size: 0.85em; }
/* Guess history columns — reduce padding */
    #guess-history-zone h2,
    #selection-grid-zone h2 {
        font-size: 0.95em;
        margin-bottom: 8px;
    }
.guess-street-column {
        padding: 7px 5px;
    }
.guess-street-column h4 {
        font-size: 0.78em;
        margin-bottom: 5px;
    }
.guess-cards .card {
        width: 32px;
        height: 46px;
        font-size: 0.8em;
    }
/* Card grid — wrapper scrolls, slots/buttons stay fixed */
    #card-grid-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;   /* bleed to container edges */
        padding: 0 12px 6px;
    }
#card-grid {
        min-width: 572px; /* 13 × 40px cards + 12 × 4px gaps */
        gap: 4px;
    }
.card-wrapper .card {
        height: 52px;
        font-size: 0.88em;
        padding-top: 3px;
    }
/* Selection controls — slots side by side, buttons full-width row below */
    #selection-controls {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 12px;
    }
.card-slot {
        flex-grow: 1;
        flex-basis: calc(50% - 44px);
        height: 56px;
    }
.card-slot .card {
        width: 38px;
        height: 54px;
    }
#selection-buttons {
        flex-direction: row;
        width: 100%;
        gap: 8px;
    }
#selection-buttons .btn {
        flex: 1;
        font-size: 0.85em;
        padding: 10px 6px;
        min-height: 44px;
        height: auto;
    }
/* Legend popup narrower on mobile */
    #feedback-legend {
        width: 270px;
        right: 8px;
        top: 52px;
        font-size: 0.9em;
    }
/* Intro screen */
    #intro-screen h1 {
        font-size: 2.6em;
    }
.intro-tagline {
        font-size: 1.05em;
        margin-bottom: 20px;
    }
.intro-description {
        font-size: 0.88em;
    }
#play-game-btn {
        padding: 13px 40px;
        font-size: 1.1em;
    }
/* Modal */
    .modal-content {
        padding: 20px 14px;
        border-radius: 10px;
    }
.modal-solution-cards .card {
        width: 62px;
        height: 88px;
        font-size: 1.5em;
    }
.modal-solution-cards .card-symbol-display {
        font-size: 1.2em;
    }
.modal-context {
        font-size: 0.92em !important;
        padding: 12px;
    }
.modal-buttons {
        flex-direction: column;
        gap: 10px;
    }
.modal-buttons .btn {
        padding: 12px;
        font-size: 1em;
        height: auto;
    }
}

/* ============================================================
   Phone Landscape + Small Tablet  481px – 900px
   ============================================================ */
@media (min-width: 481px) and (max-width: 900px) {

    body {
        padding: 12px;
    }
header h1 {
        font-size: 2em;
    }
.game-container {
        gap: 14px;
    }
/* Card grid — ensure cards stay tappable */
    #card-grid-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
#card-grid {
        min-width: 572px;
        gap: 4px;
    }
.card-wrapper .card {
        height: 58px;
        font-size: 0.95em;
    }
/* Selection buttons touch-friendly */
    #selection-buttons .btn {
        min-height: 44px;
        height: auto;
    }
/* Intro */
    #intro-screen h1 {
        font-size: 3em;
    }
}

/* ============================================================
   Mobile bottom-sheet guess picker
   Desktop (> 900px) keeps the picker inline; these elements stay hidden.
   ============================================================ */
#mobile-action-bar,
#sheet-backdrop,
.sheet-handle,
.sheet-close {
    display: none;
}
.bar-hidden {
    display: none !important;
}
@media (max-width: 900px) {

    /* Keep the desktop pot | board | replay row on mobile (it still fits);
       just tighten the gaps. The replay stays in-flow to the right of the
       board rather than floating onto the felt's rounded corner. */
    #board-area { gap: 30px; }
/* Picker becomes a bottom sheet, lifting it out of the page flow so the
       table is no longer pushed off-screen by the 13×4 card grid. */
    #selection-grid-zone {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1100;
        height: 74vh;
        max-height: 74vh;
        margin: 0;
        padding-top: 26px;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    }
#selection-grid-zone.open {
        transform: translateY(0);
    }
/* Grab handle + close affordances */
    .sheet-handle {
        display: block;
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        border-radius: 2px;
        background: var(--color-border);
    }
.sheet-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 6px;
        right: 12px;
        width: 32px;
        height: 32px;
        padding: 0;
        border: none;
        background: none;
        font-size: 1.9em;
        line-height: 1;
        color: var(--color-text-secondary);
        cursor: pointer;
    }
/* Backdrop dims the table while the sheet is open */
    #sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
#sheet-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
body.sheet-open {
        overflow: hidden;
    }
/* Sticky bottom trigger bar */
    #mobile-action-bar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        padding: 10px 14px max(10px, env(safe-area-inset-bottom));
        background: var(--color-container-bg);
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    }
#mobile-guess-trigger {
        flex: 1;
        min-height: 50px;
        height: auto;
        font-size: 1.05em;
        border-radius: 10px;
    }
/* Reserve room so the fixed bar never covers page content */
    .game-container {
        padding-bottom: 78px;
    }
/* The bar advances the street on mobile, so hide the inline button */
    #next-street-btn {
        display: none;
    }
}

/* Scale down chip piles a touch on the smallest screens so wide
   multi-denomination pots/bets don't overflow the felt. */
@media (max-width: 480px) {
    #pot-chips .chip-pile,
    .bet-zone .chip-pile {
        transform: scale(0.85);
    }
}
/* ============================================================
   How-to-play modal
   Ported from the minimal-UI experiment, restyled for the light
   theme: it reuses .modal-overlay / .modal-content and draws its
   colours from the existing palette variables rather than
   introducing a second one.
   ============================================================ */

.help-content {
    text-align: left;
    max-width: 480px;
    padding: 40px 34px 26px;
}
.modal-x {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.9em;
    font-weight: 300;
    line-height: 1;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px;
}
.modal-x:hover { color: var(--color-text-primary); }
.help-title {
    font-size: 1.7em;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--color-text-primary);
}
.help-lede {
    margin: 0 0 16px;
    color: var(--color-text-secondary);
    font-size: 0.97em;
}
.help-steps {
    margin: 0 0 20px;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.help-steps li {
    font-size: 0.92em;
    line-height: 1.5;
    color: var(--color-text-primary);
}
.help-examples {
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.help-example {
    display: flex;
    align-items: center;
    gap: 14px;
}
.help-example p {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.45;
    color: var(--color-text-secondary);
}
.help-example p strong { color: var(--color-text-primary); }
/* Self-contained example tiles. The real board cards are styled by
   `.guess-row .card.green` etc., which is scoped to a guess row, so these
   carry their own colours instead of depending on that context. */
.help-card {
    width: 38px;
    height: 54px;
    flex-shrink: 0;
    border-radius: 5px;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    color: #fff;
    font-weight: 700;
    line-height: 1;
}
.help-card-rank { font-size: 1.05em; }
.help-card-suit { font-size: 0.95em; }
.help-card.green  { background-color: var(--color-green-wordle);  border-color: var(--color-green-wordle); }
.help-card.yellow { background-color: var(--color-yellow-wordle); border-color: var(--color-yellow-wordle); }
.help-card.grey   { background-color: var(--color-grey-wordle);   border-color: var(--color-grey-wordle); }
.help-card.known  { background-color: var(--color-known);         border-color: var(--color-known); }
.help-note {
    font-size: 0.82em;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin: 0 0 14px;
}
.help-footnote {
    font-size: 0.84em;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
}
/* Secondary "How to play" button on the intro screen. */
.btn-ghost {
    display: inline-block;
    margin-top: 12px;
    background: none;
    border: none;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.btn-ghost:hover { color: var(--color-text-primary); }
