:root {
    --bg1: #8ce6ff;
    --bg2: #59c8ff;
    --panel: #eafcff;
    --panel-2: #d9f6ff;
    --line: #1d87df;
    --line-dark: #0c68c4;
    --text: #104570;
    --shadow: 0 16px 40px rgba(2, 67, 126, 0.22);
    --white: #ffffff;
    --gold: #ffd54f;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255,255,255,.8), transparent 25%),
        linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(135deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%, transparent 100%);
    background-size: 180px 180px;
    opacity: .35;
}

.page-shell {
    width: min(980px, calc(100% - 24px));
    margin: 0 auto;
    padding: 22px 0 40px;
    position: relative;
    z-index: 1;
}

.logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.logo-pill {
    min-width: min(420px, 100%);
    background: linear-gradient(180deg, #62dbff 0%, #1bb0ff 100%);
    border: 4px solid var(--line);
    border-radius: 28px;
    color: #fff;
    text-align: center;
    padding: 10px 20px 14px;
    box-shadow: 0 12px 0 #0e7fd8, var(--shadow);
    text-shadow: 0 3px 0 rgba(8, 97, 168, .8);
}

.logo-pill h1 {
    margin: 2px 0 0;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1;
    letter-spacing: 1px;
}

.logo-small {
    display: inline-block;
    background: rgba(255,255,255,.24);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .9rem;
    font-weight: 700;
}

.panel {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border: 4px solid var(--line);
    border-radius: 36px;
    padding: 20px;
    box-shadow: inset 0 3px 0 rgba(255,255,255,.9), var(--shadow);
    position: relative;
    overflow: hidden;
}

.panel::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255,255,255,.35) 0%, rgba(255,255,255,0) 45%);
}

.home-panel,
.create-panel,
.join-panel,
.form-panel,
.ranking-panel,
.top-panel {
    margin-bottom: 16px;
}

.small-gap {
    padding-bottom: 10px;
}

.pill-title {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 16px;
    padding: 10px 18px;
    background: linear-gradient(180deg, #55d7ff 0%, #1eaef6 100%);
    border: 4px solid var(--line);
    border-radius: 24px;
    color: var(--white);
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .8px;
    box-shadow: 0 8px 0 #0f7fd7;
    text-shadow: 0 2px 0 rgba(8, 97, 168, .8);
}

.center {
    text-align: center;
}

.muted {
    opacity: .86;
}

.info-note {
    margin: 14px auto 0;
    max-width: 760px;
    background: rgba(255,255,255,.65);
    border: 2px dashed rgba(16, 69, 112, .24);
    border-radius: 18px;
    padding: 12px 14px;
    font-size: .95rem;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 176px;
    text-decoration: none;
    color: var(--text);
    background: linear-gradient(180deg, #7ae6ff 0%, #38beff 100%);
    border: 4px solid var(--line);
    border-radius: 28px;
    padding: 18px 14px;
    box-shadow: 0 10px 0 #0f7fd7;
    transition: transform .15s ease, box-shadow .15s ease;
    text-align: center;
}

.level-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 13px 0 #0f7fd7;
}

.level-number {
    display: inline-flex;
    width: 58px;
    height: 58px;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: linear-gradient(180deg, #a8f2ff 0%, #6ddcff 100%);
    border: 4px solid var(--line);
    color: var(--white);
    font-size: 1.7rem;
    font-weight: 900;
    text-shadow: 0 2px 0 rgba(8, 97, 168, .8);
    box-shadow: inset 0 3px 0 rgba(255,255,255,.7);
}

.level-icon {
    font-size: 1.6rem;
}

.level-name {
    font-size: .96rem;
    font-weight: 800;
    line-height: 1.2;
}

.test-preview-card {
    text-align: center;
    background: rgba(255,255,255,.48);
    border: 3px solid rgba(29, 135, 223, .2);
    border-radius: 28px;
    padding: 18px;
    margin-bottom: 16px;
}

.test-preview-card h2 {
    margin: 8px 0 8px;
}

.test-icon-big {
    font-size: 2.3rem;
}

.stack-form {
    max-width: 520px;
    margin: 0 auto;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
}

.game-input {
    width: 100%;
    background: rgba(255,255,255,.95);
    border: 4px solid var(--line);
    border-radius: 20px;
    padding: 14px 16px;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    box-shadow: inset 0 4px 0 rgba(255,255,255,.8);
}

.game-input.readonly {
    font-size: .9rem;
}

.game-input:focus {
    border-color: var(--line-dark);
}

.game-button,
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: linear-gradient(180deg, #67ddff 0%, #23b4ff 100%);
    color: var(--white);
    border: 4px solid var(--line);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 0 #0f7fd7;
    text-shadow: 0 2px 0 rgba(8, 97, 168, .8);
}

.game-button:hover,
.link-button:hover {
    transform: translateY(-1px);
}

.game-button.big {
    width: 100%;
    margin-top: 14px;
}

.game-button.small,
.link-button {
    font-size: .95rem;
    padding: 10px 12px;
}

.text-link {
    color: var(--line-dark);
    font-weight: 800;
    text-decoration: none;
}

.question-form {
    display: grid;
    gap: 14px;
}

.question-card {
    position: relative;
    background: rgba(255,255,255,.65);
    border: 3px solid rgba(29, 135, 223, .25);
    border-radius: 26px;
    padding: 16px 16px 14px 64px;
}

.question-number {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #7ae6ff 0%, #2fc1ff 100%);
    border: 3px solid var(--line);
    border-radius: 14px;
    color: var(--white);
    font-weight: 900;
    text-shadow: 0 2px 0 rgba(8, 97, 168, .8);
}

.question-text {
    margin: 0 0 14px;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.35;
}

.answer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.answer-pill {
    position: relative;
    cursor: pointer;
}

.answer-pill input {
    position: absolute;
    opacity: 0;
}

.answer-pill span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    background: linear-gradient(180deg, #ecfdff 0%, #c8f5ff 100%);
    border: 3px solid rgba(29, 135, 223, .38);
    border-radius: 18px;
    font-weight: 900;
    transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.answer-pill input:checked + span {
    background: linear-gradient(180deg, #67ddff 0%, #23b4ff 100%);
    color: var(--white);
    border-color: var(--line);
    transform: translateY(-2px);
    text-shadow: 0 2px 0 rgba(8, 97, 168, .8);
}

.submit-btn {
    margin-top: 4px;
}

.share-box,
.ai-box,
.result-banner {
    background: rgba(255,255,255,.72);
    border: 3px solid rgba(29, 135, 223, .22);
    border-radius: 24px;
    padding: 16px;
    margin-bottom: 16px;
}

.result-banner h2 {
    margin: 8px 0 8px;
    font-size: 1.5rem;
}

.result-badge,
.ai-chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(180deg, #7ae6ff 0%, #2fc1ff 100%);
    color: white;
    font-weight: 900;
    border: 3px solid var(--line);
    text-shadow: 0 2px 0 rgba(8, 97, 168, .8);
}

.share-link-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.ranking-list {
    display: grid;
    gap: 12px;
}

.ranking-row {
    display: grid;
    grid-template-columns: 96px 1fr auto;
    gap: 12px;
    align-items: center;
    background: rgba(255,255,255,.74);
    border: 3px solid rgba(29, 135, 223, .2);
    border-radius: 22px;
    padding: 12px;
}

.ranking-row.me {
    border-color: #f7c92b;
    box-shadow: 0 0 0 4px rgba(247, 201, 43, .18);
}

.rank-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 900;
}

.medal {
    font-size: 1.35rem;
}

.position {
    font-size: 1.1rem;
}

.rank-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rank-main strong {
    font-size: 1.05rem;
}

.rank-main span {
    opacity: .86;
}

.rank-score {
    min-width: 88px;
    text-align: right;
    font-weight: 900;
    color: var(--line-dark);
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100%, calc(100% - 14px));
    }

    .panel {
        border-radius: 28px;
        padding: 16px;
    }

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

    .ranking-row {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .rank-score {
        text-align: left;
    }

    .share-link-row,
    .answer-grid {
        grid-template-columns: 1fr;
    }

    .question-card {
        padding-left: 56px;
    }
}
