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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: #edf9ff;
    color: #31404a;
    font-family: Georgia, "Times New Roman", serif;
    overscroll-behavior: none;
}

#webgl {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
    touch-action: none;
}

#css3d-root {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    touch-action: none;
}

#css3d-renderer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

#url-overlay {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 16px;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    transition: opacity .12s;
    margin: 0 auto;
    max-width: 420px;
}

#url-overlay.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

#url-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#url-input:focus {
    border-color: #4CAF50;
}

#hud {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 10;
    max-width: min(92vw, 520px);
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 14px 40px rgba(86, 116, 139, 0.18);
    backdrop-filter: blur(14px);
    z-index: 100;
}

.hud-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.title-group {
    min-width: 0;
}

#title {
    font-size: 18px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#subtitle {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.35;
    letter-spacing: 0.08em;
    color: #0d6f58;
    font-weight: 700;
    text-transform: uppercase;
}

.hackathon-ribbon {
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(20, 186, 144, 0.28);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(0, 255, 163, 0.16), rgba(220, 31, 255, 0.12));
    color: #17333b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.info-button {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(49, 64, 74, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: #22313c;
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    flex: none;
}

.info-button:hover,
.info-button:focus-visible {
    background: #ffffff;
    outline: 2px solid rgba(87, 136, 182, 0.35);
    outline-offset: 1px;
}

#hint {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.45;
    color: rgba(49, 64, 74, 0.86);
}

#target-label {
    margin-top: 6px;
    font-size: 14px;
    color: rgba(49, 64, 74, 0.9);
    display: flex;
    align-items: center;
    gap: 8px;
}

#current-target-name {
    color: #ff3f3f;
    font-weight: 700;
}

#current-target-preview {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.wallet-form-overlay {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 12px;
}

.wallet-form-overlay input,
.wallet-form-overlay button {
    min-width: 0;
    border-radius: 12px;
    font: inherit;
}

.wallet-form-overlay input {
    padding: 10px 12px;
    border: 1px solid rgba(49, 64, 74, 0.16);
    background: rgba(255, 255, 255, 0.92);
    color: #22313c;
}

.wallet-form-overlay input:focus {
    outline: 2px solid rgba(87, 136, 182, 0.35);
    outline-offset: 1px;
}

.wallet-form-overlay button {
    border: 0;
    padding: 10px 14px;
    background: linear-gradient(135deg, #335678, #5e87af);
    color: #f9fbff;
    font-weight: 700;
    cursor: pointer;
}

.wallet-status {
    margin-top: 10px;
    min-height: 20px;
    font-size: 13px;
    line-height: 1.45;
    color: rgba(49, 64, 74, 0.82);
}

.chain-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(49, 64, 74, 0.12);
    color: #22313c;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chain-indicator__icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
}

.chain-indicator__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.chain-indicator.is-ethereum {
    box-shadow: 0 0 0 1px rgba(98, 126, 234, 0.12) inset;
}

.chain-indicator.is-solana {
    box-shadow: 0 0 0 1px rgba(31, 212, 178, 0.14) inset;
    background: linear-gradient(135deg, rgba(0, 255, 163, 0.16), rgba(220, 31, 255, 0.12));
    border-color: rgba(20, 186, 144, 0.24);
}

.wallet-status.error {
    color: #9a2d12;
}

body.locked #hud {
    opacity: 0.52;
}

#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    background: rgba(255, 59, 48, 0.95);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 300px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.72);
    z-index: 500;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.overlay .overlay-card {
    padding: 24px 42px;
    border-radius: 18px;
    background: rgba(10, 12, 18, 0.9);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.35);
    font-size: 22px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: #ffffff;
}

.overlay .overlay-card.loading-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.overlay-title {
    font-size: 22px;
}

.overlay-subtitle {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: none;
    color: rgba(255, 255, 255, 0.82);
    max-width: 420px;
    line-height: 1.45;
}

.overlay .overlay-card.kill {
    background: rgba(150, 0, 0, 0.92);
    border: 2px solid rgba(255, 55, 55, 0.8);
}

.overlay.hidden {
    opacity: 0;
}

.about-overlay {
    position: fixed;
    inset: 0;
    z-index: 650;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(7, 12, 18, 0.6);
    backdrop-filter: blur(10px);
    transition: opacity 0.25s ease;
}

.about-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.about-card {
    position: relative;
    width: min(92vw, 520px);
    padding: 24px 24px 22px;
    border-radius: 20px;
    background: rgba(250, 252, 255, 0.96);
    border: 1px solid rgba(87, 136, 182, 0.18);
    box-shadow: 0 28px 56px rgba(14, 32, 48, 0.28);
    color: #22313c;
}

.about-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(87, 136, 182, 0.12);
    color: #335678;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.about-card h2 {
    margin-top: 14px;
    font-size: 24px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.about-card p {
    margin-top: 12px;
    font-size: 15px;
    line-height: 1.6;
    color: rgba(34, 49, 60, 0.88);
}

.about-close {
    position: absolute;
    top: 16px;
    right: 16px;
    border: 0;
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(51, 86, 120, 0.1);
    color: #335678;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.about-close:hover,
.about-close:focus-visible {
    background: rgba(51, 86, 120, 0.16);
    outline: 2px solid rgba(87, 136, 182, 0.35);
    outline-offset: 1px;
}

#mobile-controls {
    position: fixed;
    inset: 0;
    z-index: 220;
    pointer-events: none;
    display: none;
}

body.touch-device #mobile-controls {
    display: block;
}

.mobile-pad,
.mobile-look-pad {
    position: absolute;
    bottom: 24px;
    width: min(34vw, 190px);
    height: min(34vw, 190px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(6px);
    pointer-events: auto;
    touch-action: none;
    user-select: none;
}

.mobile-pad {
    left: 20px;
}

#mobile-look-zone {
    display: none;
}

.mobile-pad-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.56);
    font-size: 12px;
    letter-spacing: 0.18em;
    pointer-events: none;
}

.mobile-pad-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44%;
    height: 44%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.34);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

body.screen-mode #mobile-controls {
    opacity: 0.4;
}

@media (max-width: 640px) {
    #hud {
        top: 12px;
        left: 12px;
        right: 12px;
        max-width: none;
        padding: 12px 14px;
    }

    #title {
        font-size: 16px;
    }

    #subtitle {
        font-size: 11px;
    }

    .hackathon-ribbon {
        font-size: 11px;
    }

    #hint {
        font-size: 13px;
    }

    .info-button {
        width: 32px;
        height: 32px;
        font-size: 17px;
    }

    .about-card {
        padding: 22px 18px 18px;
    }

    .about-card h2 {
        font-size: 20px;
    }

    .wallet-form-overlay {
        grid-template-columns: 1fr;
    }

    #url-overlay {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
        margin: 0;
    }

    .mobile-pad,
    .mobile-look-pad {
        width: min(38vw, 170px);
        height: min(38vw, 170px);
        bottom: 18px;
    }

    .mobile-pad {
        left: 14px;
    }

    .mobile-look-pad {
        right: 14px;
    }
}
