:root {
    --bg: #f4f8ff;
    --panel: #ffffff;
    --text: #1f2a37;
    --muted: #5f6f82;
    --line: #dbe3f0;
    --primary: #1f7cf2;

    --water: #1f7cf2;
    --fire: #ef5a29;
    --earth: #2f9e44;
    --air: #f2c94c;

    --shadow: 0 12px 24px rgba(31, 42, 55, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Nunito Sans', sans-serif;
    color: var(--text);
    background: linear-gradient(140deg, #f6fbff 0%, #eef7ff 55%, #fff8ea 100%);
    min-height: 100vh;
}

h1,
h2,
h3,
.brand strong {
    font-family: 'Baloo 2', sans-serif;
    letter-spacing: 0.2px;
    margin: 0;
}

h1 {
    font-size: clamp(1.55rem, 2.3vw, 2.2rem);
}

p {
    margin-top: 0.45rem;
    margin-bottom: 0.8rem;
}

small,
.muted {
    color: var(--muted);
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin-inline: auto;
}

.page {
    padding: 1.25rem 0 2.5rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand small {
    display: block;
    margin-top: -0.2rem;
}

.brand-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--water), var(--fire));
    color: #fff;
    font-weight: 800;
    display: grid;
    place-items: center;
}

.menu {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.menu a {
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    font-weight: 700;
}

.menu a:hover {
    background: #eff4ff;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel.nested {
    padding: 1rem;
    margin-bottom: 0;
    box-shadow: none;
}

.panel-narrow {
    max-width: 560px;
    margin-inline: auto;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.stat-card {
    color: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.stat-card h2 {
    font-size: 2rem;
    line-height: 1;
}

.stat-card.water {
    background: linear-gradient(135deg, #2d95ff, #1f7cf2);
}

.stat-card.fire {
    background: linear-gradient(135deg, #ff7b3d, #ef5a29);
}

.stat-card.earth {
    background: linear-gradient(135deg, #43b75d, #2f9e44);
}

.alert {
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.alert-success {
    background: #eaf8ee;
    color: #23683a;
    border: 1px solid #b9e2c6;
}

.alert-error {
    background: #ffecec;
    color: #8f1b1b;
    border: 1px solid #ffc9c9;
}

.form-grid {
    display: grid;
    gap: 0.8rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-weight: 700;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c8d4e6;
    border-radius: 12px;
    padding: 0.7rem 0.75rem;
    background: #fff;
}

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

.btn {
    border: 1px solid #b7c7df;
    background: #fff;
    color: #1f2a37;
    border-radius: 12px;
    padding: 0.58rem 0.85rem;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #2d95ff, #1f7cf2);
}

.btn-danger {
    border-color: transparent;
    color: #fff;
    background: linear-gradient(135deg, #ff6b5f, #d93d31);
}

.btn-outline {
    border-color: #9cb5db;
}

.btn-sm {
    padding: 0.45rem 0.68rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

th,
td {
    padding: 0.65rem 0.55rem;
    border-bottom: 1px solid #e7edf7;
    text-align: left;
    vertical-align: top;
}

th {
    color: #4c5e75;
    font-size: 0.9rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    background: #eaf0ff;
    color: #35507d;
}

.badge-water {
    background: #dfeeff;
    color: #1f65be;
}

.badge-fire {
    background: #ffe5da;
    color: #a13714;
}

.badge-earth {
    background: #dff5e4;
    color: #216b35;
}

.badge-air {
    background: #fff5cf;
    color: #7a5d05;
}

.grid-2,
.grid-3,
.grid-live-top,
.grid-live-bottom {
    display: grid;
    gap: 0.8rem;
}

.qrcode-img {
    width: min(260px, 100%);
    border-radius: 12px;
    border: 1px solid #dde8f7;
    background: #fff;
}

.input-readonly {
    font-size: 0.92rem;
}

.simple-list {
    margin: 0;
    padding-left: 1.1rem;
    max-height: 200px;
    overflow: auto;
}

.timer-box {
    margin-top: 1rem;
    border-radius: 14px;
    background: #f1f7ff;
    border: 1px solid #c9ddfb;
    padding: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timer-box strong {
    font-size: 1.4rem;
}

.distribution-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
}

.dist-item {
    padding: 0.58rem 0.65rem;
    border-radius: 12px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    font-weight: 800;
}

.dist-water {
    background: linear-gradient(135deg, #2d95ff, #1f7cf2);
}

.dist-fire {
    background: linear-gradient(135deg, #ff7b3d, #ef5a29);
}

.dist-earth {
    background: linear-gradient(135deg, #43b75d, #2f9e44);
}

.dist-air {
    background: linear-gradient(135deg, #f8d46d, #efbc2c);
    color: #5a4600;
}

.student-shell {
    text-align: center;
}

.student-play {
    max-width: 900px;
    margin-inline: auto;
    display: grid;
    gap: 0.8rem;
}

.student-header {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
}

.student-timer {
    margin-top: 0;
}

.student-state.hidden,
.hidden {
    display: none !important;
}

.question-image,
.question-preview-image {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #dde7f7;
    margin: 0.6rem 0;
}

.answer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.68rem;
    margin-top: 0.8rem;
}

.element-card {
    border: 0;
    border-radius: 16px;
    color: #fff;
    text-align: left;
    padding: 0.9rem;
    min-height: 104px;
    display: grid;
    gap: 0.22rem;
    box-shadow: 0 8px 16px rgba(31, 42, 55, 0.18);
    cursor: pointer;
}

.element-card:active {
    transform: scale(0.99);
}

.element-card.water {
    background: linear-gradient(135deg, #2d95ff, #1f7cf2);
}

.element-card.fire {
    background: linear-gradient(135deg, #ff7b3d, #ef5a29);
}

.element-card.earth {
    background: linear-gradient(135deg, #43b75d, #2f9e44);
}

.element-card.air {
    background: linear-gradient(135deg, #f8d46d, #efbc2c);
    color: #553f00;
}

.element-icon {
    font-size: 1.3rem;
}

.element-name {
    font-size: 0.95rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.element-text {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.feedback {
    margin-top: 0.8rem;
    font-weight: 800;
}

.feedback.success {
    color: #22753d;
}

.feedback.error {
    color: #9a2416;
}

.ranking-list {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.35rem;
}

.ranking-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    border-bottom: 1px dashed #dbe6f8;
    padding-bottom: 0.35rem;
}

.podium {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.podium-item {
    border-radius: 12px;
    padding: 0.7rem;
    color: #fff;
    font-weight: 800;
}

.podium-item.pos-1 { background: linear-gradient(135deg, #2d95ff, #1f7cf2); }
.podium-item.pos-2 { background: linear-gradient(135deg, #43b75d, #2f9e44); }
.podium-item.pos-3 { background: linear-gradient(135deg, #ff7b3d, #ef5a29); }

.info-box {
    margin-top: 1rem;
    border-radius: 14px;
    border: 1px dashed #bfd2ee;
    background: #f4f9ff;
    padding: 0.8rem;
    display: grid;
    gap: 0.2rem;
}

.bg-shape {
    position: fixed;
    z-index: -1;
    border-radius: 100%;
    filter: blur(1px);
    opacity: 0.25;
}

.bg-shape-1 {
    width: 220px;
    height: 220px;
    background: #87d6ff;
    left: -80px;
    top: 16%;
}

.bg-shape-2 {
    width: 280px;
    height: 280px;
    background: #ffd181;
    right: -100px;
    bottom: 8%;
}

@media (min-width: 700px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }

    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-live-top {
        grid-template-columns: 1.2fr 1fr 1fr;
    }

    .grid-live-bottom {
        grid-template-columns: 1fr 1fr;
    }

    .answer-grid {
        grid-template-columns: 1fr 1fr;
    }
}
