/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --felt: #0d6b30;
    --felt-dark: #094d22;
    --gold: #f0c040;
    --gold-light: #ffe082;
    --red: #d32f2f;
    --green: #2e7d32;
    --blue: #1565c0;
    --dark: #1a1a2e;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(ellipse at 50% 30%, #0f7a38 0%, #0a5e2a 40%, #063d1a 100%);
    color: #fff;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    padding: 20px 12px 40px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 520px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ========== Title ========== */
.title {
    font-family: 'Playfair Display', serif;
    font-size: 2.6rem;
    font-weight: 900;
    letter-spacing: 6px;
    background: linear-gradient(180deg, #fff 0%, var(--gold) 50%, #c6930a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
    line-height: 1.1;
}

.subtitle {
    font-family: 'Playfair Display', serif;
    font-size: .95rem;
    letter-spacing: 8px;
    text-transform: uppercase;
    opacity: .5;
    margin-top: -8px;
}

/* ========== Scoreboard ========== */
.scoreboard {
    display: flex;
    gap: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-val {
    font-size: 1.4rem;
    font-weight: 700;
}

.stat-label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: .5;
}

/* ========== Table ========== */
.table {
    width: 100%;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(255,255,255,.03) 0%, transparent 70%),
        linear-gradient(180deg, #0a5525 0%, #0d6b30 50%, #0a5525 100%);
    border: 4px solid #1a8a42;
    border-radius: 24px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow:
        inset 0 0 60px rgba(0,0,0,.3),
        0 8px 32px rgba(0,0,0,.4),
        0 0 0 2px rgba(0,0,0,.3);
    position: relative;
}

.hand-section { min-height: 80px; }

.hand-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.label-text {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: .6;
}

.hand-score {
    font-size: .75rem;
    font-weight: 700;
    background: rgba(0,0,0,.4);
    padding: 3px 12px;
    border-radius: 12px;
    min-width: 32px;
    text-align: center;
}

.hand-score:empty { display: none; }

.hand {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 110px;
    align-items: flex-start;
}

/* ========== Table Divider ========== */
.table-divider {
    border-top: 1px solid rgba(255,255,255,.1);
    border-bottom: 1px solid rgba(255,255,255,.1);
    padding: 10px 0;
    margin: 4px 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== Cards ========== */
.card {
    width: 72px;
    height: 104px;
    border-radius: 10px;
    position: relative;
    box-shadow: 2px 4px 12px rgba(0,0,0,.35);
    transform-style: preserve-3d;
    animation: dealIn .4s cubic-bezier(.23,1,.32,1) both;
}

.card-face {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    backface-visibility: hidden;
}

.card-front {
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border: 1px solid #ddd;
}

.card-front .corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-weight: 700;
}

.card-front .corner-top {
    top: 5px;
    left: 6px;
}

.card-front .corner-bottom {
    bottom: 5px;
    right: 6px;
    transform: rotate(180deg);
}

.card-front .corner .c-rank {
    font-size: .8rem;
}

.card-front .corner .c-suit {
    font-size: .7rem;
    line-height: 1;
}

.card-front .center-suit {
    font-size: 2.2rem;
    line-height: 1;
}

.card.red .card-front { color: var(--red); }
.card.black .card-front { color: #1a1a1a; }

.card-back {
    background:
        repeating-linear-gradient(
            45deg,
            #1a237e 0px, #1a237e 4px,
            #283593 4px, #283593 8px
        );
    border: 3px solid #fff;
    transform: rotateY(180deg);
    overflow: hidden;
}

.card-back::after {
    content: "";
    position: absolute;
    inset: 6px;
    border: 2px solid rgba(255,255,255,.25);
    border-radius: 6px;
}

.card.facedown {
    animation: dealIn .4s cubic-bezier(.23,1,.32,1) both;
}

.card.facedown .card-front { visibility: hidden; }
.card.facedown .card-back { transform: rotateY(0deg); }

.card.flipping {
    animation: flipCard .6s ease-in-out both;
}

@keyframes dealIn {
    from { opacity: 0; transform: translateY(-40px) scale(.8); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes flipCard {
    0%   { transform: rotateY(180deg); }
    100% { transform: rotateY(0deg); }
}

/* ========== Message ========== */
.message {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(0,0,0,.5);
    letter-spacing: 1px;
}

.message:empty { display: none; }

.message.win       { color: var(--gold); }
.message.lose      { color: #ff6b6b; }
.message.push      { color: #b0bec5; }
.message.blackjack {
    color: var(--gold);
    font-size: 1.5rem;
    animation: pulseGlow 1s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    from { text-shadow: 0 0 10px rgba(240,192,64,.3); }
    to   { text-shadow: 0 0 30px rgba(240,192,64,.7), 0 0 60px rgba(240,192,64,.3); }
}

/* ========== Balance ========== */
.balance-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.balance-label {
    font-size: .6rem;
    letter-spacing: 3px;
    opacity: .5;
}

.balance-amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.balance-amount.changing {
    animation: balancePop .3s ease-out;
}

@keyframes balancePop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ========== Bet Area ========== */
.bet-area {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    animation: fadeSlideUp .3s ease-out;
}

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

.bet-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ========== Chips ========== */
.chip-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px dashed rgba(255,255,255,.6);
    cursor: pointer;
    transition: transform .15s, box-shadow .2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chip-inner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    pointer-events: none;
}

.chip-btn:active { transform: scale(.9); }

.chip-btn[data-amount="5"]   { background: #c62828; }
.chip-btn[data-amount="5"] .chip-inner { color: #fff; }
.chip-btn[data-amount="25"]  { background: #2e7d32; }
.chip-btn[data-amount="25"] .chip-inner { color: #fff; }
.chip-btn[data-amount="50"]  { background: #1565c0; }
.chip-btn[data-amount="50"] .chip-inner { color: #fff; }
.chip-btn[data-amount="100"] { background: #111; }
.chip-btn[data-amount="100"] .chip-inner { color: var(--gold); border-color: var(--gold); }

.chip-btn.selected {
    box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(240,192,64,.5);
    transform: scale(1.08);
}

/* ========== Bet Input ========== */
.bet-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.bet-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.bet-dollar {
    position: absolute;
    left: 10px;
    font-weight: 700;
    color: #555;
    font-size: 1rem;
    pointer-events: none;
}

#bet-amount {
    width: 90px;
    padding: 10px 10px 10px 24px;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,.15);
    background: rgba(0,0,0,.3);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: border-color .2s;
    -moz-appearance: textfield;
}

#bet-amount::-webkit-inner-spin-button,
#bet-amount::-webkit-outer-spin-button { -webkit-appearance: none; }

#bet-amount:focus { border-color: var(--gold); }

/* ========== Buttons ========== */
.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 2px;
    transition: transform .1s, box-shadow .2s, filter .2s;
    touch-action: manipulation;
    min-height: 48px;
}

.btn:active { transform: scale(.94); }

.btn-deal {
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
    color: #222;
    box-shadow: 0 4px 12px rgba(240,192,64,.3);
}

.btn-hit {
    background: linear-gradient(180deg, #43a047, #2e7d32);
    color: #fff;
    box-shadow: 0 4px 12px rgba(46,125,50,.3);
}

.btn-stand {
    background: linear-gradient(180deg, #ef5350, #c62828);
    color: #fff;
    box-shadow: 0 4px 12px rgba(198,40,40,.3);
}

.btn-double {
    background: linear-gradient(180deg, #42a5f5, #1565c0);
    color: #fff;
    box-shadow: 0 4px 12px rgba(21,101,192,.3);
}

.btn-new-round {
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
    color: #222;
    box-shadow: 0 4px 12px rgba(240,192,64,.3);
    animation: fadeSlideUp .3s ease-out;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    animation: fadeSlideUp .3s ease-out;
}

/* ========== Donate Section ========== */
.donate-section {
    margin-top: 20px;
    background: linear-gradient(135deg, rgba(0,0,0,.35), rgba(0,0,0,.2));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 22px 18px;
    width: 100%;
}

.donate-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.donate-icon {
    font-size: 1.3rem;
}

.donate-header h3 {
    font-size: .9rem;
    font-weight: 600;
    opacity: .85;
}

.wallet-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wallet {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.06);
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.06);
}

.wallet-label {
    font-weight: 700;
    font-size: .85rem;
    min-width: 50px;
    white-space: nowrap;
}

.wallet-addr {
    font-size: .7rem;
    word-break: break-all;
    background: rgba(0,0,0,.3);
    padding: 6px 8px;
    border-radius: 6px;
    flex: 1;
    min-width: 0;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: rgba(255,255,255,.7);
}

.copy-btn {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: 1px;
    transition: background .2s;
    white-space: nowrap;
}

.copy-btn:active { background: rgba(255,255,255,.2); }

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,.85);
    color: #fff;
    padding: 10px 24px;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity .3s, transform .3s;
    z-index: 100;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========== Tips Button ========== */
.tips-toggle-btn {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.7);
    padding: 6px 18px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background .2s, color .2s;
    touch-action: manipulation;
}

.tips-toggle-btn:active { background: rgba(255,255,255,.15); color: #fff; }

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: linear-gradient(180deg, #1a2a1a 0%, #0f1f0f 100%);
    border: 1px solid rgba(255,255,255,.1);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.23,1,.32,1);
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.modal-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(180deg, #fff, var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: rgba(255,255,255,.1);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
}

.modal-close:active { background: rgba(255,255,255,.2); }

.modal-body {
    overflow-y: auto;
    padding: 18px 22px 32px;
    -webkit-overflow-scrolling: touch;
}

/* ========== Tip Sections ========== */
.tip-section {
    margin-bottom: 22px;
}

.tip-section:last-child { margin-bottom: 0; }

.tip-section h3 {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(240,192,64,.15);
}

.tip-section ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tip-section li {
    font-size: .85rem;
    line-height: 1.5;
    padding-left: 18px;
    position: relative;
    color: rgba(255,255,255,.85);
}

.tip-section li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    opacity: .5;
}

.tip-section li strong {
    color: #fff;
}

/* ========== Strategy Chart ========== */
.chart-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

.strategy-chart {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    text-align: center;
}

.strategy-chart th {
    background: rgba(0,0,0,.4);
    padding: 10px 12px;
    font-weight: 700;
    font-size: .7rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,.6);
}

.strategy-chart td {
    padding: 8px 12px;
    border-top: 1px solid rgba(255,255,255,.06);
    font-weight: 600;
}

.strategy-chart tbody tr:nth-child(odd) { background: rgba(255,255,255,.03); }
.strategy-chart tbody tr:nth-child(even) { background: rgba(0,0,0,.15); }

.act-hit    { color: #66bb6a; }
.act-stand  { color: #ef5350; }
.act-double { color: #42a5f5; }

.chart-note {
    font-size: .7rem;
    opacity: .45;
    margin-top: 8px;
    text-align: center;
}

/* ========== Keyboard Shortcuts ========== */
.shortcut-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.shortcut {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .8rem;
    color: rgba(255,255,255,.75);
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    padding: 4px 8px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 6px;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
}

/* ========== Responsive ========== */
@media (max-width: 420px) {
    .title { font-size: 2rem; letter-spacing: 4px; }
    .card { width: 60px; height: 88px; }
    .card-front .center-suit { font-size: 1.7rem; }
    .card-front .corner .c-rank { font-size: .7rem; }
    .card-front .corner .c-suit { font-size: .6rem; }
    .btn { padding: 12px 20px; font-size: .9rem; width: 100%; }
    .controls { width: 100%; }
    .controls .btn { flex: 1; min-width: 0; }
    .chip-btn { width: 52px; height: 52px; }
    .chip-inner { width: 32px; height: 32px; font-size: .7rem; }
    .balance-amount { font-size: 1.4rem; }
    .table { padding: 16px 12px; border-radius: 18px; }
    .bet-input-row { width: 100%; }
    .bet-input-row .btn { flex: 1; }
}
