/* Sprint 37 pupil settings (approved option A). Shared by the settings page and the fight drawer (stage 2).
   Tokens live on .pset so nothing leaks into the rest of the game. The game is dark by design, so there is
   one dark palette. Every class is pset-* to stay clear of the teacher settings styles. */

.pset {
    --pset-ink: #0b1020;
    --pset-panel: rgba(10, 15, 30, 0.94);
    --pset-raise: #1b2540;
    --pset-line: rgba(255, 255, 255, 0.14);
    --pset-text: #eef1f8;
    --pset-muted: #aab4c8;
    --pset-gold: #ffd88a;
    --pset-gold-deep: #f2b544;
    --pset-gold-ink: #2b1a00;
    --pset-gold-fill: linear-gradient(#ffe7a3, #f2b544);
    --pset-tag-account: #8ec8f8;
    --pset-tag-device: #c7cbe0;
    --pset-tag-new: #7ee0a8;
    --pset-danger-text: #ffd2d2;
    --pset-danger-line: rgba(255, 143, 143, 0.5);
    --pset-danger-fill: rgba(255, 143, 143, 0.08);
    --pset-hit: #ff6b6b;
    --pset-hit-stroke: #2a0606;
    --pset-display: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
    --pset-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--pset-text);
    font-family: var(--pset-body);
    font-size: 16px;
    line-height: 1.5;
}

.pset *,
.pset *::before,
.pset *::after {
    box-sizing: border-box;
}

.pset :focus-visible {
    outline: 3px solid var(--pset-gold);
    outline-offset: 2px;
}

.pset-icon {
    width: 20px;
    height: 20px;
    flex: none;
}

/* ---------- Page frame ---------- */
.pset-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: radial-gradient(1200px 600px at 20% -10%, #1d2a52 0%, transparent 60%), linear-gradient(#0e1530, #0a0f22);
}

.pset-page__bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 28px;
    border-bottom: 1px solid var(--pset-line);
    background: rgba(5, 8, 18, 0.85);
    backdrop-filter: blur(6px);
}

.pset-page__title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font: 600 26px var(--pset-display);
    color: var(--pset-text);
}

.pset-page__title .pset-icon {
    width: 26px;
    height: 26px;
    color: var(--pset-gold);
}

.pset-page__body {
    flex: 1;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
}

.pset-nav {
    position: sticky;
    top: 69px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 22px 14px;
    border-right: 1px solid var(--pset-line);
    min-height: calc(100vh - 69px);
}

.pset-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 12px 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--pset-muted);
    font: 600 16px var(--pset-body);
    text-align: left;
    justify-content: flex-start;
    cursor: pointer;
}

.pset-nav button:hover,
.pset-nav button[aria-current="true"] {
    background: var(--pset-raise);
    color: var(--pset-text);
}

.pset-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px 28px 48px;
    min-width: 0;
}

.pset-card {
    max-width: 720px;
    padding: 20px 22px;
    border: 1px solid var(--pset-line);
    border-radius: 16px;
    background: var(--pset-panel);
    scroll-margin-top: 84px;
}

.pset-card--empty {
    display: none;
}

/* ---------- Section parts ---------- */
.pset-sec {
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-margin-top: 84px;
}

.pset-sec__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.pset-sec__title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font: 600 20px var(--pset-display);
    color: var(--pset-text);
}

.pset-sec__title .pset-icon {
    width: 22px;
    height: 22px;
    color: var(--pset-gold);
}

.pset-tag {
    padding: 2px 9px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.pset-tag--account { color: var(--pset-tag-account); }
.pset-tag--device { color: var(--pset-tag-device); }
.pset-tag--new { color: var(--pset-gold-ink); background: var(--pset-tag-new); border-color: var(--pset-tag-new); }

.pset-hint {
    margin: 0;
    font-size: 14px;
    color: var(--pset-muted);
}

.pset-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 48px;
}

.pset-row__label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 150px;
    font-weight: 600;
    font-size: 15.5px;
}

.pset-row__label .pset-icon { color: var(--pset-muted); }

.pset-row__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pset-row__title {
    font-weight: 600;
    font-size: 16px;
}

.pset-row__value {
    font-weight: 600;
    color: var(--pset-gold);
}

.pset-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Slider */
.pset-slide {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.pset-slide input {
    flex: 1;
    min-width: 0;
    height: 32px;
    accent-color: var(--pset-gold-deep);
    cursor: pointer;
}

.pset-slide input:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pset-slide__val {
    width: 3.2ch;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--pset-muted);
}

/* Switch */
.pset-switch {
    position: relative;
    flex: none;
    width: 64px;
    height: 36px;
    border: 2px solid var(--pset-line);
    border-radius: 999px;
    background: #2a3350;
    cursor: pointer;
    transition: background 0.15s;
}

.pset-switch__knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #dfe4f0;
    transition: left 0.15s;
}

.pset-switch[aria-checked="true"] {
    background: var(--pset-gold-deep);
    border-color: var(--pset-gold);
}

.pset-switch[aria-checked="true"] .pset-switch__knob {
    left: 31px;
    background: #fff;
}

/* Choice group (radio buttons as big words) */
.pset-seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 6px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
}

.pset-seg__opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 46px;
    padding: 6px 10px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--pset-text);
    font: 600 15px var(--pset-body);
    text-align: center;
    cursor: pointer;
}

.pset-seg__opt:hover { background: rgba(255, 255, 255, 0.06); }

.pset-seg__opt[aria-checked="true"] {
    background: var(--pset-gold-fill);
    border-color: var(--pset-gold);
    color: var(--pset-gold-ink);
}

.pset-seg__sub {
    font-weight: 500;
    font-size: 12.5px;
    line-height: 1.25;
    opacity: 0.85;
}

.pset-seg--stack { grid-auto-flow: row; }

.pset-seg--stack .pset-seg__opt {
    flex-direction: row;
    justify-content: space-between;
    padding: 8px 14px;
    text-align: left;
}

.pset-seg--stack .pset-seg__main {
    font-family: var(--pset-display);
    font-size: 17px;
}

/* Buttons */
.pset-btnrow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pset-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 8px 16px;
    border: 1px solid var(--pset-line);
    border-radius: 12px;
    background: var(--pset-raise);
    color: var(--pset-text);
    font: 600 15px var(--pset-body);
    cursor: pointer;
}

.pset-btn .pset-icon {
    width: 18px;
    height: 18px;
}

.pset-btn--gold {
    background: var(--pset-gold-fill);
    border-color: var(--pset-gold);
    color: var(--pset-gold-ink);
}

.pset-btn--danger {
    background: var(--pset-danger-fill);
    border-color: var(--pset-danger-line);
    color: var(--pset-danger-text);
}

.pset-saynote {
    margin: 0;
    min-height: 1em;
    font-size: 13.5px;
    color: var(--pset-gold);
}

/* EPIC 60 entry inside the You section */
.pset .wcs-entry {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    border: 1px solid var(--pset-line);
    border-radius: 12px;
    background: var(--pset-raise);
    color: var(--pset-text);
    text-decoration: none;
}

/* Reading sample */
.pset-reading-preview {
    margin-top: 4px;
}

/* ---------- Battle effects preview ("Show me a hit") ---------- */
.pset-fx {
    position: relative;
    height: 160px;
    overflow: hidden;
    border: 1px solid var(--pset-line);
    border-radius: 12px;
    background: #070a14;
}

.pset-fx__bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 70%;
    opacity: 0.85;
}

/* The slime and its hit number share one box, so "above the sprite" is measured from the sprite itself. */
.pset-fx__target {
    position: absolute;
    left: 50%;
    bottom: 8px;
    --pset-sprite-top: 62%;
    width: 104px;
    height: 104px;
    transform: translateX(-50%);
}

/* Idle sheet is 7 frames of 64 by 64; show the first frame. */
.pset-fx__slime {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-size: 700% 100%;
    background-position: 0 0;
    image-rendering: pixelated;
}

.pset-hit {
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    font: 700 30px var(--pset-display);
    color: var(--pset-hit);
    -webkit-text-stroke: 2px var(--pset-hit-stroke);
    paint-order: stroke fill;
    white-space: nowrap;
    pointer-events: none;
}

.pset-hit--full { animation: pset-hit-full 1s cubic-bezier(0.2, 0.8, 0.3, 1) forwards; }
.pset-hit--reduced { animation: pset-hit-reduced 1.1s ease-out forwards; }

/* Off: just the number, ABOVE the sprite and clear of it (never over it), no movement. The slime's
   visible pixels start about 62% down its 64 by 64 frame, so the number sits just above that line. */
.pset-hit--off {
    top: auto;
    bottom: calc(100% - var(--pset-sprite-top) + 6px);
    translate: -50% 0;
    font-size: 26px;
    animation: pset-hit-off 1.2s steps(1, end) forwards;
}

@keyframes pset-hit-full {
    0% { scale: 0.4; opacity: 0; }
    15% { scale: 1.7; opacity: 1; }
    35% { scale: 1.05; }
    100% { scale: 1; opacity: 0; translate: -50% -140%; }
}

@keyframes pset-hit-reduced {
    0% { opacity: 0; }
    15% { opacity: 1; }
    100% { opacity: 0; translate: -50% -120%; }
}

@keyframes pset-hit-off {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.pset-fx--shake { animation: pset-shake 0.32s linear; }

@keyframes pset-shake {
    0%, 100% { translate: 0 0; }
    20% { translate: -9px 3px; }
    40% { translate: 8px -4px; }
    60% { translate: -6px 2px; }
    80% { translate: 4px -1px; }
}

.pset-fx__flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    animation: pset-flash 0.14s linear;
}

@keyframes pset-flash {
    0% { opacity: 0.55; }
    100% { opacity: 0; }
}

/* ---------- Phone held sideways and smaller ---------- */
@media (max-height: 500px), (max-width: 900px) {
    .pset-page__bar { padding: 8px 16px; }
    .pset-page__title { font-size: 21px; }
    .pset-page__body { grid-template-columns: 170px minmax(0, 1fr); }
    .pset-nav { top: 57px; padding: 10px 8px; min-height: calc(100vh - 57px); }
    .pset-nav button { min-height: 44px; padding: 8px 10px; font-size: 14.5px; }
    .pset-content { padding: 12px 16px 24px; gap: 12px; }
    .pset-card { padding: 14px 16px; border-radius: 14px; scroll-margin-top: 64px; }
    .pset-sec { scroll-margin-top: 64px; }
    .pset-row__label { min-width: 120px; }
}

/* Phone held upright: the section list becomes a scrolling row under the bar. */
@media (max-width: 600px) {
    .pset-page__body { grid-template-columns: minmax(0, 1fr); }
    .pset-nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        min-height: 0;
        border-right: 0;
        border-bottom: 1px solid var(--pset-line);
    }
    .pset-nav button { flex: none; }
    .pset-row { flex-wrap: wrap; }
    .pset-row__label { min-width: 0; }
    .pset-slide { flex-basis: 100%; }
}

/* ---------- Fight drawer (option A): slides in from the right, the fight stays in view ---------- */
.pset-drawer-layer {
    position: fixed;
    inset: 0;
    z-index: 1300;
}

.pset-drawer-dim {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(3, 6, 14, 0.05), rgba(3, 6, 14, 0.45));
}

.pset-drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(400px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--pset-panel);
    border-left: 1px solid var(--pset-line);
    box-shadow: -20px 0 40px rgba(0, 0, 0, 0.4);
    animation: pset-drawer-in 0.2s ease-out;
}

@keyframes pset-drawer-in {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.pset-drawer__head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px 12px 20px;
    border-bottom: 1px solid var(--pset-line);
}

.pset-drawer__title {
    margin: 0;
    font: 600 24px var(--pset-display);
    color: var(--pset-text);
}

.pset-drawer__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 16px 20px 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.pset-drawer__body .pset-sec + .pset-sec {
    padding-top: 18px;
    border-top: 1px solid var(--pset-line);
}

.pset-iconbtn {
    flex: none;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid var(--pset-line);
    border-radius: 12px;
    background: var(--pset-raise);
    color: var(--pset-text);
    cursor: pointer;
}

.pset-iconbtn .pset-icon {
    width: 22px;
    height: 22px;
}

@media (max-height: 500px) {
    .pset-drawer { width: min(372px, 100vw); }
    .pset-drawer__head { padding: 6px 10px 6px 16px; }
    .pset-drawer__title { font-size: 20px; }
    .pset-drawer__body { padding: 12px 16px 18px; gap: 14px; }
    .pset-iconbtn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .pset-drawer { animation: none; }
}
