/* Polygons - Game-specific styles */

/* Override body padding for polygons */
body {
    padding-bottom: 32px;
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 12px;
}

.game-header h1 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    text-shadow: 0 0 10px var(--glow-purple);
}

.money-display {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    color: var(--tg-theme-link-color);
    letter-spacing: -0.02em;
    text-shadow: 0 0 10px var(--glow-blue);
    animation: moneyGlow 4s ease-in-out infinite alternate;
}

@keyframes moneyGlow {
    from {
        text-shadow: 0 0 10px var(--glow-blue);
    }
    to {
        text-shadow: 0 0 14px var(--glow-blue), 0 0 20px var(--glow-purple);
    }
}

.money-icon {
    margin-right: 2px;
}

/* Header Right Section */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Shapes List */
.shapes-list {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border-subtle);
}

.shapes-list-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    gap: 8px;
    transition: background 0.2s var(--ease-out);
}

.shapes-list-header:active {
    background: rgba(0, 0, 0, 0.05);
}

.shapes-list-toggle {
    font-size: 10px;
    color: var(--tg-theme-hint-color);
    transition: transform 0.2s var(--ease-out);
}

.shapes-list.expanded .shapes-list-toggle {
    transform: rotate(90deg);
}

.shapes-list-header span:nth-child(2) {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
}

.shapes-count {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
}

.shapes-list-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s var(--ease-out);
}

.shapes-list.expanded .shapes-list-content {
    max-height: 200px;
    overflow-y: auto;
}

/* Shape Row */
.shape-row {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 10px;
    border-top: 1px solid var(--border-subtle);
}

.shape-row.main {
    background: rgba(0, 0, 0, 0.03);
}

.shape-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.shape-indicator.filled {
    background: currentColor;
}

.shape-indicator.outline {
    border: 2px solid currentColor;
    background: transparent;
}

.shape-row-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.shape-row-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.shape-row-level {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 6px;
    border-radius: 6px;
}

.shape-row-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.shape-row-bar {
    width: 50px;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.shape-row-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 3px;
    transition: width 0.3s var(--ease-out);
}

.shape-row-text {
    font-size: 11px;
    color: var(--tg-theme-hint-color);
    min-width: 45px;
    text-align: right;
}

/* Play Area */
.play-area {
    position: relative;
    width: 100%;
    height: 55vh;
    background: var(--tg-theme-secondary-bg-color);
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 24px 24px;
    border-radius: 16px;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border-subtle);
}

/* Shape */
.shape {
    position: absolute;
    width: 40px;
    height: 40px;
    transition: clip-path 0.5s var(--ease-out), background-color 0.5s var(--ease-out);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    z-index: 10;
}

.shape.evolving,
.helper.evolving {
    animation: evolveFlash 0.5s var(--ease-out);
}

@keyframes evolveFlash {
    0%, 100% { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2)); }
    50% { filter: drop-shadow(0 0 20px currentColor) brightness(1.5); }
}

/* Feed */
.feed {
    position: absolute;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, #FFE082 0%, #FFC107 100%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: feedSpawn 0.3s ease-out;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
    z-index: 5;
}

@keyframes feedSpawn {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.feed.eaten {
    animation: feedEaten 0.2s ease-out forwards;
}

@keyframes feedEaten {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

/* Coin */
.coin {
    position: absolute;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA000 100%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: coinFloat 1s ease-out forwards;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.6);
    z-index: 15;
    pointer-events: none;
}

.coin::after {
    content: '$';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: #5D4037;
}

@keyframes coinFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0);
    }
    20% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    40% {
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(0.8);
    }
}

/* Game Instructions */
.game-instructions {
    text-align: center;
    padding: 12px;
    color: var(--tg-theme-hint-color);
    font-size: 14px;
}

/* Button extras */
.btn.affordable {
    animation: btnPulse 1.5s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 0 0 rgba(74, 158, 255, 0); }
    50% { box-shadow: 0 0 12px var(--glow-blue); }
}

.btn-buy {
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-upgrade {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.visible {
    display: flex;
}

.modal-content {
    background: var(--tg-theme-bg-color);
    padding: 32px 24px;
    border-radius: 20px;
    text-align: center;
    max-width: 300px;
    width: 100%;
    box-shadow: var(--shadow-3);
    border: 1px solid var(--border-subtle);
    animation: modalSlideIn 0.3s var(--ease-out);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h2 {
    font-family: var(--font-display);
    font-size: 24px;
    margin-bottom: 16px;
}

.modal-content p {
    margin-bottom: 8px;
    color: var(--tg-theme-hint-color);
}

.earnings-text {
    font-size: 14px;
    margin-top: 16px;
}

.earnings-amount {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: bold;
    color: var(--tg-theme-link-color);
    margin-bottom: 24px;
}

.modal-content .btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
}

/* Mining Animation */
.mining-icon {
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--tg-theme-link-color);
    border-radius: 2px;
    animation: mining var(--mining-speed, 1s) ease-in-out infinite;
    transform-origin: bottom center;
    margin-left: 6px;
}

@keyframes mining {
    0%, 100% { transform: rotate(-20deg); }
    50% { transform: rotate(20deg); }
}

/* Clickable Resource */
.resource.clickable {
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s var(--ease-bounce);
}

.resource.clickable:active {
    transform: scale(0.95);
}

.resource.bounce {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Money Popup Animation */
.money-popup {
    position: fixed;
    top: 60px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 999;
    animation: moneyFloat 0.8s ease-out forwards;
}

@keyframes moneyFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateY(-20px) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1);
    }
}

/* Resource Popup Animation */
.resource-popup {
    position: fixed;
    font-size: 14px;
    font-weight: bold;
    color: var(--tg-theme-link-color);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 998;
    transform: translateX(-50%);
    animation: resourceFloat 0.6s ease-out forwards;
}

@keyframes resourceFloat {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(0.8);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-25px) scale(1);
    }
}

/* Shop Button */
.shop-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    box-shadow: var(--shadow-2), 0 0 12px var(--glow-blue);
    z-index: 20;
    transition: transform 0.2s var(--ease-bounce), box-shadow 0.2s var(--ease-out);
}

.shop-btn:active {
    transform: scale(0.95);
    box-shadow: var(--shadow-1);
}

/* Shop Overlay */
.shop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease-out), visibility 0.3s var(--ease-out);
    z-index: 100;
}

.shop-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Shop Drawer */
.shop-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: var(--tg-theme-bg-color);
    transform: translateX(100%) scale(0.98);
    transform-origin: right center;
    transition: transform 0.3s var(--ease-out);
    z-index: 101;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-3);
    border-left: 1px solid var(--border-subtle);
}

.shop-drawer.open {
    transform: translateX(0) scale(1);
}

.shop-drawer .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.shop-drawer .drawer-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--tg-theme-hint-color);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s var(--ease-out);
}

.close-btn:hover {
    color: var(--tg-theme-text-color);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Shop Item */
.shop-item {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-1);
}

.shop-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.shop-item-title {
    font-size: 16px;
    font-weight: 600;
}

.shop-item-count {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
}

.shop-item-desc {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 12px;
}

.shop-item-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-bounce);
}

.shop-item-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.shop-item-btn:not(:disabled):active {
    opacity: 0.8;
}

.shop-hint {
    text-align: center;
    color: var(--tg-theme-hint-color);
    font-size: 13px;
    margin-top: 16px;
    font-style: italic;
}

/* Helper Shape */
.helper {
    position: absolute;
    transition: clip-path 0.5s var(--ease-out), background-color 0.5s var(--ease-out);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    z-index: 9;
    opacity: 0.85;
}
