/* Twitchy Monkeys — Jungle theme with card face system */

:root {
    --game-primary: #4a7c2e;
    --game-surface: #1a2e1a;
    --game-bg: #0f1a0f;
}

/* ── Card type accent colors (shared by .tm-card and .tm-mini-card) ── */

[data-type="baby_monkey"]    { --card-accent: #e91e8f; }
[data-type="basic_monkey"]   { --card-accent: #4a7c2e; }
[data-type="magical_monkey"] { --card-accent: #3498db; }
[data-type="magic"]          { --card-accent: #2ecc71; }
[data-type="upgrade"]        { --card-accent: #f4a62a; }
[data-type="downgrade"]      { --card-accent: #c0392b; }
[data-type="instant"]        { --card-accent: #e67e22; }

/* ── Jungle background ── */

body.player-mode {
    background:
        repeating-linear-gradient(
            120deg,
            transparent,
            transparent 80px,
            rgba(74, 124, 46, 0.03) 80px,
            rgba(74, 124, 46, 0.03) 82px
        ),
        repeating-linear-gradient(
            60deg,
            transparent,
            transparent 120px,
            rgba(30, 80, 20, 0.02) 120px,
            rgba(30, 80, 20, 0.02) 122px
        ),
        linear-gradient(180deg, #0f1a0f 0%, #162816 40%, #1a2e1a 60%, #0f1a0f 100%);
}

/* ── Game screen layout ── */

#game-screen.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.tm-board-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 120px;
}

/* ── Status bar ── */

.tm-status-bar {
    padding: 10px 12px;
    background: var(--game-surface);
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--game-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Card face ── */

.tm-card {
    display: flex;
    flex-direction: column;
    min-width: 90px;
    max-width: 120px;
    border-radius: 10px;
    border: 2px solid var(--card-accent, #555);
    background: linear-gradient(
        160deg,
        color-mix(in srgb, var(--card-accent, #555) 18%, transparent),
        color-mix(in srgb, var(--card-accent, #555) 5%, transparent)
    );
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow: hidden;
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tm-card-art {
    text-align: center;
    font-size: 1.8rem;
    padding: 8px 4px 4px;
    line-height: 1;
}

.tm-card-nameplate {
    padding: 4px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tm-card-name {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--game-text, #eee);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tm-card-type {
    font-size: 0.6rem;
    color: var(--card-accent, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.tm-card-text {
    padding: 2px 8px 6px;
    font-size: 0.6rem;
    color: var(--game-text-muted, #aaa);
    line-height: 1.3;
}

/* ── Card context: Tableau (compact, hide effect text) ── */

.tableau-view-card .tm-card {
    animation: cardPop 0.2s ease-out;
}

.tableau-view-card .tm-card-text {
    display: none;
}

@keyframes cardPop {
    from { transform: scale(1.04); opacity: 0.8; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ── Card context: Zoom (larger, full detail) ── */

.card-zoom-card .tm-card {
    min-width: 220px;
    max-width: 280px;
    border-width: 3px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 20px color-mix(in srgb, var(--card-accent, #555) 25%, transparent);
}

.card-zoom-card .tm-card-art {
    font-size: 3rem;
    padding: 20px 8px 12px;
}

.card-zoom-card .tm-card-nameplate {
    padding: 8px 12px;
}

.card-zoom-card .tm-card-name {
    font-size: 1.1rem;
    white-space: normal;
}

.card-zoom-card .tm-card-type {
    font-size: 0.75rem;
    margin-top: 2px;
}

.card-zoom-card .tm-card-text {
    display: block;
    font-size: 0.85rem;
    padding: 6px 12px 14px;
    max-height: 120px;
    overflow-y: auto;
}

/* ── Card context: Hand (BottomSheet) ── */

.card-hand-card .tm-card {
    min-width: 95px;
    max-width: 115px;
}

.card-hand-card .tm-card-art {
    font-size: 1.5rem;
    padding: 6px 4px 2px;
}

/* ── Shared zones row ── */

.tm-shared-zones {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.85rem;
    color: var(--game-text-muted, #aaa);
}

.tm-zone-count {
    font-weight: 700;
    color: var(--game-text, #eee);
}

/* Action panel sits above bottom sheet peek, but sheet can slide over it */
.bottom-sheet-overlay {
    z-index: 110 !important;
}

.action-panel {
    bottom: 60px !important;
}

/* ── Mini-cards (opponent troops overview) ── */

.tm-mini-card {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid var(--card-accent, #555);
    color: var(--card-accent, #aaa);
    background: color-mix(in srgb, var(--card-accent, #555) 10%, transparent);
}

/* ── Opponent troops overview ── */

.tm-opponent-troops {
    padding: 6px 8px;
    overflow-y: auto;
    max-height: 30vh;
}

.tm-troop-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 4px;
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.tm-troop-row:active {
    background: rgba(74, 124, 46, 0.15);
}

.tm-troop-row.viewing {
    background: rgba(74, 124, 46, 0.1);
    outline: 1px solid rgba(74, 124, 46, 0.3);
}

.tm-troop-row + .tm-troop-row {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tm-troop-header {
    flex-shrink: 0;
    min-width: 70px;
    text-align: right;
    padding-top: 2px;
}

.tm-troop-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--game-text, #eee);
    line-height: 1.2;
}

.tm-troop-name.is-turn {
    color: var(--game-primary);
}

.tm-troop-count {
    font-size: 0.7rem;
    color: var(--game-text-muted, #aaa);
}

.tm-troop-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.tm-troop-empty {
    font-size: 0.7rem;
    color: var(--game-text-muted, #aaa);
    font-style: italic;
    padding: 2px 0;
}

/* Divider between own troop and opponent overview */
.tm-troops-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-size: 0.7rem;
    color: var(--game-text-muted, #aaa);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-troops-divider::before,
.tm-troops-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

/* ── Screech shake animation ── */

@keyframes screechShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(2px); }
}

#game-screen.screech-shake {
    animation: screechShake 0.25s ease-out;
}

/* ── Screech pulse for spotlight display ── */

@keyframes screechPulse {
    from { opacity: 1; }
    to   { opacity: 0.6; }
}

/* ── Win celebration — emoji rain ── */

@keyframes emojiRain {
    0% {
        transform: translateY(-60px) rotate(0deg);
        opacity: 1;
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.tm-celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.tm-confetti {
    position: absolute;
    top: -60px;
    font-size: 2rem;
    animation: emojiRain linear forwards;
}

/* ── Winner / Final ── */

.tm-winner {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #f4a62a;
    margin: 16px 0;
}

#playagain-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 20px auto;
    padding: 14px;
    font-size: 1.2em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: var(--game-primary);
    color: white;
}

#playagain-btn:hover { background: #5a9c3e; }
