:root {
    --bg-main: #2b3a4a;
    --bg-dark: #1b2631;
    --border-outer: #8d9da8;
    --border-inner: #151e27;
    --text-classic: #ffffff;
    --text-yellow: #ffcc00;
    --text-green: #66ff00;
    --text-red: #ff3333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    font-family: 'NeoDunggeunmo', '돋움', sans-serif;
    color: var(--text-classic);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    user-select: none;
}

.app-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
}

@media (max-width: 700px) {
    .app-container {
        flex-direction: column;
        align-items: center;
        padding: 20px 0;
        height: auto;
    }

    body {
        align-items: flex-start;
        height: auto;
    }
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 0px;
    text-align: center;
}

.stats-table th {
    border-bottom: 1px solid #555;
    padding: 3px 2px;
    color: #ffcc00;
    font-weight: normal;
    background: #151c24;
    position: sticky;
    top: 0;
    z-index: 2;
    line-height: 1.1;
}

.stats-table td {
    padding: 2.5px 2px;
    border-bottom: 1px dotted #444;
    line-height: 1.1;
}

.stats-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.stats-table-wrapper::-webkit-scrollbar-thumb {
    background-color: #666;
    border-radius: 3px;
}

.stats-table-wrapper::-webkit-scrollbar-track {
    background-color: #222;
}

.sf-window {
    width: 320px;
    background: linear-gradient(180deg, #3d5066 0%, #1a2533 100%);
    border: 2px solid #a3b2c2;
    border-radius: 6px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8), inset 0 0 0 2px #0a1017;
    position: relative;
    overflow: hidden;
}

.sf-header {
    background: linear-gradient(90deg, #3d5168, #18222d);
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px groove #485c72;
    font-size: 14px;
    text-shadow: 1px 1px 0 #000;
}

.sf-close-btn {
    background: #cc3333;
    border: 1px solid #ff9999;
    color: white;
    font-family: inherit;
    cursor: pointer;
    border-radius: 2px;
    padding: 0 5px;
}

.sf-close-btn:active {
    background: #880000;
}

.sf-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sf-title {
    font-size: 18px;
    color: var(--text-yellow);
    text-shadow: 1px 1px 0 #000;
    margin-bottom: 10px;
}

.level-selector {
    font-size: 12px;
    color: #eee;
    background: rgba(0, 0, 0, 0.3);
    border: 1px inset #485c72;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.level-selector label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.level-selector input {
    margin-right: 3px;
    cursor: pointer;
}

.item-display {
    text-align: center;
    margin-bottom: 10px;
}

.stars {
    font-size: 13.5px;
    margin-bottom: 5px;
    color: #444;
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(15, auto);
    justify-content: center;
    column-gap: 2px;
    row-gap: 4px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.stars span:nth-child(5),
.stars span:nth-child(10),
.stars span:nth-child(20),
.stars span:nth-child(25) {
    margin-right: 8px;
}

.star.filled {
    color: var(--text-yellow);
    text-shadow: 1px 1px 0 #000;
}

.star.empty {
    color: #444;
    text-shadow: 1px 1px 0 #000;
}

.item-icon-box {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #a4b2be, #76818a);
    border: 2px solid #ddd;
    border-radius: 4px;
    margin: 5px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

.item-name {
    font-size: 14px;
    text-shadow: 1px 1px 0 #000;
    margin-top: 5px;
}

.star-count-text {
    font-size: 14px;
    color: var(--text-yellow);
    margin-top: 5px;
    text-shadow: 1px 1px 0 #000;
}

.sf-info-box {
    width: 100%;
    font-size: 14px;
    text-shadow: 1px 1px 0 #000;
    margin-bottom: 15px;
    line-height: 1.6;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border: 1px inset #475a6e;
    border-radius: 4px;
}

.prob-row {
    display: flex;
    justify-content: space-between;
}

.prob-success {
    color: var(--text-green);
}

.prob-fail {
    color: #ccc;
}

.prob-destroy {
    color: var(--text-red);
}

.drop-warning {
    color: #ff9955;
    font-size: 12px;
    text-align: center;
    margin-top: 5px;
}

.meso-cost {
    font-size: 18px;
    color: var(--text-yellow);
    text-shadow: 1px 1px 0 #000;
    margin-bottom: 10px;
    text-align: center;
    width: 100%;
}

.checkbox-row {
    font-size: 12px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.total-stats {
    width: 100%;
    font-size: 12px;
    text-shadow: 1px 1px 0 #000;
    line-height: 1.5;
    text-align: center;
    padding-top: 10px;
    border-top: 1px dashed #555;
    margin-bottom: 15px;
}

.sf-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 0 15px 15px 15px;
}

.sf-btn {
    font-family: inherit;
    font-size: 16px;
    padding: 6px 20px;
    background: linear-gradient(180deg, #d2dce2 0%, #9baab8 100%);
    border-top: 2px solid #fff;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #555;
    border-right: 2px solid #555;
    color: #111;
    cursor: pointer;
    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}

.sf-btn:active {
    border-top: 2px solid #555;
    border-left: 2px solid #555;
    border-bottom: 2px solid #fff;
    border-right: 2px solid #fff;
    background: #9baab8;
    color: #000;
}

.hidden {
    display: none !important;
}

#result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

.result-text {
    font-size: 40px;
    font-weight: bold;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-text.success {
    color: var(--text-yellow);
    text-shadow: 3px 3px 0 #000, 0 0 15px rgba(255, 204, 0, 0.8);
}

.result-text.fail {
    color: #cccccc;
    text-shadow: 3px 3px 0 #000;
}

.result-text.destroy {
    font-size: 34px;
    color: var(--text-red);
    text-shadow: 3px 3px 0 #000, 0 0 15px rgba(255, 51, 51, 0.8);
    animation: popIn 0.2s, shake 0.5s;
}

.sparkle-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    box-shadow:
        0 -2px 0 0 #fff, 0 -4px 0 0 #fff,
        0 2px 0 0 #fff, 0 4px 0 0 #fff,
        -2px 0 0 0 #fff, -4px 0 0 0 #fff,
        2px 0 0 0 #fff, 4px 0 0 0 #fff;
    pointer-events: none;
    z-index: -1;
}

.sparkle-particle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #ffaa00;
    border-radius: 50%;
    filter: blur(3px);
    z-index: -1;
    opacity: 0.7;
}

@keyframes sparkle-anim {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(var(--scale-max, 1));
        opacity: 1;
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.result-text.protected {
    font-size: 34px;
    color: #4dd0e1;
    text-shadow: 3px 3px 0 #000, 0 0 15px rgba(77, 208, 225, 0.8);
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star {
    position: relative;
    z-index: 1;
}

.star.filled {
    color: #ffcc00;
    text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffaa00;
}

@keyframes popIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }
}