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

:root {
    --spidey-red: #E23636;
    --spidey-red-dark: #B91C1C;
    --spidey-blue: #1A1A6C;
    --spidey-blue-light: #2E2E9C;
    --symbiote-black: #1A1A2E;
    --web-white: #F0F0F0;
    --accent-blue: #4A6FA5;
}

body {
    font-family: 'Share Tech Mono', monospace;
    min-height: 100vh;
    overflow-x: hidden;
}

.spidey-container {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--spidey-red) 0%, var(--spidey-blue) 50%, var(--symbiote-black) 100%);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

/* Web pattern overlay */
.spidey-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at center, transparent 0%, transparent 45%, rgba(255,255,255,0.03) 45%, rgba(255,255,255,0.03) 46%, transparent 46%),
        repeating-conic-gradient(from 0deg, transparent 0deg 15deg, rgba(255,255,255,0.02) 15deg 16deg);
    background-size: 80px 80px, 160px 160px;
    pointer-events: none;
    animation: web-pulse 8s ease-in-out infinite;
}

@keyframes web-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Corner webs */
.web-corner {
    position: fixed;
    width: 120px;
    height: 120px;
    pointer-events: none;
    opacity: 0.4;
    z-index: 1;
}

.web-tl {
    top: 0;
    left: 0;
    background: 
        linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 0% 0%, transparent 0%, transparent 70%, rgba(255,255,255,0.1) 70%);
    animation: web-sway 4s ease-in-out infinite;
}

.web-tr {
    top: 0;
    right: 0;
    background: linear-gradient(225deg, rgba(255,255,255,0.3) 0%, transparent 50%);
    animation: web-sway 4s ease-in-out infinite reverse;
}

.web-bl {
    bottom: 0;
    left: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.3) 0%, transparent 50%);
    animation: web-sway 5s ease-in-out infinite;
}

.web-br {
    bottom: 0;
    right: 0;
    background: linear-gradient(315deg, rgba(255,255,255,0.3) 0%, transparent 50%);
    animation: web-sway 5s ease-in-out infinite reverse;
}

@keyframes web-sway {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(2deg) scale(1.02); }
}

/* Crawling spider */
.crawling-spider {
    position: fixed;
    top: 50%;
    left: -50px;
    font-size: 24px;
    z-index: 100;
    animation: spider-crawl 4s linear forwards;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

@keyframes spider-crawl {
    0% { left: -50px; transform: rotate(90deg); }
    25% { top: 30%; transform: rotate(45deg); }
    50% { left: 50%; top: 20%; transform: rotate(0deg); }
    75% { top: 40%; transform: rotate(-45deg); }
    100% { left: calc(100% + 50px); transform: rotate(-90deg); }
}

.calc-wrapper {
    max-width: 400px;
    width: 100%;
    position: relative;
    z-index: 10;
}

/* Header */
.spidey-header {
    text-align: center;
    margin-bottom: 20px;
}

.spidey-title {
    font-family: 'Bangers', cursive;
    font-size: 2.8rem;
    color: var(--web-white);
    text-shadow: 
        3px 3px 0 var(--spidey-red-dark),
        -1px -1px 0 var(--symbiote-black),
        4px 4px 8px rgba(0,0,0,0.4);
    letter-spacing: 2px;
    animation: title-bounce 3s ease-in-out infinite;
}

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

.spidey-tagline {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    margin-top: 4px;
    font-style: italic;
}

/* Message popup */
.spidey-message {
    background: linear-gradient(135deg, var(--spidey-red) 0%, var(--spidey-red-dark) 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    margin-bottom: 16px;
    animation: message-swing 0.4s ease-out;
    box-shadow: 
        0 4px 20px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.2);
}

@keyframes message-swing {
    0% { transform: translateY(-30px) rotate(-5deg); opacity: 0; }
    50% { transform: translateY(5px) rotate(2deg); }
    100% { transform: translateY(0) rotate(0); opacity: 1; }
}

/* Calculator body */
.calculator-body {
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(240,240,240,0.98) 100%);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 
        0 20px 60px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.8),
        0 0 0 4px var(--spidey-red),
        0 0 0 8px var(--spidey-blue);
    position: relative;
    overflow: hidden;
}

/* Web texture on calculator */
.calculator-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0 L30 60 M0 30 L60 30 M0 0 L60 60 M60 0 L0 60' stroke='%23E23636' stroke-width='0.3' fill='none' opacity='0.08'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* Display wrapper - mask shape */
.display-wrapper {
    position: relative;
    margin-bottom: 20px;
    padding: 8px;
}

/* Spidey eyes decoration */
.spidey-eye {
    position: absolute;
    top: -15px;
    width: 30px;
    height: 20px;
    background: white;
    border: 3px solid var(--symbiote-black);
    z-index: 5;
}

.left-eye {
    left: 20%;
    border-radius: 50% 80% 30% 70%;
    transform: rotate(-10deg);
}

.right-eye {
    right: 20%;
    border-radius: 80% 50% 70% 30%;
    transform: rotate(10deg);
}

.display-screen {
    background: linear-gradient(135deg, var(--symbiote-black) 0%, #0D0D1A 100%);
    border-radius: 16px;
    padding: 20px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    border: 4px solid var(--spidey-red);
    box-shadow: 
        inset 0 4px 12px rgba(0,0,0,0.6),
        0 0 20px rgba(226, 54, 54, 0.3);
}

.display-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 2.8rem;
    color: #00FF88;
    text-shadow: 0 0 10px rgba(0,255,136,0.5);
    word-break: break-all;
}

.op-indicator {
    position: absolute;
    top: 8px;
    right: 16px;
    font-size: 1.2rem;
    color: var(--spidey-red);
    font-weight: bold;
}

/* Web shoot animation */
.web-shoot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, transparent 70%);
    border-radius: 50%;
    animation: web-burst 0.8s ease-out forwards;
    pointer-events: none;
}

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

/* Button grid */
.btn-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.spidey-btn {
    padding: 18px;
    font-size: 1.4rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    font-family: 'Share Tech Mono', monospace;
}

.spidey-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.6) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.spidey-btn:active::before {
    width: 150px;
    height: 150px;
}

.spidey-btn:hover {
    transform: translateY(-3px) scale(1.02);
}

.spidey-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Button variants */
.btn-number {
    background: linear-gradient(180deg, var(--spidey-blue-light) 0%, var(--spidey-blue) 100%);
    color: white;
    box-shadow: 
        0 4px 0 #12124A,
        0 6px 12px rgba(0,0,0,0.2);
}

.btn-number:hover {
    background: linear-gradient(180deg, #3A3AAC 0%, var(--spidey-blue-light) 100%);
}

.btn-operation {
    background: linear-gradient(180deg, var(--spidey-red) 0%, var(--spidey-red-dark) 100%);
    color: white;
    box-shadow: 
        0 4px 0 #8B1515,
        0 6px 12px rgba(0,0,0,0.2);
}

.btn-operation::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='30' height='30' viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15 0 L15 30 M0 15 L30 15' stroke='white' stroke-width='0.5' fill='none' opacity='0.15'/%3E%3C/svg%3E");
    pointer-events: none;
}

.btn-equals {
    background: linear-gradient(180deg, #FF4444 0%, var(--spidey-red) 100%);
    color: white;
    box-shadow: 
        0 4px 0 #8B1515,
        0 6px 12px rgba(0,0,0,0.3),
        0 0 20px rgba(226,54,54,0.4);
    font-size: 1.6rem;
}

.btn-equals:hover {
    box-shadow: 
        0 4px 0 #8B1515,
        0 6px 12px rgba(0,0,0,0.3),
        0 0 30px rgba(226,54,54,0.6);
}

.btn-symbiote {
    background: linear-gradient(180deg, #2A2A3E 0%, var(--symbiote-black) 100%);
    color: white;
    box-shadow: 0 4px 0 #0A0A15, 0 6px 12px rgba(0,0,0,0.2);
}

.btn-accent {
    background: linear-gradient(180deg, var(--accent-blue) 0%, #3A5A85 100%);
    color: white;
    box-shadow: 0 4px 0 #2A4A75, 0 6px 12px rgba(0,0,0,0.2);
}

/* Controls */
.controls-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.control-btn {
    flex: 1;
    padding: 12px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Share Tech Mono', monospace;
}

.control-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.4);
}

/* History panel */
.history-panel {
    margin-top: 16px;
    background: rgba(255,255,255,0.95);
    border-radius: 16px;
    padding: 16px;
    max-height: 250px;
    overflow-y: auto;
    animation: slide-in 0.3s ease-out;
    border: 3px solid var(--spidey-red);
}

@keyframes slide-in {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(226,54,54,0.3);
}

.history-header h3 {
    font-family: 'Bangers', cursive;
    color: var(--spidey-blue);
    font-size: 1.1rem;
}

.clear-web-btn {
    font-size: 0.75rem;
    color: var(--spidey-red);
    background: none;
    border: 1px solid var(--spidey-red);
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-web-btn:hover {
    background: var(--spidey-red);
    color: white;
}

.empty-history {
    text-align: center;
    color: #666;
    padding: 20px;
    font-style: italic;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(26,26,108,0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--symbiote-black);
}

.history-item:hover {
    background: rgba(226,54,54,0.1);
    transform: translateX(4px);
}

.history-spider {
    font-size: 0.8rem;
}

/* City skyline */
.city-skyline {
    height: 60px;
    margin-top: 20px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 60' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='10' y='30' width='20' height='30' fill='%231A1A2E'/%3E%3Crect x='35' y='20' width='15' height='40' fill='%231A1A2E'/%3E%3Crect x='55' y='35' width='25' height='25' fill='%231A1A2E'/%3E%3Crect x='85' y='10' width='18' height='50' fill='%231A1A2E'/%3E%3Crect x='108' y='25' width='30' height='35' fill='%231A1A2E'/%3E%3Crect x='143' y='15' width='12' height='45' fill='%231A1A2E'/%3E%3Crect x='160' y='28' width='22' height='32' fill='%231A1A2E'/%3E%3Crect x='187' y='5' width='25' height='55' fill='%231A1A2E'/%3E%3Crect x='217' y='22' width='18' height='38' fill='%231A1A2E'/%3E%3Crect x='240' y='32' width='28' height='28' fill='%231A1A2E'/%3E%3Crect x='273' y='18' width='15' height='42' fill='%231A1A2E'/%3E%3Crect x='293' y='8' width='20' height='52' fill='%231A1A2E'/%3E%3Crect x='318' y='25' width='24' height='35' fill='%231A1A2E'/%3E%3Crect x='347' y='35' width='18' height='25' fill='%231A1A2E'/%3E%3Crect x='370' y='20' width='22' height='40' fill='%231A1A2E'/%3E%3C/svg%3E") repeat-x bottom;
    background-size: auto 100%;
    opacity: 0.3;
}

/* Footer */
.spidey-footer {
    margin-top: 20px;
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
}

.spidey-footer a {
    color: white;
    text-decoration: underline;
    transition: color 0.2s;
}

.spidey-footer a:hover {
    color: var(--spidey-red);
}

.spidey-footer p {
    margin: 4px 0;
}

/* Scrollbar */
.history-panel::-webkit-scrollbar {
    width: 8px;
}

.history-panel::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb {
    background: var(--spidey-red);
    border-radius: 4px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .spidey-title {
        font-size: 2rem;
    }
    
    .display-value {
        font-size: 2.2rem;
    }
    
    .spidey-btn {
        padding: 16px 12px;
        font-size: 1.2rem;
    }
    
    .btn-grid {
        gap: 8px;
    }
    
    .calculator-body {
        padding: 16px;
    }
    
    .spidey-eye {
        width: 24px;
        height: 16px;
        top: -12px;
    }
}