/* ── Floating Trigger Button ───────────────────────────────── */
#tfm-open-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 16px;
    background: #1a1a2e;
    color: #e0e0ff;
    border: 2px solid #4b4bff;
    border-radius: 30px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(75, 75, 255, 0.45);
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
    -webkit-user-select: none;
    user-select: none;
}
#tfm-open-btn:hover {
    background: #2a2a6e;
    box-shadow: 0 6px 26px rgba(75, 75, 255, 0.65);
    transform: translateY(-1px);
}
#tfm-open-btn:active {
    transform: translateY(0);
}

/* ── Modal Overlay ─────────────────────────────────────────── */
#tfm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.82);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    outline: none;
}
#tfm-overlay.tfm-active {
    display: flex;
}

/* ── Modal Box ─────────────────────────────────────────────── */
#tfm-modal {
    background: #0d0d1a;
    border: 2px solid #4b4bff;
    border-radius: 14px;
    padding: 20px 20px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(75, 75, 255, 0.25);
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    animation: tfm-pop-in 0.2s ease;
}
@keyframes tfm-pop-in {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Header ────────────────────────────────────────────────── */
#tfm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
#tfm-title {
    font-family: 'Courier New', Courier, monospace;
    font-size: 20px;
    font-weight: 700;
    color: #c0c0ff;
    letter-spacing: 0.08em;
}
#tfm-close-btn {
    background: transparent;
    border: 1px solid #555;
    color: #aaa;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
#tfm-close-btn:hover {
    background: #ff4444;
    border-color: #ff4444;
    color: #fff;
}

/* ── Game Layout ────────────────────────────────────────────── */
#tfm-game-wrap {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* ── Canvas ─────────────────────────────────────────────────── */
#tfm-canvas {
    display: block;
    border: 2px solid #333;
    background: #05050f;
    border-radius: 4px;
    flex-shrink: 0;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#tfm-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 110px;
}
.tfm-panel {
    background: #111124;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 10px;
    text-align: center;
}
.tfm-label {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: #666;
    letter-spacing: 0.12em;
    margin-bottom: 4px;
}
.tfm-value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 22px;
    font-weight: 700;
    color: #c0c0ff;
}
#tfm-next-canvas {
    display: block;
    margin: 4px auto 0;
    background: #05050f;
    border-radius: 4px;
}
#tfm-controls-hint {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: #444;
    line-height: 1.9;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 8px 10px;
}

/* ── Pause / Game Over Overlay ─────────────────────────────── */
#tfm-message {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    border-radius: 14px;
    z-index: 10;
}
#tfm-message.show {
    display: flex;
}
#tfm-message p {
    font-family: 'Courier New', Courier, monospace;
    font-size: 24px;
    color: #fff;
    font-weight: 700;
    margin: 0;
}
#tfm-message button {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    padding: 8px 22px;
    background: #4b4bff;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}
#tfm-message button:hover {
    background: #6666ff;
}

/* ── Mobile tweaks ──────────────────────────────────────────── */
@media (max-width: 520px) {
    #tfm-modal {
        padding: 14px 10px 18px;
    }
    #tfm-game-wrap {
        flex-direction: column;
        align-items: center;
    }
    #tfm-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        min-width: unset;
        gap: 8px;
    }
    #tfm-controls-hint {
        display: none;
    }
}
