/* TDPixi — mobile-first reskin for Telegram WebApp */

:root {
    --bg:        #1e1e22;
    --surface:   #2a2a30;
    --surface2:  #35353d;
    --text:      #e8e8ec;
    --muted:     #888890;
    --border:    #44444c;
    --btn-ok:    #2e7d4f;
    --btn-ok-fg: #a8f0c0;
    --btn-up:    #1a5f5f;
    --btn-up-fg: #7edede;
    --btn-bad:   #7d2e2e;
    --btn-bad-fg:#f0a8a8;
    --accent:    #4a9eff;
}

[data-theme="light"] {
    --bg:        #f0f0f4;
    --surface:   #ffffff;
    --surface2:  #e8e8ec;
    --text:      #111116;
    --muted:     #666670;
    --border:    #ccccD4;
    --btn-ok:    #3cb371;
    --btn-ok-fg: #fff;
    --btn-up:    #008080;
    --btn-up-fg: #fff;
    --btn-bad:   #ff6347;
    --btn-bad-fg:#fff;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

#game {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
}

#pixiCanvas {
    display: block;
    width: 100% !important;
    flex-shrink: 0;
}

#menu {
    flex: 1;
    display: flex;
    overflow: hidden;
    border-top: 1px solid var(--border);
    background: var(--surface);
    min-height: 180px;
}

/* ── Player panel (left) ─────────────────────────────────────────────────── */

#playermenu {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    height: auto !important;   /* override ui.js inline style.height */
}

/* ── Tower panel (right) ─────────────────────────────────────────────────── */

#towermenu {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: auto !important;   /* override ui.js inline style.height */
}

#towerinfo {
    flex: 1;
    overflow-y: auto;
}

/* ── Info blocks ─────────────────────────────────────────────────────────── */

.info {
    padding: 10px 12px 6px;
    flex: 1;
    overflow-y: auto;
}

.title {
    display: block;
    font-weight: 700;
    font-size: 12px;
    text-align: center;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--muted);
}

.value {
    color: var(--text);
    font-weight: 600;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

#functions, #functions2 {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border);
}

.button {
    display: block;
    width: 100%;
    padding: 11px 12px;
    text-align: center;
    background: var(--btn-ok);
    color: var(--btn-ok-fg);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.08);
    transition: transform 0.08s, opacity 0.1s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}
.button:active {
    opacity: 0.8;
    transform: scale(0.97);
}

.btn-danger {
    background: var(--btn-bad);
    color: var(--btn-bad-fg);
}

#upgrades {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border-top: 1px solid var(--border);
}

.upbutton {
    display: block;
    padding: 7px 10px;
    text-align: center;
    background: var(--btn-up);
    color: var(--btn-up-fg);
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.08);
    transition: opacity 0.15s;
}
.upbutton:active { opacity: 0.75; }

/* ── Buy mode indicator ──────────────────────────────────────────────────── */

#buytower.buymode-active {
    background: var(--accent);
    color: #fff;
    animation: td-pulse 1s ease-in-out infinite;
}

@keyframes td-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* ── Insufficient gold shake ─────────────────────────────────────────────── */

@keyframes td-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    60%       { transform: translateX(6px); }
    80%       { transform: translateX(-3px); }
}
.shake { animation: td-shake 0.35s ease-in-out; }

/* ── Wave toast ──────────────────────────────────────────────────────────── */

.td-toast {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%) translateY(-70px);
    background: rgba(10, 10, 14, 0.82);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 20px;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    z-index: 100;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.td-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── Death overlay ───────────────────────────────────────────────────────── */

.td-death {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.td-death.visible {
    opacity: 1;
    pointer-events: all;
}
.td-death-inner {
    text-align: center;
    padding: 32px 28px;
}
.td-death-emoji {
    font-size: 64px;
    margin-bottom: 10px;
}
.td-death-title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--btn-bad-fg);
    margin-bottom: 6px;
}
.td-death-sub {
    color: var(--muted);
    font-size: 15px;
    margin-bottom: 28px;
}
.td-death-inner .button {
    width: 180px;
    margin: 0 auto;
}
