/*
 * Drosat Arcade Kit — shared chrome for every arcade game.
 * Owns: HUD header, pause menu, start / results / levels modals, question panel,
 * feedback toast, touch pads. Games keep only their world art in their own CSS.
 */

:root {
    --ak-navy-950: #030a1c;
    --ak-navy-900: #061230;
    --ak-navy-800: #0a1a42;
    --ak-navy-700: #102559;
    --ak-brand: #00337c;
    --ak-blue: #1384e3;
    --ak-blue-300: #7cc8ff;
    --ak-cyan: #3ad6ff;
    --ak-gold: #f4b41a;
    --ak-gold-300: #ffd56b;
    --ak-success: #22c58b;
    --ak-danger: #f05252;
    --ak-text: #f4f8ff;
    --ak-muted: #a6b6d6;
    --ak-dim: #7187b3;

    --ak-surface: rgba(8, 20, 52, 0.78);
    --ak-surface-strong: rgba(9, 22, 58, 0.97);
    --ak-surface-soft: rgba(255, 255, 255, 0.06);
    --ak-line: rgba(124, 200, 255, 0.2);
    --ak-line-strong: rgba(124, 200, 255, 0.38);

    --ak-accent: var(--ak-blue);
    --ak-grad-primary: linear-gradient(135deg, #1d93f0 0%, #0b5bc4 55%, #00337c 100%);
    --ak-grad-gold: linear-gradient(135deg, #ffd56b 0%, #f4b41a 60%, #e39a06 100%);

    --ak-radius-sm: 12px;
    --ak-radius: 16px;
    --ak-radius-lg: 24px;
    --ak-shadow: 0 18px 50px rgba(0, 6, 24, 0.55);
    --ak-blur: blur(14px);

    --ak-font: 'Cairo', 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ak-font-num: 'Fredoka', 'Cairo', system-ui, sans-serif;

    --ak-gap: 10px;
    --ak-edge: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
    --ak-top: max(10px, env(safe-area-inset-top));
    --ak-bottom: max(12px, env(safe-area-inset-bottom));
    --ak-hud-h: 52px;
    --ak-tap: 44px;
}

/* ───────────────────────── Base ───────────────────────── */

html.ak-root,
.ak-game {
    -webkit-text-size-adjust: 100%;
}

.ak-game {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--ak-navy-950);
    color: var(--ak-text);
    font-family: var(--ak-font);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.ak-game *,
.ak-game *::before,
.ak-game *::after {
    box-sizing: border-box;
}

.ak-game :is(button, a, input, select) {
    font: inherit;
    color: inherit;
}

.ak-game :is(button, a, [role="button"]):focus-visible {
    outline: 3px solid var(--ak-gold);
    outline-offset: 2px;
}

.ak-game [hidden] {
    display: none !important;
}

.ak-svg {
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    display: inline-block;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ak-svg--fill {
    fill: currentColor;
    stroke: none;
}

.ak-num {
    font-family: var(--ak-font-num);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
}

/* ───────────────────────── Buttons ───────────────────────── */

.ak-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 22px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
    touch-action: manipulation;
    white-space: normal;
    overflow-wrap: anywhere;
}

.ak-btn .ak-svg {
    font-size: 1.2em;
}

.ak-btn:active {
    transform: translateY(1px) scale(0.985);
}

.ak-btn:disabled,
.ak-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.ak-btn--primary {
    background: var(--ak-grad-primary);
    color: #fff;
    border-color: rgba(124, 200, 255, 0.35);
    box-shadow: 0 10px 26px rgba(19, 132, 227, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.ak-btn--primary:hover:not(:disabled) {
    box-shadow: 0 12px 32px rgba(19, 132, 227, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.ak-btn--gold {
    background: var(--ak-grad-gold);
    color: #1b1300;
    border-color: rgba(255, 228, 150, 0.6);
    box-shadow: 0 10px 26px rgba(244, 180, 26, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.ak-btn--gold:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 32px rgba(244, 180, 26, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.ak-btn--ghost {
    background: var(--ak-surface-soft);
    color: var(--ak-text);
    border-color: var(--ak-line);
}

.ak-btn--ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--ak-line-strong);
}

.ak-btn--block {
    width: 100%;
}

.ak-btn--lg {
    min-height: 56px;
    font-size: 18px;
    border-radius: 16px;
}

.ak-btn.is-loading {
    pointer-events: none;
}

.ak-btn.is-loading::after {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    animation: ak-spin 0.8s linear infinite;
}

.ak-icon-btn {
    width: var(--ak-tap);
    height: var(--ak-tap);
    min-width: var(--ak-tap);
    display: inline-grid;
    place-items: center;
    padding: 0;
    border-radius: 14px;
    border: 1px solid var(--ak-line);
    background: var(--ak-surface);
    color: var(--ak-text);
    font-size: 21px;
    cursor: pointer;
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    box-shadow: 0 6px 18px rgba(0, 6, 24, 0.35);
    transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease;
    touch-action: manipulation;
}

.ak-icon-btn:hover {
    border-color: var(--ak-line-strong);
    background: var(--ak-surface-strong);
}

.ak-icon-btn:active {
    transform: scale(0.94);
}

/* ───────────────────────── HUD header ───────────────────────── */

.ak-hud {
    position: fixed;
    inset-inline: 0;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ak-gap);
    padding: var(--ak-top) var(--ak-edge) 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ak-hud > * {
    pointer-events: auto;
}

.ak-hud__group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: nowrap;
}

.ak-hud__group--stats {
    justify-content: flex-end;
    flex-shrink: 1;
}

.ak-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: var(--ak-tap);
    padding: 4px 14px 4px 4px;
    border-radius: 14px;
    border: 1px solid var(--ak-line);
    background: var(--ak-surface);
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    box-shadow: 0 6px 18px rgba(0, 6, 24, 0.35);
    min-width: 0;
}

[dir="rtl"] .ak-brand {
    padding: 4px 4px 4px 14px;
}

.ak-logo-plate {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    height: 100%;
    padding: 2px 9px;
    border-radius: 10px;
    background: #fff;
    box-shadow: inset 0 -1px 0 rgba(0, 51, 124, 0.12);
}

.ak-logo-plate img {
    display: block;
    height: 26px;
    width: auto;
}

.ak-brand__title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22ch;
}

.ak-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--ak-line);
    background: var(--ak-surface);
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    color: var(--ak-blue-300);
}

.ak-chip .ak-svg {
    font-size: 16px;
}

.ak-stat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: var(--ak-tap);
    min-width: 0;
    padding: 0 13px;
    border-radius: 14px;
    border: 1px solid var(--ak-line);
    background: var(--ak-surface);
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    box-shadow: 0 6px 18px rgba(0, 6, 24, 0.35);
    font-family: var(--ak-font-num);
    font-size: 17px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--ak-text);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.ak-stat > .ak-svg {
    font-size: 19px;
    color: var(--ak-stat-color, var(--ak-blue-300));
}

.ak-stat--gold { --ak-stat-color: var(--ak-gold); }
.ak-stat--red { --ak-stat-color: #ff6b81; }
.ak-stat--green { --ak-stat-color: var(--ak-success); }
.ak-stat--cyan { --ak-stat-color: var(--ak-cyan); }

.ak-stat__label {
    font-family: var(--ak-font);
    font-size: 12px;
    font-weight: 700;
    color: var(--ak-muted);
}

.ak-stat.is-bump {
    animation: ak-bump 0.35s ease;
    border-color: var(--ak-gold);
}

/* hearts / lives */
.ak-lives {
    display: inline-flex;
    gap: 2px;
    color: #ff6b81;
    font-size: 17px;
}

.ak-lives .is-lost {
    opacity: 0.22;
}

/* ───────────────────────── Question panel ───────────────────────── */

.ak-question {
    position: fixed;
    z-index: 30;
    top: calc(var(--ak-top) + var(--ak-hud-h) + 8px);
    left: 50%;
    width: min(720px, calc(100% - 2 * var(--ak-edge)));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 18px 12px;
    border-radius: var(--ak-radius);
    border: 1px solid var(--ak-line-strong);
    background: linear-gradient(180deg, rgba(10, 26, 66, 0.9), rgba(6, 16, 44, 0.88));
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    box-shadow: var(--ak-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ak-question--bottom {
    top: auto;
    bottom: calc(var(--ak-bottom) + var(--ak-pad-h, 0px));
}

.ak-question__tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(244, 180, 26, 0.12);
    color: var(--ak-gold-300);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-question__text {
    width: 100%;
    margin: 0;
    font-size: var(--ak-fit-size, 22px);
    font-weight: 800;
    line-height: 1.5;
    color: #fff;
    overflow-wrap: anywhere;
    text-wrap: balance;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.ak-question__hint {
    max-width: 100%;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ak-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-question__hint:empty,
.ak-question__tag:empty {
    display: none;
}

.ak-question.is-pulse {
    animation: ak-pulse 0.5s ease;
}

/* ───────────────────────── Feedback toast ───────────────────────── */

.ak-feedback {
    position: fixed;
    z-index: 45;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%) scale(0.9);
    max-width: calc(100% - 2 * var(--ak-edge));
    padding: 10px 22px;
    border-radius: 999px;
    border: 1px solid var(--ak-line-strong);
    background: var(--ak-surface-strong);
    box-shadow: var(--ak-shadow);
    font-size: clamp(17px, 3.6vw, 24px);
    font-weight: 900;
    text-align: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.ak-feedback.is-show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.ak-feedback--good {
    border-color: rgba(34, 197, 139, 0.7);
    background: linear-gradient(135deg, rgba(14, 92, 70, 0.96), rgba(6, 46, 40, 0.96));
}

.ak-feedback--bad {
    border-color: rgba(240, 82, 82, 0.7);
    background: linear-gradient(135deg, rgba(110, 22, 34, 0.96), rgba(56, 10, 22, 0.96));
}

.ak-feedback--gold {
    border-color: rgba(244, 180, 26, 0.75);
    background: linear-gradient(135deg, rgba(110, 76, 6, 0.96), rgba(60, 38, 4, 0.96));
}

/* ───────────────────────── Touch pads ───────────────────────── */

.ak-pads {
    position: fixed;
    z-index: 30;
    inset-inline: 0;
    bottom: 0;
    display: none;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 0 var(--ak-edge) var(--ak-bottom);
    pointer-events: none;
}

.ak-touch .ak-pads {
    display: flex;
}

.ak-pads__group {
    display: flex;
    gap: 10px;
    pointer-events: auto;
    direction: ltr; /* ◀ ▶ keep their physical order in RTL */
}

.ak-pad {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    border: 1px solid var(--ak-line-strong);
    background: rgba(8, 20, 52, 0.62);
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    color: #fff;
    font-size: 28px;
    font-weight: 900;
    box-shadow: 0 8px 22px rgba(0, 6, 24, 0.4);
    touch-action: none;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease;
}

.ak-pad--wide {
    width: auto;
    min-width: 88px;
    padding: 0 16px;
    font-size: 15px;
}

.ak-pad--accent {
    background: var(--ak-grad-primary);
}

.ak-pad--gold {
    background: var(--ak-grad-gold);
    color: #1b1300;
}

.ak-pad.is-active,
.ak-pad:active {
    transform: scale(0.93);
    background: rgba(19, 132, 227, 0.55);
}

.ak-keys {
    position: fixed;
    z-index: 29;
    left: 50%;
    bottom: var(--ak-bottom);
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: calc(100% - 2 * var(--ak-edge));
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--ak-line);
    background: var(--ak-surface);
    -webkit-backdrop-filter: var(--ak-blur);
    backdrop-filter: var(--ak-blur);
    font-size: 13px;
    font-weight: 700;
    color: var(--ak-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.ak-keys kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    border-radius: 6px;
    border: 1px solid var(--ak-line-strong);
    background: rgba(255, 255, 255, 0.08);
    font-family: var(--ak-font-num);
    font-size: 12px;
    color: #fff;
    text-align: center;
}

.ak-touch .ak-keys,
.ak-keys.is-faded {
    opacity: 0;
}

/* ───────────────────────── Modals ───────────────────────── */

.ak-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--ak-top) + 12px) var(--ak-edge) var(--ak-bottom);
    background:
        radial-gradient(circle at 50% 0%, rgba(19, 132, 227, 0.22), transparent 55%),
        rgba(2, 8, 24, 0.8);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    animation: ak-fade 0.22s ease;
}

.ak-modal[aria-hidden="true"] {
    display: none;
}

.ak-modal__card {
    position: relative;
    width: min(520px, 100%);
    margin: auto;
    padding: 22px 22px 20px;
    border-radius: var(--ak-radius-lg);
    border: 1px solid var(--ak-line-strong);
    background:
        radial-gradient(circle at 50% -10%, color-mix(in srgb, var(--ak-accent) 26%, transparent), transparent 60%),
        linear-gradient(180deg, #0c1f4e 0%, #081639 100%);
    box-shadow: var(--ak-shadow), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    text-align: center;
    animation: ak-pop 0.3s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.ak-modal__card--wide {
    width: min(760px, 100%);
}

.ak-modal__exit {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    border: 1px solid var(--ak-line-strong);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    font-size: 20px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease;
}

.ak-modal__exit:hover {
    background: #13317a;
    border-color: var(--ak-gold);
    transform: translateX(-2px);
}

.ak-modal__logo {
    display: flex;
    justify-content: center;
    margin: 0 auto 14px;
}

.ak-modal__logo .ak-logo-plate {
    height: 46px;
    padding: 4px 16px;
    border-radius: 14px;
    box-shadow: 0 8px 22px rgba(0, 6, 24, 0.35);
}

.ak-modal__logo .ak-logo-plate img {
    height: 36px;
}

.ak-modal__hero {
    width: 74px;
    height: 74px;
    margin: 0 auto 10px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    border: 1px solid color-mix(in srgb, var(--ak-accent) 55%, transparent);
    background: linear-gradient(145deg, color-mix(in srgb, var(--ak-accent) 32%, #0a1a42), #0a1a42);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--ak-accent) 30%, transparent);
    font-size: 38px;
    line-height: 1;
}

.ak-modal__hero .ak-svg {
    font-size: 38px;
}

.ak-modal__hero--win {
    --ak-accent: var(--ak-gold);
    color: var(--ak-gold-300);
}

.ak-modal__hero--lose {
    --ak-accent: #ff6b81;
    color: #ffb3bf;
}

.ak-modal__title {
    margin: 0 0 6px;
    font-size: clamp(22px, 4.6vw, 28px);
    font-weight: 900;
    line-height: 1.3;
    color: #fff;
    overflow-wrap: anywhere;
}

.ak-modal__desc {
    margin: 0 auto 16px;
    max-width: 44ch;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.7;
    color: var(--ak-muted);
    overflow-wrap: anywhere;
}

.ak-modal__section {
    margin: 0 0 16px;
}

.ak-modal__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--ak-gold-300);
}

.ak-modal__actions {
    display: grid;
    gap: 10px;
}

.ak-modal__actions--row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* session (course / unit) chip */
.ak-session {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    margin: 0 auto 14px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(244, 180, 26, 0.35);
    background: rgba(244, 180, 26, 0.08);
    color: var(--ak-gold-300);
    font-size: 13px;
    font-weight: 700;
}

.ak-session span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* how-to tiles */
.ak-tips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin: 0 0 16px;
}

.ak-tip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: var(--ak-radius-sm);
    border: 1px solid var(--ak-line);
    background: var(--ak-surface-soft);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--ak-text);
    overflow-wrap: anywhere;
}

.ak-tip__icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(19, 132, 227, 0.16);
    color: var(--ak-blue-300);
    font-size: 20px;
}

.ak-tips.ak-tips--list {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
}

.ak-tips--list .ak-tip {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    text-align: start;
    font-size: 13px;
}

.ak-tips--list .ak-tip__icon {
    flex: none;
    width: 32px;
    height: 32px;
    font-size: 17px;
}

/* stats grid (results) */
.ak-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 16px;
}

.ak-stats__item {
    padding: 10px 8px;
    border-radius: var(--ak-radius-sm);
    border: 1px solid var(--ak-line);
    background: var(--ak-surface-soft);
    min-width: 0;
}

.ak-stats__label {
    font-size: 12px;
    font-weight: 700;
    color: var(--ak-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-stats__value {
    margin-top: 2px;
    font-family: var(--ak-font-num);
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.ak-stats__item--gold .ak-stats__value { color: var(--ak-gold-300); }
.ak-stats__item--blue .ak-stats__value { color: var(--ak-blue-300); }
.ak-stats__item--green .ak-stats__value { color: #6ee7b7; }

/* stars */
.ak-stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 2px 0 14px;
    color: rgba(255, 255, 255, 0.18);
    font-size: 34px;
}

.ak-stars .is-on {
    color: var(--ak-gold);
    filter: drop-shadow(0 0 10px rgba(244, 180, 26, 0.55));
    animation: ak-star 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.ak-stars .is-on:nth-child(2) { animation-delay: 0.12s; }
.ak-stars .is-on:nth-child(3) { animation-delay: 0.24s; }

/* menu grid (pause) */
.ak-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin: 12px 0 0;
}

.ak-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 82px;
    padding: 10px 6px;
    border-radius: var(--ak-radius);
    border: 1px solid var(--ak-line);
    background: var(--ak-surface-soft);
    color: var(--ak-text);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.ak-menu-item .ak-svg {
    font-size: 24px;
    color: var(--ak-blue-300);
}

.ak-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--ak-line-strong);
}

.ak-menu-item:active {
    transform: scale(0.97);
}

.ak-menu-item.is-off .ak-svg {
    color: #ff8fa0;
}

/* leaderboard */
.ak-board {
    margin: 0 0 16px;
    padding: 8px;
    border-radius: var(--ak-radius);
    border: 1px solid var(--ak-line);
    background: rgba(0, 0, 0, 0.16);
    text-align: start;
}

.ak-board__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
}

.ak-board__row:nth-child(-n+3) {
    background: rgba(244, 180, 26, 0.07);
}

.ak-board__rank {
    width: 24px;
    text-align: center;
    color: var(--ak-gold-300);
    font-family: var(--ak-font-num);
}

.ak-board__name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-board__score {
    color: var(--ak-blue-300);
    font-family: var(--ak-font-num);
}

.ak-board__empty {
    padding: 8px;
    text-align: center;
    color: var(--ak-muted);
    font-size: 13px;
}

/* ───────────────────────── Levels ───────────────────────── */

.ak-levels {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(122px, 1fr));
    gap: 10px;
    margin: 4px 0 16px;
    text-align: center;
}

.ak-level {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 124px;
    padding: 12px 8px 10px;
    border-radius: var(--ak-radius);
    border: 1px solid var(--ak-line);
    background: var(--ak-surface-soft);
    color: var(--ak-text);
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ak-level:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--ak-line-strong);
    background: rgba(255, 255, 255, 0.09);
}

.ak-level.is-current {
    border-color: var(--ak-gold);
    box-shadow: 0 0 0 2px rgba(244, 180, 26, 0.25), 0 10px 26px rgba(244, 180, 26, 0.18);
}

.ak-level:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.ak-level__num {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(19, 132, 227, 0.2);
    color: var(--ak-blue-300);
    font-family: var(--ak-font-num);
    font-size: 13px;
    font-weight: 800;
}

.ak-level__icon {
    margin-top: 10px;
    font-size: 30px;
    line-height: 1.1;
}

.ak-level__icon .ak-svg {
    font-size: 28px;
    color: var(--ak-dim);
}

.ak-level__name {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.ak-level__stars {
    display: flex;
    gap: 2px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.2);
}

.ak-level__stars .is-on {
    color: var(--ak-gold);
}

/* level picker inside start modal (compact row) */
.ak-level-pick {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 14px;
    padding: 8px 8px 8px 14px;
    border-radius: var(--ak-radius);
    border: 1px solid var(--ak-line);
    background: var(--ak-surface-soft);
    text-align: start;
}

[dir="rtl"] .ak-level-pick {
    padding: 8px 14px 8px 8px;
}

.ak-level-pick__info {
    min-width: 0;
}

.ak-level-pick__kicker {
    font-size: 12px;
    font-weight: 700;
    color: var(--ak-muted);
}

.ak-level-pick__name {
    font-size: 16px;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ak-level-pick .ak-btn {
    min-height: 42px;
    padding: 6px 14px;
    font-size: 14px;
    flex: 0 0 auto;
}

/* ───────────────────────── Toast (top) ───────────────────────── */

.ak-toast {
    position: fixed;
    z-index: 120;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -12px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 2 * var(--ak-edge));
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid rgba(244, 180, 26, 0.6);
    background: var(--ak-surface-strong);
    color: var(--ak-gold-300);
    font-size: 14px;
    font-weight: 800;
    box-shadow: var(--ak-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ak-toast.is-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ───────────────────────── State helpers ───────────────────────── */

.ak-game.ak-has-modal .ak-hud,
.ak-game.ak-has-modal .ak-question,
.ak-game.ak-has-modal .ak-pads,
.ak-game.ak-has-modal .ak-keys {
    opacity: 0;
    pointer-events: none;
}

.ak-game.ak-has-modal .ak-hud > * {
    pointer-events: none;
}

.ak-game.ak-idle .ak-question,
.ak-game.ak-idle .ak-pads,
.ak-game.ak-idle .ak-keys {
    opacity: 0;
    pointer-events: none;
}

.ak-sr {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ───────────────────────── Animations ───────────────────────── */

@keyframes ak-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ak-pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes ak-spin { to { transform: rotate(360deg); } }
@keyframes ak-bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes ak-pulse { 0% { box-shadow: var(--ak-shadow), 0 0 0 0 rgba(244, 180, 26, 0.6); } 100% { box-shadow: var(--ak-shadow), 0 0 0 14px rgba(244, 180, 26, 0); } }
@keyframes ak-star { from { opacity: 0; transform: scale(0.3) rotate(-30deg); } to { opacity: 1; transform: none; } }

/* ───────────────────────── Responsive ───────────────────────── */

@media (max-width: 760px) {
    :root {
        --ak-hud-h: 44px;
        --ak-tap: 42px;
        --ak-gap: 6px;
    }

    .ak-brand__title {
        display: none;
    }

    .ak-brand,
    [dir="rtl"] .ak-brand {
        padding: 3px;
    }

    .ak-logo-plate img {
        height: 22px;
    }

    .ak-stat {
        padding: 0 10px;
        gap: 5px;
        font-size: 15px;
    }

    .ak-stat > .ak-svg {
        font-size: 17px;
    }

    .ak-stat__label,
    .ak-stat--optional {
        display: none;
    }

    .ak-chip {
        height: 30px;
        padding: 0 10px;
        font-size: 12px;
    }

    .ak-hud__group {
        gap: 6px;
    }

    .ak-question {
        padding: 8px 12px 10px;
        top: calc(var(--ak-top) + var(--ak-hud-h) + 6px);
    }

    .ak-question__text {
        font-size: var(--ak-fit-size, 18px);
    }

    .ak-question__hint {
        font-size: 12px;
    }

    .ak-pad {
        width: 58px;
        height: 58px;
        border-radius: 18px;
        font-size: 24px;
    }

    .ak-modal__card {
        padding: 20px 16px 16px;
        border-radius: 22px;
    }

    .ak-modal__hero {
        width: 62px;
        height: 62px;
        border-radius: 18px;
        font-size: 32px;
    }

    .ak-modal__desc {
        font-size: 14px;
        margin-bottom: 14px;
    }

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

    .ak-tip {
        padding: 10px 6px;
        font-size: 12px;
    }

    .ak-tip__icon {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }

    .ak-levels {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        gap: 8px;
    }

    .ak-level {
        min-height: 108px;
    }

    .ak-stats__value {
        font-size: 20px;
    }
}

@media (max-width: 380px) {
    .ak-hud__group--stats .ak-stat:nth-child(n+3) {
        display: none;
    }

    .ak-chip .ak-chip__text {
        display: none;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    :root {
        --ak-hud-h: 40px;
        --ak-tap: 40px;
    }

    .ak-question {
        width: min(560px, calc(100% - 2 * var(--ak-edge)));
        padding: 6px 12px 8px;
    }

    .ak-question__text {
        font-size: var(--ak-fit-size, 16px);
        line-height: 1.4;
    }

    .ak-question__hint,
    .ak-question__tag {
        display: none;
    }

    .ak-brand__title {
        display: none;
    }

    .ak-modal {
        padding-top: calc(var(--ak-top) + 10px);
    }

    .ak-modal__logo {
        margin-bottom: 8px;
    }

    .ak-modal__logo .ak-logo-plate {
        height: 38px;
    }

    .ak-modal__logo .ak-logo-plate img {
        height: 28px;
    }

    .ak-modal__hero {
        display: none;
    }

    .ak-modal__desc {
        margin-bottom: 10px;
    }

    .ak-pad {
        width: 54px;
        height: 54px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ak-game *,
    .ak-game *::before,
    .ak-game *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Narrow phones: keep the header on one row without overlaps */
@media (max-width: 480px) {
    .ak-chip .ak-chip__text {
        display: none;
    }

    .ak-chip {
        padding: 0 9px;
        gap: 4px;
    }

    .ak-stat {
        padding: 0 8px;
    }

    .ak-lives {
        font-size: 14px;
        gap: 1px;
    }

    .ak-hud {
        gap: 6px;
    }
}

/* ───────────────────────── In-game quiz (answer options inside a modal) ───────────────────────── */

.ak-quiz {
    margin: 0 0 14px;
    padding: 14px;
    border-radius: var(--ak-radius);
    border: 1px solid var(--ak-line);
    background: rgba(0, 0, 0, 0.18);
}

.ak-quiz__prompt {
    margin: 6px 0 4px;
    font-size: clamp(17px, 3.6vw, 21px);
    font-weight: 800;
    line-height: 1.55;
    color: #fff;
    overflow-wrap: anywhere;
}

.ak-quiz__hint {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ak-muted);
}

.ak-quiz__hint:empty {
    display: none;
}

.ak-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.ak-option,
.ak-options > button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--ak-line-strong);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.ak-options > button:hover:not(:disabled) {
    background: rgba(19, 132, 227, 0.22);
    border-color: var(--ak-blue-300);
}

.ak-options > button:active:not(:disabled) {
    transform: scale(0.98);
}

.ak-options > button:disabled {
    cursor: default;
    opacity: 0.6;
}

.ak-options > button.correct-burst,
.ak-options > button.is-correct {
    opacity: 1;
    background: rgba(34, 197, 139, 0.3);
    border-color: var(--ak-success);
}

.ak-options > button.wrong-burst,
.ak-options > button.wrong-shake,
.ak-options > button.is-wrong {
    opacity: 1;
    background: rgba(240, 82, 82, 0.25);
    border-color: var(--ak-danger);
    animation: ak-shake 0.35s ease;
}

@keyframes ak-shake {
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.ak-meter {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.ak-meter > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--ak-grad-gold);
    transition: width 0.35s ease;
}

.ak-meter-row {
    display: flex;
    justify-content: space-between;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 800;
    color: var(--ak-muted);
}

@media (max-width: 420px) {
    .ak-options {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 420px) {
    .ak-pads {
        gap: 8px;
    }

    .ak-pads__group {
        gap: 6px;
    }

    .ak-pad {
        width: 50px;
        height: 50px;
        border-radius: 15px;
        font-size: 21px;
    }

    .ak-pad--wide {
        width: auto;
        min-width: 76px;
    }
}

/* Session chip wraps instead of truncating long course / unit names */
.ak-session {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    border-radius: 16px;
}

.ak-session span {
    white-space: normal;
    overflow: visible;
}
