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

:root {
    --pink-deep: #e91e8c;
    --pink-mid: #ff6bb5;
    --pink-light: #ffb3d9;
    --pink-pale: #ffe0f0;
    --pink-bg: #fff0f7;
    --pink-card: #fff5fa;
    --white: #ffffff;
    --text: #5a2d4c;
    --muted: #c47fa8;
    --red: #ff4d7d;
    --yellow: #e0960a;
    --green: #2d8a55;
    --border: #f9c8e2;
    --shadow: rgba(233, 30, 140, 0.15);
    --font: 'Nunito', sans-serif;
    --display: 'Fredoka One', cursive;
}

body {
    font-family: var(--font);
    background: var(--pink-bg);
    color: var(--text);
    min-height: 100vh;
    padding: 24px 16px 48px;
    position: relative;
    overflow-x: hidden;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, var(--pink-light) 1.5px, transparent 1.5px);
    background-size: 28px 28px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.deco {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    font-size: 1.4em;
    animation: float 4s ease-in-out infinite;
    opacity: 0.5;
}

.deco:nth-child(1) {
    top: 6%;
    left: 4%;
    animation-delay: 0s;
}

.deco:nth-child(2) {
    top: 12%;
    right: 6%;
    animation-delay: 0.8s;
    font-size: 1em;
}

.deco:nth-child(3) {
    top: 45%;
    left: 2%;
    animation-delay: 1.5s;
    font-size: 0.9em;
}

.deco:nth-child(4) {
    bottom: 20%;
    right: 3%;
    animation-delay: 0.4s;
}

.deco:nth-child(5) {
    bottom: 8%;
    left: 8%;
    animation-delay: 2s;
    font-size: 1.1em;
}

.deco:nth-child(6) {
    top: 70%;
    right: 5%;
    animation-delay: 1.1s;
    font-size: 0.85em;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-10px) rotate(8deg);
    }
}

.wrapper {
    max-width: 780px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.dev-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78em;
    font-weight: 800;
    color: var(--pink-deep);
    text-decoration: none;
    background: var(--white);
    border: 2px solid var(--pink-light);
    padding: 5px 14px;
    border-radius: 100px;
    margin-bottom: 28px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--shadow);
}

.dev-link:hover {
    background: var(--pink-deep);
    color: white;
    border-color: var(--pink-deep);
    transform: translateY(-1px);
}

header {
    text-align: center;
    margin-bottom: 32px;
}

.kitty-face {
    font-size: 4.5em;
    line-height: 1;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 8px var(--shadow));
    animation: bounce 2.5s ease-in-out infinite;
    transition: transform 0.2s;
}

.kitty-face:hover {
    animation-play-state: paused;
    transform: scale(.20px);
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

h1 {
    font-family: var(--display);
    font-size: clamp(2.2em, 6vw, 3.4em);
    color: var(--pink-deep);
    line-height: 1;
    text-shadow: 3px 3px 0px var(--pink-light);
}

.subtitle {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.95em;
    font-weight: 600;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.ribbon {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    justify-content: center;
}

.ribbon-line {
    height: 2px;
    width: 80px;
    background: linear-gradient(90deg, transparent, var(--pink-light));
    border-radius: 2px;
}

.ribbon-line.right {
    background: linear-gradient(90deg, var(--pink-light), transparent);
}

.tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.tab {
    font-family: var(--font);
    font-size: 0.88em;
    font-weight: 800;
    padding: 10px 22px;
    border-radius: 100px;
    border: 2px solid var(--pink-light);
    cursor: pointer;
    background: var(--white);
    color: var(--muted);
    transition: all 0.2s;
    box-shadow: 0 2px 6px var(--shadow);
}

.tab.active {
    background: var(--pink-deep);
    color: white;
    border-color: var(--pink-deep);
    box-shadow: 0 4px 14px var(--shadow);
    transform: translateY(-1px);
}

.tab:hover:not(.active) {
    border-color: var(--pink-mid);
    color: var(--pink-deep);
}

.card {
    background: var(--white);
    border: 2.5px solid var(--pink-light);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--shadow);
}

.card-top-bar {
    background: linear-gradient(90deg, var(--pink-mid), var(--pink-deep));
    height: 8px;
}

.card-body {
    padding: 32px 28px;
}

label {
    display: block;
    font-size: 0.82em;
    font-weight: 800;
    color: var(--pink-deep);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

textarea {
    width: 100%;
    min-height: 170px;
    padding: 16px;
    background: var(--pink-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.82em;
    color: var(--text);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.6;
}

textarea::placeholder {
    color: var(--pink-light);
}

textarea:focus {
    outline: none;
    border-color: var(--pink-mid);
    box-shadow: 0 0 0 4px rgba(255, 107, 181, 0.15);
}

.hint {
    margin-top: 8px;
    font-size: 0.75em;
    font-weight: 600;
    color: var(--muted);
}

.hint kbd {
    background: var(--pink-pale);
    border: 1.5px solid var(--pink-light);
    padding: 1px 7px;
    border-radius: 6px;
    font-family: monospace;
    color: var(--pink-deep);
}

.btn-convert {
    margin-top: 20px;
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--pink-mid), var(--pink-deep));
    color: white;
    border: none;
    border-radius: 100px;
    font-family: var(--display);
    font-size: 1.15em;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 20px var(--shadow);
    position: relative;
    overflow: hidden;
}

.btn-convert::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: left 0.4s;
}

.btn-convert:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px var(--shadow);
}

.btn-convert:hover::after {
    left: 160%;
}

.btn-convert:active {
    transform: translateY(0);
}

#results {
    margin-top: 24px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.result-title {
    font-family: var(--display);
    font-size: 1.05em;
    color: var(--pink-deep);
}

.badge {
    font-size: 0.75em;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 100px;
    background: var(--pink-pale);
    color: var(--pink-deep);
    border: 1.5px solid var(--pink-light);
}

.grade-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--pink-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    margin-bottom: 10px;
    gap: 12px;
    transition: all 0.2s;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    position: relative;
    overflow: hidden;
}

.grade-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: linear-gradient(180deg, var(--pink-mid), var(--pink-deep));
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.grade-item:hover {
    border-color: var(--pink-mid);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow);
}

.subject-info {
    flex: 1;
    min-width: 0;
    padding-left: 8px;
}

.subject-code {
    font-size: 0.8em;
    font-weight: 800;
    color: var(--pink-deep);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.subject-name {
    font-size: 0.92em;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grade-display {
    text-align: right;
    flex-shrink: 0;
}

.gwa-figure {
    font-family: var(--display);
    font-size: 1.7em;
    line-height: 1;
}

.gwa-figure.passed {
    color: var(--green);
}

.gwa-figure.cond {
    color: var(--yellow);
}

.gwa-figure.failed {
    color: var(--red);
}

.gwa-figure.special {
    color: var(--muted);
}

.raw-pct {
    font-size: 0.72em;
    font-weight: 700;
    color: var(--muted);
    margin-top: 3px;
}

.pct-range {
    font-size: 0.72em;
    font-weight: 800;
    color: var(--pink-mid);
    margin-top: 1px;
}

.flash {
    padding: 13px 18px;
    border-radius: 14px;
    font-size: 0.85em;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flash.error {
    background: #fff0f3;
    border: 2px solid #ffb3c1;
    color: var(--red);
}

.flash.success {
    background: #f0fff6;
    border: 2px solid #a8efc4;
    color: var(--pink-mid);
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font);
    font-size: 0.8em;
    font-weight: 800;
    padding: 7px 16px;
    background: var(--white);
    border: 2px solid var(--pink-light);
    border-radius: 100px;
    color: var(--pink-deep);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--pink-deep);
    color: white;
    border-color: var(--pink-deep);
}

.btn-copy.copied {
    background: #2d8a55;
    color: white;
    border-color: #2d8a55;
}

#tablePanel {
    display: none;
}

#tablePanel.active {
    display: block;
}

#converterPanel.hidden {
    display: none;
}

.grading-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
    font-size: 0.88em;
}

.grading-table th {
    text-align: left;
    padding: 8px 16px;
    color: var(--muted);
    font-size: 0.8em;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.grading-table td {
    padding: 11px 16px;
    background: var(--pink-card);
    font-weight: 700;
    color: var(--text);
}

.grading-table td:first-child {
    border-radius: 12px 0 0 12px;
    border-left: 4px solid var(--pink-light);
}

.grading-table td:last-child {
    border-radius: 0 12px 12px 0;
}

.figure-cell {
    font-family: var(--display);
    font-size: 1.1em;
}

.figure-cell.passed {
    color: var(--green);
}

.figure-cell.cond {
    color: var(--yellow);
}

.figure-cell.failed {
    color: var(--red);
}

.figure-cell.special {
    color: var(--muted);
}

.footer {
    text-align: center;
    margin-top: 32px;
    font-size: 0.8em;
    color: var(--muted);
    font-weight: 600;
}

.footer span {
    color: var(--pink-deep);
}

@media (max-width: 600px) {
    .card-body {
        padding: 20px 16px;
    }

    h1 {
        font-size: 2em;
    }

    .grade-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .grade-display {
        align-self: flex-end;
    }
}