:root {
    --bg-1: #2b0f54;
    --bg-2: #57156f;
    --bg-3: #9b2fae;
    --card-bg: rgba(255, 255, 255, 0.12);
    --card-bg-strong: rgba(255, 255, 255, 0.2);
    --line: rgba(255, 255, 255, 0.25);
    --text: #fff6ff;
    --muted: #f6d9ff;
    --accent: #ffd166;
    --accent-2: #ff7eb6;
    --ok: #9dffb2;
    --err: #ffd1d9;
    --shadow: 0 12px 30px rgba(26, 8, 39, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 209, 102, 0.25), transparent 22%),
        radial-gradient(circle at 80% 10%, rgba(255, 126, 182, 0.22), transparent 30%),
        linear-gradient(140deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 30px auto;
    padding: 0 16px 28px;
}

h1, h2, h3, h4 {
    margin-top: 0;
    color: #fff;
}

a {
    color: #ffe89a;
}

.top-nav {
    margin-bottom: 18px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 14px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(5px);
}

.card.light {
    background: var(--card-bg-strong);
}

input,
textarea,
select,
button {
    font-family: inherit;
    font-size: 15px;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 9px 10px;
}

input,
textarea,
select {
    width: 100%;
    color: #2d1335;
    background: #fff;
}

textarea {
    min-height: 80px;
}

button,
.btn {
    display: inline-block;
    width: auto;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent), #ffbd4a);
    color: #4a1435;
    font-weight: 700;
    padding: 10px 14px;
}

.btn.secondary {
    background: linear-gradient(135deg, #ff9bc7, #ff7eb6);
    color: #4a1435;
}

.grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ok {
    color: var(--ok);
    font-weight: 600;
}

.err {
    color: var(--err);
    font-weight: 600;
}

.small {
    font-size: 12px;
    color: var(--muted);
}

.hint-locked {
    color: #ffe4f0;
}

.reorder-list {
    display: grid;
    gap: 10px;
}

.reorder-item {
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    cursor: pointer;
}

.reorder-item.dragging {
    opacity: 0.55;
    transform: scale(0.99);
}

.reorder-handle {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    font-weight: 800;
    border-radius: 8px;
    color: #4a1435;
    background: linear-gradient(135deg, var(--accent), #ffbd4a);
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.question-meta span {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 12px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 6, 30, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 16px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-card {
    width: min(960px, 96vw);
    max-height: 92vh;
    overflow: auto;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: linear-gradient(160deg, rgba(72, 25, 102, 0.95), rgba(44, 17, 66, 0.98));
    padding: 16px;
    box-shadow: var(--shadow);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.hint-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
}

body.modal-open {
    overflow: hidden;
}

img {
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
}

.table-scroll {
    width: 100%;
    overflow: auto;
    border-radius: 12px;
}

.table-scroll table {
    min-width: 820px;
}

.level-head {
    min-width: 160px;
}

.level-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-current {
    background: rgba(255, 209, 102, 0.28);
    box-shadow: inset 0 0 0 2px rgba(255, 209, 102, 0.45);
}

th,
td {
    border: 1px solid var(--line);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

th {
    background: rgba(255, 255, 255, 0.18);
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 16px 0;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .container {
        margin: 16px auto;
        padding: 0 12px 18px;
    }

    .card {
        padding: 14px;
        border-radius: 14px;
    }

    .top-nav {
        gap: 8px;
    }

    .btn,
    button {
        width: 100%;
        text-align: center;
    }

    .modal-card {
        width: 100%;
        padding: 12px;
        border-radius: 14px;
    }

    .modal-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .hint-row {
        flex-direction: column;
        align-items: stretch;
    }

    input,
    textarea,
    select {
        font-size: 16px; /* better on iOS */
    }
}
