* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a1a;
    font-family: 'Chakra Petch', sans-serif;
    touch-action: none;
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

.btn {
    font-family: 'Cinzel Decorative', cursive;
    border: 2px solid #c8935a;
    background: linear-gradient(180deg, #8b6914 0%, #5a3e0a 100%);
    color: #ffe4a8;
    padding: 14px 32px;
    font-size: 18px;
    border-radius: 8px;
    cursor: pointer;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,228,168,0.3);
    min-width: 48px;
    min-height: 48px;
    transition: transform 0.1s, box-shadow 0.1s;
    letter-spacing: 1px;
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.btn-large {
    padding: 18px 48px;
    font-size: 22px;
    border-radius: 12px;
}

.btn-fight {
    background: linear-gradient(180deg, #c44b4b 0%, #7a1a1a 100%);
    border-color: #ff6b6b;
    color: #ffe0e0;
    font-size: 28px;
    padding: 20px 60px;
}

.btn-evolve {
    background: linear-gradient(180deg, #d4a017 0%, #8b6914 100%);
    border-color: #ffd700;
    color: #fff;
    animation: evolve-glow 1.5s ease-in-out infinite;
}

@keyframes evolve-glow {
    0%, 100% { box-shadow: 0 0 10px #ffd700, 0 0 20px rgba(255,215,0,0.3); }
    50% { box-shadow: 0 0 20px #ffd700, 0 0 40px rgba(255,215,0,0.5); }
}

.coin-display {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    border: 1px solid #c8935a;
    border-radius: 20px;
    padding: 6px 16px;
    color: #ffd700;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 20;
}

.coin-icon {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 40% 40%, #ffd700, #b8860b);
    border-radius: 50%;
    border: 1px solid #8b6914;
    display: inline-block;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-sheet {
    background: linear-gradient(180deg, #2a1f0f 0%, #1a1205 100%);
    border: 2px solid #c8935a;
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 24px 20px 40px;
    animation: slideUp 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-sheet h2 {
    font-family: 'Cinzel Decorative', cursive;
    color: #ffe4a8;
    text-align: center;
    margin-bottom: 16px;
    font-size: 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    color: #c8a87a;
    border-bottom: 1px solid rgba(200,147,90,0.2);
    font-size: 14px;
}

.stat-value {
    color: #ffe4a8;
    font-weight: 700;
}

.progress-bar-outer {
    width: 100%;
    height: 12px;
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    border: 1px solid #5a3e0a;
    margin: 12px 0;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, #c8935a, #ffd700);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.evolution-cards {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.evolution-card {
    flex: 1;
    background: rgba(0,0,0,0.4);
    border: 2px solid #5a3e0a;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}

.evolution-card:active {
    transform: scale(0.97);
}

.evolution-card.selected {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255,215,0,0.3);
}

.evolution-card h3 {
    font-family: 'Cinzel Decorative', cursive;
    color: #ffe4a8;
    font-size: 14px;
    margin-bottom: 8px;
}

.evolution-card p {
    color: #c8a87a;
    font-size: 12px;
    margin-bottom: 4px;
}

.evolution-card .tagline {
    color: #8b9dc3;
    font-style: italic;
    font-size: 11px;
    margin-top: 8px;
}

.parts-tray {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, rgba(26,18,5,0.95) 0%, rgba(10,10,26,0.98) 100%);
    border-top: 2px solid #c8935a;
    padding: 10px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 15;
}

.part-card {
    min-width: 90px;
    max-width: 90px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #5a3e0a;
    border-radius: 10px;
    padding: 8px;
    text-align: center;
    flex-shrink: 0;
    cursor: grab;
    transition: transform 0.1s, opacity 0.1s;
}

.part-card.balloon-type { border-color: #4488cc; }
.part-card.cannon-type { border-color: #cc4444; }
.part-card.engine-type { border-color: #44cc44; }
.part-card.evolved { border-color: #ffd700; box-shadow: 0 0 8px rgba(255,215,0,0.3); }

.part-card .part-name {
    color: #ffe4a8;
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.part-card .part-stat {
    color: #8b9dc3;
    font-size: 9px;
    margin-top: 2px;
}

.part-card.hull-type { border-color: #c8935a; }

.screen-title {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cinzel Decorative', cursive;
    color: #ffe4a8;
    font-size: 18px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
    z-index: 15;
}

.back-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.5);
    border: 1px solid #c8935a;
    color: #ffe4a8;
    width: 48px;
    height: 48px;
    border-radius: 24px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
}

.footer-link {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(200,147,90,0.4);
    font-size: 11px;
    text-decoration: none;
    font-family: 'Chakra Petch', sans-serif;
}

.footer-link:hover {
    color: rgba(200,147,90,0.7);
}

.battle-result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.5s ease;
}

.battle-result-overlay h1 {
    font-family: 'Cinzel Decorative', cursive;
    font-size: 36px;
    text-shadow: 0 0 20px currentColor;
    margin-bottom: 16px;
}

.battle-result-overlay.victory h1 { color: #ffd700; }
.battle-result-overlay.defeat h1 { color: #cc4444; }

.battle-result-overlay p {
    color: #c8a87a;
    font-size: 16px;
    margin-bottom: 24px;
}

.battle-buttons {
    display: flex;
    gap: 12px;
}

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.confirm-box {
    background: linear-gradient(180deg, #2a1f0f 0%, #1a1205 100%);
    border: 2px solid #ffd700;
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    text-align: center;
}

.confirm-box h3 {
    font-family: 'Cinzel Decorative', cursive;
    color: #ffd700;
    margin-bottom: 12px;
}

.confirm-box p {
    color: #c8a87a;
    font-size: 14px;
    margin-bottom: 20px;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}