:root {
    --quito-sky: #7ea7c9;
    --quito-stone: #2f3f4d;
    --quito-terracotta: #b86a47;
    --quito-gold: #c99a3a;
    --quito-cream: #f3ead7;
    --quito-ink: #1a232b;
    --panel-soft: #e8dcc4;
    --line: #6c7a86;
    --text-main: #16212a;
    --text-soft: #334654;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-xl: 0 18px 36px rgba(9, 20, 27, 0.34);
    --card-radius: 12px;
    --font-display: "Bebas Neue", sans-serif;
    --font-ui: "Sora", "Trebuchet MS", sans-serif;
    --aura-gold: rgba(221, 168, 69, 0.45);
    --aura-sky: rgba(132, 177, 214, 0.38);
    --felt-dark: #0f4d33;
    --felt-mid: #1c6a45;
    --felt-soft: #2f8558;
    --felt-ink: #0b2f1f;
    --felt-glow: rgba(245, 196, 98, 0.24);
    --table-wood: #3f2b1c;
    --table-rim: #a27a3b;
    --table-rim-soft: rgba(233, 194, 120, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    color: var(--text-main);
    background-color: #153f2c;
    background:
        radial-gradient(circle at 12% 8%, rgba(80, 135, 102, 0.24), transparent 36%),
        radial-gradient(circle at 92% 10%, rgba(221, 172, 84, 0.24), transparent 34%),
        linear-gradient(180deg, #f5eddc 0%, #eadab7 100%);
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
input,
select,
textarea,
a {
    touch-action: manipulation;
}

.app {
    height: 100%;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.header {
    --header-hide-offset: 0px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 236, 204, 0.26);
    border-radius: 14px;
    background:
        radial-gradient(circle at 14% 20%, rgba(255, 232, 194, 0.18), transparent 38%),
        linear-gradient(135deg, #16392a 0%, #1d4b36 50%, #286445 100%);
    color: var(--quito-cream);
    padding: 10px 10px 14px;
    box-shadow: 0 12px 22px rgba(5, 20, 13, 0.28);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    margin-bottom: 14px;
    transition: transform 0.32s ease, margin-bottom 0.32s ease;
}

.header.is-collapsed {
    transform: translateY(calc(-1 * var(--header-hide-offset)));
    margin-bottom: calc(14px - var(--header-hide-offset));
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.header-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    line-height: 0.95;
    text-transform: uppercase;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.city-tag {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    opacity: 0.92;
    background: rgba(255, 255, 255, 0.14);
    padding: 3px 7px;
    border-radius: 6px;
    color: rgba(255, 245, 227, 0.96);
    white-space: nowrap;
}

.header-menu-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: var(--quito-cream);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.header-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.2);
}

.header-menu-btn:active {
    transform: scale(0.96);
}

.header-menu-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.6;
}

.status-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(7, 19, 13, 0.34);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid rgba(255, 238, 214, 0.15);
}

.turn-indicator {
    color: var(--quito-gold);
    animation: pulseGlow 1.8s infinite;
    text-shadow: 0 0 12px rgba(221, 168, 69, 0.56);
}

.opponent-chat {
    flex: 0 0 auto;
    border-radius: 16px;
    background: transparent;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: none;
}

.opponent-side {
    flex: 0 0 62px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.avatar {
    width: 60px;
    height: 60px;
    min-width: 60px;
    position: relative;
    border: 2px solid rgba(184, 106, 71, 0.8);
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(145deg, #fff8f0, #f2e4cc);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.ai-thinking-bubble {
    position: absolute;
    top: -18px;
    right: -14px;
    min-width: 42px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid rgba(249, 219, 152, 0.9);
    background: linear-gradient(160deg, #3d5161, #2a3a47);
    box-shadow: 0 6px 16px rgba(6, 14, 20, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(2px) scale(0.94);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 3;
}

.ai-thinking-bubble::after {
    content: "";
    position: absolute;
    left: 8px;
    bottom: -4px;
    width: 8px;
    height: 8px;
    border-left: 1px solid rgba(249, 219, 152, 0.9);
    border-bottom: 1px solid rgba(249, 219, 152, 0.9);
    background: #2a3a47;
    transform: rotate(-35deg);
}

.ai-thinking-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: thinkingFloat 1.2s ease-in-out infinite;
}

.ai-thinking-text {
    font-size: 0.88rem;
    letter-spacing: 0.08em;
    line-height: 1;
    color: #fff5dd;
    font-weight: 800;
    min-width: 18px;
    text-align: center;
    text-shadow: 0 0 8px rgba(255, 219, 147, 0.4);
}

@keyframes thinkingFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-1px) scale(1); }
}

.avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center top;
}

.avatar i {
    font-size: 1.2rem;
    margin-bottom: 4px;
    color: var(--quito-terracotta);
}

.chat-box {
    flex: 1;
    border: 1px solid rgba(255, 238, 208, 0.52);
    border-radius: 14px;
    background: linear-gradient(180deg, #fffdf8, #fff7e8);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 8px 18px rgba(20, 28, 24, 0.16);
}

.chat-name {
    font-weight: 800;
    color: var(--quito-stone);
    font-size: 0.88rem;
    display: flex;
    justify-content: space-between;
}

.chat-timestamp {
    font-size: 0.65rem;
    color: #777;
}

.speech-bubble {
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.5;
    color: #233544;
    font-style: normal;
    opacity: 0.78;
    transform: translateY(1px) scale(0.99);
    transform-origin: left center;
}

.speech-bubble.mood-taunt,
.speech-bubble.mood-smug,
.speech-bubble.mood-rage {
    color: #8b2f1d;
}

.speech-bubble.mood-hurt {
    color: #344b63;
}

.speech-bubble.mood-neutral {
    color: #233544;
}

.speech-bubble.show {
    animation: speechIn 0.28s cubic-bezier(0.2, 0.75, 0.2, 1) both;
    opacity: 1;
}

.speech-bubble.exiting {
    animation: speechOut 0.26s ease-in forwards;
}

@keyframes speechIn {
    0% {
        opacity: 0;
        transform: translateY(7px) scale(0.96);
        filter: saturate(0.8);
    }
    65% {
        opacity: 1;
        transform: translateY(-1px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: saturate(1);
    }
}

@keyframes speechOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0.72;
        transform: translateY(3px) scale(0.985);
    }
}

.ai-thinking {
    display: none;
    font-size: 0.75rem;
    color: #6e4d1f;
    font-weight: 700;
}

.ai-thinking.show {
    display: inline-block;
}

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.opponent-hand-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 32px;
    padding-left: 0;
}

.opponent-hand-mini .card {
    width: 18px;
    height: 28px;
    border-radius: 5px;
    border-width: 1px;
    padding: 1px;
    font-size: 0.42rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: default;
    pointer-events: none;
    opacity: 0.88;
    filter: saturate(0.82);
}

.opponent-hand-mini .card + .card {
    margin-left: -12px;
}

.opponent-hand-mini .card.back::after {
    content: none;
}

.table-zone {
    flex: 1;
    border: 1px solid rgba(255, 238, 204, 0.26);
    border-radius: 20px;
    background:
        radial-gradient(circle at 50% 42%, rgba(54, 142, 93, 0.54), rgba(28, 106, 69, 0.35) 42%, rgba(15, 77, 51, 0.82) 100%),
        linear-gradient(155deg, var(--felt-soft), var(--felt-mid) 48%, var(--felt-dark));
    padding: 20px 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: inset 0 0 0 1px rgba(255, 232, 191, 0.16), inset 0 0 26px rgba(0, 0, 0, 0.24);
    position: relative;
    overflow: visible;
}

.table-zone::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.08), transparent 55%);
    pointer-events: none;
    z-index: 0;
}

.table-zone::after {
    content: none;
}

.table-label {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 33, 22, 0.76);
    color: #f9e7c2;
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    z-index: 3;
}

.cards-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.capture-pile {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

.capture-pile.ai {
    top: 10px;
    right: 12px;
}

.capture-pile.player {
    bottom: 10px;
    left: 12px;
}

.capture-stack {
    position: relative;
    width: 22px;
    height: 30px;
}

.capture-mini-card {
    position: absolute;
    inset: 0;
    border-radius: 4px;
    border: 1px solid #77211f;
    background:
        radial-gradient(circle at 50% 52%, rgba(255, 228, 210, 0.18), transparent 54%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.09) 0 4px, transparent 4px 8px),
        linear-gradient(145deg, #9c1f24, #c73a3f 45%, #7a1116);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
    transform-origin: center;
}

.capture-pile.ai .capture-mini-card:nth-child(odd) {
    transform: translate(-1px, -1px) rotate(5deg);
}

.capture-pile.ai .capture-mini-card:nth-child(even) {
    transform: translate(1px, 1px) rotate(-4deg);
}

.capture-pile.player .capture-mini-card:nth-child(odd) {
    transform: translate(-1px, 1px) rotate(-5deg);
}

.capture-pile.player .capture-mini-card:nth-child(even) {
    transform: translate(1px, -1px) rotate(4deg);
}

.capture-mini-card:nth-child(1) { z-index: 1; }
.capture-mini-card:nth-child(2) { z-index: 2; }
.capture-mini-card:nth-child(3) { z-index: 3; }
.capture-mini-card:nth-child(4) { z-index: 4; }
.capture-mini-card:nth-child(5) { z-index: 5; }
.capture-mini-card:nth-child(6) { z-index: 6; }
.capture-mini-card:nth-child(7) { z-index: 7; }
.capture-mini-card:nth-child(8) { z-index: 8; }
.capture-mini-card:nth-child(9) { z-index: 9; }
.capture-mini-card:nth-child(10) { z-index: 10; }

.score-pile {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

.score-pile.ai {
    top: 10px;
    left: 12px;
    --stack-x: -1.6px;
    --stack-y: 1px;
}

.score-pile.player {
    bottom: 10px;
    right: 12px;
    --stack-x: 1.6px;
    --stack-y: -1px;
}

.score-stack {
    position: relative;
    width: 22px;
    height: 30px;
}

.score-piles-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.score-pile.ai .score-piles-wrap {
    flex-direction: row;
}

.score-pile.player .score-piles-wrap {
    flex-direction: row-reverse;
}

.score-stack.down-stack {
    width: 22px;
    height: 30px;
}

.score-stack.up-stack {
    width: 22px;
    height: 30px;
}

.score-mini-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 22px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #8f7a57;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.46rem;
    font-weight: 700;
    transform-origin: center;
    transform: translate(
        calc(var(--stack-index, 0) * var(--stack-x, 1px)),
        calc(var(--stack-index, 0) * var(--stack-y, 1px))
    );
}

.score-mini-card.up {
    border-color: #9f8a63;
    background:
        linear-gradient(180deg, #fffdf7 0%, #fff6e5 75%, #f2deba 100%);
    color: #384c5b;
}

.score-mini-card.up .score-mini-rank {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    line-height: 1;
    color: #2c3f4e;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.score-mini-card.up::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.36), transparent 45%);
    pointer-events: none;
}

.score-mini-card.down {
    background:
        radial-gradient(circle at 50% 52%, rgba(255, 228, 210, 0.18), transparent 54%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.09) 0 4px, transparent 4px 8px),
        linear-gradient(145deg, #9c1f24, #c73a3f 45%, #7a1116);
    border-color: #77211f;
}

.score-mini-card.tilt-left {
    transform: translate(
        calc(var(--stack-index, 0) * var(--stack-x, 1px)),
        calc(var(--stack-index, 0) * var(--stack-y, 1px))
    ) rotate(-5deg);
}

.score-mini-card.tilt-right {
    transform: translate(
        calc(var(--stack-index, 0) * var(--stack-x, 1px)),
        calc(var(--stack-index, 0) * var(--stack-y, 1px))
    ) rotate(4deg);
}

.score-mini-card:nth-child(1) { z-index: 1; }
.score-mini-card:nth-child(2) { z-index: 2; }
.score-mini-card:nth-child(3) { z-index: 3; }
.score-mini-card:nth-child(4) { z-index: 4; }
.score-mini-card:nth-child(5) { z-index: 5; }
.score-mini-card:nth-child(6) { z-index: 6; }
.score-mini-card:nth-child(7) { z-index: 7; }
.score-mini-card:nth-child(8) { z-index: 8; }
.score-mini-card:nth-child(9) { z-index: 9; }
.score-mini-card:nth-child(10) { z-index: 10; }
.score-mini-card:nth-child(11) { z-index: 11; }
.score-mini-card:nth-child(12) { z-index: 12; }
.score-mini-card:nth-child(13) { z-index: 13; }
.score-mini-card:nth-child(14) { z-index: 14; }
.score-mini-card:nth-child(15) { z-index: 15; }
.score-mini-card:nth-child(16) { z-index: 16; }
.score-mini-card:nth-child(17) { z-index: 17; }
.score-mini-card:nth-child(18) { z-index: 18; }
.score-mini-card:nth-child(19) { z-index: 19; }
.score-mini-card:nth-child(20) { z-index: 20; }

.card {
    width: clamp(58px, 16vw, 70px);
    aspect-ratio: 0.68;
    border-radius: var(--card-radius);
    border: 1px solid #9f8a63;
    background:
        linear-gradient(180deg, #fffdf7 0%, #fff6e5 75%, #f2deba 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    font-size: 1.08rem;
    color: #384c5b;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.24);
    flex-shrink: 0;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.22s ease, filter 0.22s ease;
    cursor: pointer;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.36), transparent 45%);
    pointer-events: none;
}

.card::after {
    content: "";
    position: absolute;
    left: 7px;
    right: 7px;
    bottom: 8px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(113, 88, 46, 0.45), transparent);
    pointer-events: none;
}

.card.back {
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 232, 215, 0.2), transparent 50%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 4px, transparent 4px 9px),
        linear-gradient(155deg, #8f1318, #be2e34 45%, #741015);
    border-color: #6f1215;
}

.card-rank-main {
    position: relative;
    font-size: clamp(2rem, 8vw, 2.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.card-suit-mark {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(113, 88, 46, 0.35);
    background: rgba(255, 245, 224, 0.7);
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    line-height: 1;
    opacity: 0.92;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}

.playable.capture {
    outline: 2px solid rgba(201, 154, 58, 0.65);
    outline-offset: 1px;
}

.card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 12px 18px rgba(0, 0, 0, 0.32);
    filter: saturate(1.08);
    z-index: 10;
}

.card.deal-in {
    animation: cardDealIn 0.22s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.player-hand {
    border-radius: 18px;
    background: transparent;
    box-shadow: none;
    min-height: 112px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hand-title {
    display: none;
}

.player-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    align-items: end;
}

.player-card {
    width: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.player-card:hover {
    transform: translateY(-8px);
    z-index: 20;
}

.player-card.selected {
    box-shadow: 0 12px 22px rgba(201, 154, 58, 0.52);
    border: 2px solid var(--quito-gold);
    transform: translateY(-10px) scale(1.02);
    z-index: 25;
}

.player-card.playable.capture {
    box-shadow: 0 0 0 2px rgba(201, 154, 58, 0.5), 0 0 18px var(--aura-gold);
}

.table-empty {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px dashed rgba(255, 236, 204, 0.44);
    background: radial-gradient(circle, rgba(255, 241, 213, 0.2), rgba(255, 241, 213, 0.02) 62%);
    opacity: 0.85;
}

.progress-mini {
    margin-top: 6px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

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

.fill {
    height: 100%;
    width: 0;
    transition: width 0.4s ease;
}

.fill.player {
    background: linear-gradient(90deg, #d6986d, #efba86);
}

.fill.ai {
    background: linear-gradient(90deg, #6e9fc8, #9cc3e2);
}

#stripFlash {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: rgba(180, 25, 25, 0.35);
    z-index: 990;
    transition: opacity 0.2s ease;
}

#stripFlash.flash {
    opacity: 1;
}

.result-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.game-window-shell {
    padding: 0;
    background:
        radial-gradient(circle at 10% 8%, rgba(247, 193, 91, 0.2), transparent 34%),
        radial-gradient(circle at 88% 82%, rgba(80, 135, 102, 0.22), transparent 36%),
        linear-gradient(165deg, rgba(6, 21, 14, 0.84), rgba(9, 30, 20, 0.88));
    backdrop-filter: blur(4px);
}

.game-window {
    position: relative;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    color: #f8f0dd;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 42%, rgba(56, 147, 96, 0.44), rgba(21, 85, 55, 0.35) 46%, rgba(10, 46, 30, 0.88) 100%),
        linear-gradient(160deg, var(--felt-soft) 0%, var(--felt-mid) 50%, var(--felt-dark) 100%);
    animation: windowEnter 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.game-window::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 8%, rgba(255, 244, 218, 0.09), transparent 48%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 12px);
    pointer-events: none;
}

.game-window::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 18px;
    border: 1px solid rgba(255, 231, 183, 0.2);
    pointer-events: none;
}

.window-glow {
    position: absolute;
    inset: auto -20% -30% auto;
    width: 70vw;
    max-width: 460px;
    aspect-ratio: 1 / 1;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255, 198, 87, 0.3), rgba(255, 198, 87, 0.02) 68%);
    filter: blur(6px);
    pointer-events: none;
}

.window-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(env(safe-area-inset-top) + 12px) 16px 14px;
    border-bottom: 1px solid rgba(244, 219, 168, 0.3);
    background:
        radial-gradient(circle at 12% 10%, rgba(255, 226, 171, 0.2), transparent 42%),
        linear-gradient(180deg, rgba(9, 40, 26, 0.92), rgba(11, 34, 23, 0.56));
    position: relative;
    z-index: 2;
}

.window-chip {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffcd68;
    box-shadow: 0 0 10px rgba(255, 205, 104, 0.45);
}

.window-chip:nth-child(2) {
    background: #f39f6e;
}

.window-chip:nth-child(3) {
    background: #6bb4e5;
}

.window-title {
    margin-left: 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 236, 204, 0.94);
}

.window-content {
    min-height: calc(100dvh - 110px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px calc(env(safe-area-inset-bottom) + 30px);
    gap: 14px;
    position: relative;
    z-index: 2;
}

.window-kicker {
    font-size: 0.74rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 222, 171, 0.86);
    font-weight: 700;
}

.window-content h2 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 2.8rem);
    line-height: 0.95;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #fff0d0;
    text-shadow: 0 6px 24px rgba(10, 26, 39, 0.58);
}

.window-description {
    color: rgba(244, 236, 218, 0.93);
    line-height: 1.48;
    font-size: 0.93rem;
    max-width: 28ch;
}

.welcome-window-content {
    position: relative;
}

.welcome-window-content::after {
    content: "";
    position: absolute;
    right: -72px;
    top: 16%;
    width: 208px;
    height: 208px;
    border-radius: 20px;
    border: 1px solid rgba(255, 217, 151, 0.24);
    transform: rotate(15deg);
    background: linear-gradient(145deg, rgba(255, 228, 169, 0.26), rgba(255, 228, 169, 0.02));
}

.window-primary-btn {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #f3be58, #dd9e2f);
    color: #2a1c06;
    box-shadow: 0 9px 24px rgba(12, 24, 17, 0.42);
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.window-primary-btn:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
}

.window-primary-btn:active {
    transform: translateY(1px);
}

.register-window-content {
    justify-content: flex-start;
    padding-top: clamp(72px, 20dvh, 130px);
}

.register-window-content h2 {
    font-size: clamp(1.4rem, 5.8vw, 2rem);
    line-height: 1.04;
}

.register-window-content .field {
    gap: 8px;
    margin-top: 8px;
}

.register-window-content .field label {
    color: rgba(255, 233, 193, 0.95);
    font-size: 0.78rem;
}

.register-window-content .field input {
    border: 1px solid rgba(255, 220, 160, 0.5);
    border-radius: 12px;
    padding: 12px;
    font-size: 0.94rem;
    background: rgba(8, 27, 18, 0.46);
    color: #fff1d2;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.register-window-content .field input::placeholder {
    color: rgba(255, 228, 173, 0.62);
}

.register-actions {
    margin-top: 12px;
    justify-content: stretch;
}

.dealer-flow-content {
    justify-content: flex-start;
    padding-top: clamp(22px, 6dvh, 52px);
    gap: 12px;
}

.dealer-flow-result-card,
.dealer-flow-shuffle-card,
.dealer-flow-cut-card {
    border: 1px solid rgba(255, 224, 172, 0.25);
    border-radius: 16px;
    background: linear-gradient(165deg, rgba(8, 29, 19, 0.72), rgba(15, 42, 29, 0.5));
    padding: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dealer-flow-result-card h2 {
    margin-top: 4px;
    color: #fce6ba;
    font-size: clamp(1.5rem, 6vw, 2.1rem);
    line-height: 1.02;
}

.dealer-flow-summary {
    margin-top: 6px;
    color: rgba(242, 234, 217, 0.95);
    line-height: 1.42;
    font-size: 0.92rem;
}

.dealer-flow-dealer-badge {
    display: inline-flex;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 226, 173, 0.34);
    background: linear-gradient(180deg, #f6c76a, #dea03a);
    color: #1f1808;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.dealer-flow-shuffle-head,
.dealer-flow-cut-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.dealer-flow-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(252, 223, 169, 0.9);
    font-weight: 700;
}

.dealer-flow-shuffle-head h3 {
    margin-top: 2px;
    font-size: 1rem;
    color: #f8e8c6;
    line-height: 1.3;
}

.dealer-flow-count-badge {
    min-width: 80px;
    padding: 8px 10px;
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(10, 30, 21, 0.92), rgba(13, 37, 26, 0.76));
    border: 1px solid rgba(255, 223, 164, 0.28);
    text-align: center;
}

.dealer-flow-count-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(250, 224, 172, 0.9);
    margin-bottom: 4px;
}

.dealer-flow-count-badge strong,
.dealer-flow-cut-head strong {
    font-family: var(--font-display);
    font-size: 2rem;
    line-height: 1;
    color: #fce8bc;
}

.dealer-flow-note {
    margin-top: 8px;
    color: rgba(241, 233, 214, 0.96);
    line-height: 1.42;
    font-size: 0.88rem;
}

.dealer-flow-stage {
    margin-top: 12px;
}

.dealer-flow-deck-stack {
    position: relative;
    width: min(200px, 48vw);
    height: 130px;
    display: grid;
    place-items: center;
}

.dealer-flow-deck-card {
    position: absolute;
    width: clamp(62px, 16vw, 78px);
    aspect-ratio: 0.68;
    cursor: default;
    pointer-events: none;
}

.dealer-flow-deck-card-1 {
    transform: translateX(-18px) rotate(-10deg);
}

.dealer-flow-deck-card-2 {
    transform: translateX(16px) rotate(8deg);
}

.dealer-flow-deck-card-3 {
    transform: translateY(-4px) rotate(-1deg);
}

.dealer-flow-deck-card::before {
    border-radius: inherit;
}

.dealer-flow-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.dealer-flow-status-pill {
    border: 1px solid rgba(255, 225, 168, 0.24);
    border-radius: 999px;
    background: rgba(9, 31, 22, 0.72);
    color: rgba(252, 229, 182, 0.95);
    font-size: 0.72rem;
    line-height: 1.2;
    padding: 6px 10px;
}

.dealer-flow-actions {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#dealerFlowStartBtn {
    grid-column: 1 / -1;
    width: 100%;
}

.dealer-flow-cut-card {
    display: grid;
    gap: 10px;
}

.dealer-flow-cut-head strong {
    font-size: 1.2rem;
    padding-top: 10px;
}

#dealerFlowMsg {
    color: rgba(242, 234, 217, 0.95);
    line-height: 1.4;
    font-size: 0.88rem;
    max-width: none;
}

.pregame-rival-panel {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 10px;
    border: 1px solid rgba(255, 224, 172, 0.25);
    border-radius: 16px;
    background: linear-gradient(165deg, rgba(8, 29, 19, 0.7), rgba(15, 42, 29, 0.5));
    padding: 10px;
}

.pregame-rival-panel img {
    width: 78px;
    height: 92px;
    border-radius: 12px;
    object-fit: cover;
    object-position: center top;
    border: 1px solid rgba(255, 226, 173, 0.36);
}

.pregame-rival-meta h3 {
    margin-top: 2px;
    font-size: 1rem;
    color: #fee7ba;
}

.pregame-rival-title {
    color: rgba(228, 240, 253, 0.9);
    font-size: 0.78rem;
}

.pregame-rival-style {
    margin-top: 4px;
    color: #f3be58;
    font-size: 0.78rem;
    font-weight: 700;
}

.pregame-rival-tip {
    color: rgba(241, 231, 210, 0.9);
    font-size: 0.75rem;
}

.high-card-stage {
    border: 1px solid rgba(255, 224, 172, 0.24);
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(7, 26, 18, 0.66), rgba(13, 39, 27, 0.45));
    padding: 12px;
    display: grid;
    gap: 10px;
}

.cut-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fce2af;
    font-size: 0.82rem;
    font-weight: 700;
}

#dealerCutPercentInput,
#dealerFlowCutInput {
    width: 100%;
    accent-color: #f1b84f;
}

.duel-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.duel-card {
    min-height: 166px;
    border-radius: 12px;
    border: 1px solid rgba(255, 226, 174, 0.32);
    background: linear-gradient(170deg, rgba(15, 38, 26, 0.9), rgba(11, 30, 21, 0.95));
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    transform: perspective(700px) rotateY(180deg);
    transition: transform 0.48s ease, box-shadow 0.22s ease;
}

.duel-card.revealed {
    transform: perspective(700px) rotateY(0deg);
    box-shadow: 0 10px 20px rgba(2, 8, 13, 0.4);
}

.duel-card.ai.revealed {
    box-shadow: 0 0 0 1px rgba(108, 183, 231, 0.42), 0 10px 20px rgba(2, 8, 13, 0.4);
}

.duel-card-label {
    font-size: 0.75rem;
    color: rgba(238, 232, 222, 0.9);
    letter-spacing: 0.03em;
}

.duel-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.duel-card-percent {
    font-size: 0.7rem;
    font-weight: 800;
    color: #1f1808;
    background: linear-gradient(180deg, #f6c76a, #dea03a);
    border: 1px solid rgba(252, 211, 125, 0.95);
    border-radius: 999px;
    padding: 2px 8px;
}

.duel-card-slot {
    display: grid;
    place-items: center;
    flex: 1;
}

.duel-reveal-card {
    width: clamp(68px, 19vw, 78px);
}

.duel-card-placeholder {
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 232, 215, 0.2), transparent 50%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 4px, transparent 4px 9px),
        linear-gradient(155deg, #8f1318, #be2e34 45%, #741015);
    border-color: #6f1215;
}

.duel-card-placeholder::after {
    content: "";
}

.shuffle-stage {
    position: relative;
    height: 96px;
    border-radius: 14px;
    border: 1px solid rgba(255, 223, 164, 0.26);
    background: linear-gradient(160deg, rgba(8, 28, 19, 0.8), rgba(13, 37, 26, 0.58));
    overflow: hidden;
    display: grid;
    place-items: center;
}

.shuffle-trail {
    position: absolute;
    inset: auto 8% 16px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(246, 199, 106, 0), rgba(246, 199, 106, 0.55), rgba(246, 199, 106, 0));
    filter: blur(2px);
    opacity: 0;
}

.shuffle-stage.shuffling .dealer-flow-deck-card-1 {
    animation: deckShuffleLeft 280ms ease-in-out var(--shuffle-loops, 1);
}

.shuffle-stage.shuffling .dealer-flow-deck-card-2 {
    animation: deckShuffleRight 280ms ease-in-out var(--shuffle-loops, 1);
}

.shuffle-stage.shuffling .dealer-flow-deck-card-3 {
    animation: deckShuffleCenter 280ms ease-in-out var(--shuffle-loops, 1);
}

.shuffle-stage.shuffling .shuffle-trail {
    animation: shuffleTrail 280ms ease-in-out var(--shuffle-loops, 1);
}

.cut-visual {
    position: relative;
    height: 86px;
    border-radius: 12px;
    border: 1px solid rgba(255, 222, 167, 0.28);
    background: linear-gradient(165deg, rgba(8, 27, 18, 0.72), rgba(11, 35, 24, 0.58));
    overflow: hidden;
}

.cut-visual-top,
.cut-visual-bottom {
    position: absolute;
    inset: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 228, 179, 0.28);
    background: linear-gradient(145deg, rgba(240, 186, 74, 0.3), rgba(90, 152, 196, 0.25));
}

.cut-visual-top {
    top: 10px;
    bottom: 42px;
}

.cut-visual-bottom {
    top: 42px;
    bottom: 10px;
}

.cut-visual-line {
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 50%;
    width: 3px;
    border-radius: 999px;
    transform: translateX(-50%);
    background: #f6c76a;
    box-shadow: 0 0 12px rgba(246, 199, 106, 0.58);
    transition: left 0.18s ease;
}

.ritual-finish-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background:
        radial-gradient(circle at 50% 52%, rgba(252, 206, 117, 0.38), transparent 48%),
        radial-gradient(circle at 50% 50%, rgba(111, 181, 228, 0.25), transparent 62%);
}

#dealerFlowModal.ritual-finishing #dealerFlowFinishOverlay {
    animation: ritualFlash 620ms ease-out;
}

.tournament-window-content {
    justify-content: flex-start;
    padding-top: clamp(36px, 9dvh, 72px);
}

.tournament-window-content h2 {
    font-size: clamp(1.8rem, 7.2vw, 2.4rem);
}

.game-window-panel-content {
    justify-content: flex-start;
    padding-top: clamp(28px, 8dvh, 56px);
}

.game-window-panel {
    width: 100%;
    background: linear-gradient(170deg, rgba(7, 28, 19, 0.68), rgba(12, 35, 24, 0.5));
    border: 1px solid rgba(255, 220, 160, 0.28);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 14px 30px rgba(2, 10, 16, 0.32);
    backdrop-filter: blur(4px);
}

.game-window-panel h3 {
    color: #fce6ba;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.game-window-panel ul {
    padding-left: 16px;
    display: grid;
    gap: 6px;
    color: rgba(255, 238, 204, 0.95);
    font-size: 0.86rem;
    line-height: 1.35;
}

.game-window-panel .rules-actions {
    margin-top: 14px;
}

.result-window-panel {
    margin-top: clamp(18px, 6dvh, 64px);
}

.result-window-panel .result-title {
    color: #fce6ba;
}

.result-window-panel .result-msg {
    color: rgba(255, 239, 207, 0.94);
}

.result-window-panel.is-match-summary {
    border-color: rgba(255, 227, 171, 0.45);
    background: linear-gradient(160deg, rgba(7, 35, 24, 0.8), rgba(12, 42, 28, 0.62));
}

.result-window-panel.is-match-summary.is-loss {
    border-color: rgba(204, 197, 181, 0.3);
    background: linear-gradient(160deg, rgba(9, 22, 17, 0.82), rgba(14, 30, 24, 0.66));
}

.result-window-panel.is-match-summary .result-msg {
    white-space: normal;
    margin-top: 2px;
}

.match-summary {
    display: grid;
    gap: 12px;
}

.match-summary-head {
    display: grid;
    gap: 4px;
}

.match-summary-kicker {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 224, 170, 0.9);
    font-weight: 700;
}

.match-summary.is-loss .match-summary-kicker {
    color: rgba(224, 219, 206, 0.75);
}

.match-summary-body {
    display: grid;
    gap: 10px;
}

.match-score-line {
    color: #fff0cf;
    font-size: 0.95rem;
    line-height: 1.42;
}

.match-summary.is-loss .match-score-line {
    color: rgba(231, 227, 215, 0.9);
}

.series-track {
    display: grid;
    gap: 8px;
    border: 1px solid rgba(255, 224, 172, 0.26);
    border-radius: 14px;
    background: linear-gradient(150deg, rgba(255, 229, 178, 0.08), rgba(79, 153, 114, 0.12));
    padding: 10px;
}

.match-summary.is-loss .series-track {
    border-color: rgba(223, 215, 197, 0.22);
    background: linear-gradient(150deg, rgba(220, 214, 197, 0.08), rgba(91, 114, 101, 0.12));
}

.series-track-label {
    font-size: 0.73rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 228, 177, 0.92);
    font-weight: 700;
}

.match-summary.is-loss .series-track-label {
    color: rgba(228, 222, 210, 0.82);
}

.series-pips {
    display: flex;
    gap: 8px;
    align-items: center;
}

.series-pip {
    width: 28px;
    height: 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 225, 169, 0.34);
    background: rgba(14, 39, 28, 0.7);
}

.series-pip.win {
    background: linear-gradient(180deg, #f5c768, #e0a33b);
    border-color: rgba(255, 222, 157, 0.75);
    box-shadow: 0 0 8px rgba(243, 190, 88, 0.32);
}

.series-pip.lose {
    background: linear-gradient(180deg, #b8b1a0, #938b78);
    border-color: rgba(214, 207, 192, 0.6);
}

.series-scoreline {
    color: rgba(245, 236, 219, 0.95);
    font-size: 0.86rem;
    line-height: 1.35;
}

.match-reward {
    border: 1px solid rgba(255, 225, 163, 0.34);
    border-radius: 12px;
    padding: 10px;
    background: linear-gradient(160deg, rgba(243, 194, 94, 0.2), rgba(84, 145, 107, 0.18));
}

.reward-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255, 227, 175, 0.9);
    margin-bottom: 4px;
}

.reward-value {
    color: #fff4da;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.35;
}

.match-next {
    color: rgba(244, 235, 217, 0.92);
    font-size: 0.84rem;
    line-height: 1.38;
}

.result-card {
    width: min(420px, 100%);
    background: #fff7e6;
    border: 2px solid #9f8a63;
    border-radius: 16px;
    padding: 14px;
    box-shadow: var(--shadow-xl);
    color: var(--quito-ink);
}

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

.result-icon {
    font-size: 1.4rem;
}

.result-title {
    font-weight: 800;
    letter-spacing: 0.04em;
}

.result-msg {
    white-space: pre-line;
    line-height: 1.35;
    margin-bottom: 12px;
}

.tournament-list {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.bracket-pair {
    border: 1px solid rgba(255, 223, 166, 0.28);
    border-radius: 12px;
    background: linear-gradient(150deg, rgba(255, 232, 179, 0.16), rgba(95, 173, 124, 0.12));
    padding: 8px 10px;
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    gap: 6px;
    align-items: center;
    font-size: 0.8rem;
}

.bracket-key {
    font-weight: 700;
    color: rgba(255, 225, 170, 0.94);
    padding-right: 4px;
}

.bracket-vs {
    font-weight: 700;
    color: rgba(243, 187, 83, 0.95);
    text-align: center;
}

.bracket-name {
    color: rgba(242, 235, 222, 0.96);
    white-space: normal;
}

.table-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background:
        radial-gradient(circle at 12% 10%, rgba(247, 193, 91, 0.2), transparent 38%),
        radial-gradient(circle at 90% 86%, rgba(80, 135, 102, 0.2), transparent 36%),
        rgba(0, 0, 0, 0.55);
    z-index: 995;
}

.table-modal.open {
    display: flex;
}

.table-card {
    width: min(460px, 100%);
    background:
        radial-gradient(circle at 50% 38%, rgba(56, 147, 96, 0.42), rgba(21, 85, 55, 0.32) 48%, rgba(10, 46, 30, 0.9) 100%),
        linear-gradient(160deg, var(--felt-soft) 0%, var(--felt-mid) 50%, var(--felt-dark) 100%);
    border: 1px solid rgba(255, 230, 180, 0.28);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 20px 34px rgba(2, 12, 8, 0.46), inset 0 0 0 1px rgba(255, 236, 203, 0.16);
    color: #f7edd9;
    position: relative;
    overflow: hidden;
}

.table-card::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 13px;
    border: 1px solid rgba(255, 231, 183, 0.2);
    pointer-events: none;
}

.table-card h3 {
    margin-bottom: 12px;
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fbe6ba;
    position: relative;
    z-index: 1;
}

.table-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.table-pill {
    border: 1px solid rgba(255, 226, 173, 0.3);
    border-radius: 10px;
    background: linear-gradient(165deg, rgba(8, 29, 19, 0.72), rgba(13, 39, 27, 0.5));
    padding: 6px 8px;
    font-size: 0.8rem;
    line-height: 1.35;
    color: rgba(247, 238, 219, 0.95);
    position: relative;
    z-index: 1;
}

.dealer-cut-note,
.dealer-cut-result {
    border: 1px solid rgba(255, 226, 173, 0.3);
    border-radius: 8px;
    background: linear-gradient(165deg, rgba(8, 29, 19, 0.72), rgba(13, 39, 27, 0.5));
    color: rgba(247, 238, 219, 0.95);
    font-size: 0.8rem;
    line-height: 1.35;
    padding: 8px;
}

#dealerFlowShuffleBtn {
    background: linear-gradient(180deg, #4a6276, #324656);
    border-color: #263744;
    color: #f7edd8;
    box-shadow: 0 4px 10px rgba(23, 35, 44, 0.28);
}

#dealerFlowShuffleBtn:hover {
    background: linear-gradient(180deg, #587489, #3a5162);
}

.field {
    display: grid;
    gap: 4px;
}

.field label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #3a4b57;
}

.field input,
.field select {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #b7a378;
    background: #fffef9;
    font-size: 16px;
}

.bottom-actions {
    width: min(320px, calc(100vw - 24px));
    border: 2px solid var(--line);
    border-radius: 18px;
    background:
        radial-gradient(circle at 15% 18%, rgba(255, 255, 255, 0.12), transparent 35%),
        linear-gradient(160deg, #2a3946, #1f2b35);
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    box-shadow: var(--shadow-xl);
    position: fixed;
    top: calc(env(safe-area-inset-top) + 76px);
    right: 12px;
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.bottom-actions.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.action-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #f8ecd4;
    padding: 12px 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.action-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 14px rgba(0, 0, 0, 0.18);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn.primary {
    background: linear-gradient(180deg, var(--quito-gold), #a97f27);
    border-color: #d7b062;
    color: #222;
    box-shadow: 0 4px 0 #8a6520, 0 8px 12px rgba(0, 0, 0, 0.24);
}

.action-btn.primary:active {
    transform: translateY(4px);
    box-shadow: none;
}

.action-btn i {
    font-size: 1.2rem;
}

.rules-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 999;
}

.rules-modal.open {
    display: flex;
}

.rules-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

#tournamentStartBtn {
    padding-inline: 20px;
}

@keyframes pulseGlow {
    0% { opacity: 1; }
    50% { opacity: 0.72; transform: scale(1.05); }
    100% { opacity: 1; }
}

@keyframes cardDealIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.94);
    }
    70% {
        opacity: 1;
        transform: translateY(1px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes windowEnter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes deckShuffleLeft {
    0% { transform: translateX(-8px) rotate(-8deg); }
    50% { transform: translateX(-22px) rotate(-16deg); }
    100% { transform: translateX(-8px) rotate(-8deg); }
}

@keyframes deckShuffleRight {
    0% { transform: translateX(8px) rotate(7deg); }
    50% { transform: translateX(22px) rotate(15deg); }
    100% { transform: translateX(8px) rotate(7deg); }
}

@keyframes deckShuffleCenter {
    0% { transform: rotate(-1deg) scale(1); }
    50% { transform: rotate(2deg) scale(1.05); }
    100% { transform: rotate(-1deg) scale(1); }
}

@keyframes shuffleTrail {
    0% { opacity: 0; transform: translateX(-16px); }
    50% { opacity: 0.9; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(16px); }
}

@keyframes ritualFlash {
    0% { opacity: 0; }
    35% { opacity: 0.88; }
    100% { opacity: 0; }
}

/* ===================================
   TABLET LAYOUT (768px+)
   =================================== */
@media (min-width: 768px) {
    .app {
        max-width: 900px;
        gap: 14px;
        padding: 16px;
    }

    .header {
        padding: 14px;
        margin-bottom: 18px;
        gap: 10px;
    }

    .title {
        font-size: 2.4rem;
    }

    .city-tag {
        font-size: 0.84rem;
        padding: 4px 10px;
    }

    .status-strip {
        padding: 10px 14px;
        font-size: 1.02rem;
    }

    .opponent-chat {
        gap: 16px;
    }

    .opponent-side {
        flex: 0 0 90px;
        gap: 8px;
    }

    .avatar {
        width: 88px;
        height: 88px;
        min-width: 88px;
        border-width: 2px;
    }

    .chat-box {
        padding: 16px;
        gap: 8px;
    }

    .chat-name {
        font-size: 1.02rem;
    }

    .speech-bubble {
        font-size: 1.2rem;
    }

    .card {
        width: clamp(70px, 12vw, 90px);
        font-size: 1.24rem;
    }

    .card-rank-main {
        font-size: clamp(2.2rem, 7vw, 2.8rem);
    }

    .player-cards {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 8px;
    }

    .table-zone {
        padding: 24px 16px;
        gap: 16px;
        border-radius: 24px;
    }

    .table-label {
        font-size: 0.84rem;
    }

    .cards-row {
        gap: 14px;
    }

    .opponent-hand-mini .card {
        width: 22px;
        height: 34px;
    }

    .opponent-hand-mini .card + .card {
        margin-left: -16px;
    }

    .bottom-actions {
        width: min(400px, calc(100vw - 40px));
        grid-template-columns: repeat(3, 1fr);
        top: calc(env(safe-area-inset-top) + 100px);
    }

    .game-area {
        gap: 14px;
    }

    /* Modals for tablet */
    .result-card {
        width: min(500px, 90vw);
    }

    .table-card {
        width: min(550px, 90vw);
    }

    .game-window {
        max-width: 800px;
        margin: 0 auto;
    }

    .window-content {
        padding: 32px 28px calc(env(safe-area-inset-bottom) + 40px);
    }

    .window-content h2 {
        font-size: clamp(2.2rem, 9vw, 3.2rem);
    }

    .window-description {
        font-size: 1.04rem;
        max-width: 36ch;
    }

    .dealer-flow-deck-card {
        width: clamp(78px, 14vw, 98px);
    }

    .duel-reveal-card {
        width: clamp(78px, 17vw, 96px);
    }

    .pregame-rival-panel {
        grid-template-columns: 100px 1fr;
        gap: 14px;
    }

    .pregame-rival-panel img {
        width: 100px;
        height: 120px;
    }
}

/* ===================================
   DESKTOP LAYOUT (1024px+)
   =================================== */
@media (min-width: 1024px) {
    .app {
        max-width: 1280px;
        gap: 18px;
        padding: 24px;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .header {
        grid-column: 1 / -1;
        padding: 18px;
        margin-bottom: 0;
        gap: 12px;
    }

    .title {
        font-size: 2.8rem;
    }

    .city-tag {
        font-size: 0.9rem;
        padding: 5px 12px;
    }

    .status-strip {
        padding: 12px 18px;
        font-size: 1.1rem;
        gap: 24px;
    }

    .opponent-chat {
        grid-column: 1;
        grid-row: 2;
        gap: 20px;
    }

    .opponent-side {
        flex: 0 0 110px;
        gap: 10px;
    }

    .avatar {
        width: 110px;
        height: 110px;
        min-width: 110px;
        border-width: 3px;
    }

    .chat-box {
        padding: 20px;
        gap: 10px;
        border-radius: 16px;
    }

    .chat-name {
        font-size: 1.12rem;
    }

    .speech-bubble {
        font-size: 1.32rem;
        line-height: 1.6;
    }

    .game-area {
        grid-column: 2;
        grid-row: 2;
        gap: 18px;
    }

    .player-hand {
        min-height: 150px;
        gap: 12px;
    }

    .hand-title {
        display: block;
        font-size: 0.9rem;
        font-weight: 600;
        color: rgba(0, 0, 0, 0.6);
        margin-bottom: 4px;
    }

    .player-cards {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 10px;
        align-items: flex-end;
    }

    .card {
        width: clamp(85px, 10vw, 110px);
        font-size: 1.4rem;
    }

    .card-rank-main {
        font-size: clamp(2.6rem, 6.5vw, 3.2rem);
    }

    .card-suit-mark {
        width: 24px;
        height: 24px;
        font-size: 1.3rem;
    }

    .table-zone {
        grid-column: 1 / -1;
        grid-row: 3;
        padding: 32px;
        gap: 20px;
        border-radius: 28px;
        min-height: 280px;
    }

    .table-label {
        font-size: 0.96rem;
        padding: 6px 16px;
    }

    .cards-row {
        gap: 18px;
    }

    .table-empty {
        width: 42px;
        height: 42px;
    }

    .bottom-actions {
        position: fixed;
        bottom: 24px;
        top: auto;
        right: 24px;
        width: min(480px, calc(100vw - 64px));
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        padding: 12px;
    }

    .action-btn {
        padding: 14px 6px;
        font-size: 0.84rem;
        gap: 6px;
    }

    .action-btn i {
        font-size: 1.4rem;
    }

    /* Desktop modals */
    .result-card {
        width: min(600px, 85vw);
        padding: 20px;
    }

    .result-head {
        gap: 14px;
        margin-bottom: 16px;
    }

    .result-icon {
        font-size: 1.8rem;
    }

    .result-title {
        font-size: 1.28rem;
    }

    .result-msg {
        font-size: 1.02rem;
    }

    .table-card {
        width: min(680px, 85vw);
        padding: 20px;
    }

    .table-card h3 {
        margin-bottom: 16px;
        font-size: 1.6rem;
    }

    .table-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 12px;
        margin-bottom: 14px;
    }

    .table-pill {
        padding: 10px 12px;
        font-size: 0.92rem;
    }

    .game-window {
        max-width: 900px;
        margin: 0 auto;
    }

    .window-header {
        padding: calc(env(safe-area-inset-top) + 16px) 24px 18px;
    }

    .window-content {
        min-height: calc(100dvh - 140px);
        padding: 40px 36px calc(env(safe-area-inset-bottom) + 50px);
        gap: 18px;
    }

    .window-content h2 {
        font-size: clamp(2.6rem, 8vw, 3.8rem);
        margin-bottom: 8px;
    }

    .window-description {
        font-size: 1.12rem;
        max-width: 44ch;
        line-height: 1.6;
    }

    .window-primary-btn {
        width: auto;
        min-width: 200px;
        padding: 16px 24px;
        font-size: 1rem;
    }

    .register-window-content {
        padding-top: clamp(100px, 25dvh, 180px);
    }

    .register-window-content h2 {
        font-size: clamp(2rem, 6vw, 2.8rem);
    }

    .register-window-content .field input {
        font-size: 1.02rem;
        padding: 14px;
    }

    .dealer-flow-content {
        padding-top: clamp(40px, 8dvh, 80px);
        gap: 18px;
    }

    .dealer-flow-result-card,
    .dealer-flow-shuffle-card,
    .dealer-flow-cut-card {
        padding: 18px;
    }

    .dealer-flow-result-card h2 {
        font-size: clamp(1.8rem, 7vw, 2.6rem);
    }

    .dealer-flow-summary {
        font-size: 1.04rem;
    }

    .dealer-flow-deck-stack {
        width: min(260px, 52vw);
        height: 160px;
    }

    .dealer-flow-deck-card {
        width: clamp(98px, 13vw, 120px);
    }

    .dealer-flow-count-badge {
        min-width: 100px;
        padding: 10px 14px;
    }

    .dealer-flow-count-badge strong,
    .dealer-flow-cut-head strong {
        font-size: 2.4rem;
    }

    .duel-cards-row {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .duel-card {
        min-height: 200px;
        padding: 12px;
        gap: 10px;
    }

    .duel-card-label {
        font-size: 0.88rem;
    }

    .duel-reveal-card {
        width: clamp(98px, 15vw, 120px);
    }

    .shuffle-stage {
        height: 120px;
        border-radius: 18px;
    }

    .cut-visual {
        height: 110px;
    }

    .pregame-rival-panel {
        grid-template-columns: 130px 1fr;
        gap: 18px;
        padding: 14px;
    }

    .pregame-rival-panel img {
        width: 130px;
        height: 156px;
        border-radius: 14px;
    }

    .pregame-rival-meta h3 {
        font-size: 1.18rem;
    }

    .pregame-rival-title {
        font-size: 0.92rem;
    }

    .pregame-rival-style {
        font-size: 0.9rem;
    }

    .tournament-window-content {
        padding-top: clamp(60px, 12dvh, 100px);
    }

    .tournament-window-content h2 {
        font-size: clamp(2.2rem, 8vw, 3.2rem);
    }

    .tournament-list {
        gap: 12px;
        margin-bottom: 18px;
    }

    .bracket-pair {
        padding: 12px 16px;
        font-size: 0.92rem;
    }

    .match-summary {
        gap: 16px;
    }

    .match-score-line {
        font-size: 1.08rem;
    }

    .series-track {
        gap: 12px;
        padding: 14px;
    }

    .series-pips {
        gap: 12px;
    }

    .series-pip {
        width: 36px;
        height: 12px;
    }

    .series-scoreline {
        font-size: 0.98rem;
    }

    .result-window-panel {
        margin-top: clamp(36px, 10dvh, 100px);
    }

    .game-window-panel {
        border-radius: 20px;
        padding: 20px;
        box-shadow: 0 16px 36px rgba(2, 10, 16, 0.36);
    }

    .game-window-panel h3 {
        font-size: 1.6rem;
        margin-bottom: 14px;
    }

    .game-window-panel ul {
        padding-left: 20px;
        font-size: 0.98rem;
    }

    .high-card-stage {
        padding: 16px;
        gap: 12px;
    }

    .cut-control-row {
        font-size: 0.94rem;
    }
}
