/* ============================================================
   CODEGURU CLASSIX - "PHOSPHOR ARCADE" DESIGN SYSTEM
   Retro-terminal identity, rebuilt with depth, hierarchy and
   a real arcade feel. Hebrew/RTL + responsive by design.
   ============================================================ */
:root {
    /* Legacy aliases (referenced by JS + inline markup) */
    --bg-dark: #05080a;
    --panel-bg: #0b1114;
    --neon-green: #3dff88;
    --dark-green: rgba(61, 255, 136, 0.28);
    --text-main: #d7f5e1;
    --text-muted: #93b8a0;
    --dim-green: #7ba58c;
    --warning: #ffb454;
    --error: #ff6b6b;
    --accent-cyan: #4fd8e8;

    /* Full palette */
    --bg-deep: #05080a;
    --bg-panel: #0b1114;
    --bg-raise: #101a18;
    --bg-inset: #060c0e;
    --line: rgba(61, 255, 136, 0.14);
    --line-strong: rgba(61, 255, 136, 0.38);
    --phosphor: #3dff88;
    --phosphor-soft: #8ff5b6;
    --phosphor-deep: #1fce66;
    --amber: #ffb454;
    --amber-deep: #f59e2c;
    --cyan: #4fd8e8;
    --text: #d7f5e1;
    --text-dim: #9ec3ab;
    --text-faint: #6f8f7b;
    --glow: 0 0 18px rgba(61, 255, 136, 0.32);
    --glow-soft: 0 0 32px rgba(61, 255, 136, 0.14);
    --radius: 12px;
    --radius-sm: 8px;
    --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "Fira Code",
        Menlo, Consolas, "Ubuntu Mono", "Noto Sans Mono", "Liberation Mono",
        "Courier New", "Noto Sans Hebrew", monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-mono);
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 90% 55% at 50% -10%, rgba(61, 255, 136, 0.09), transparent 60%),
        radial-gradient(ellipse 60% 45% at 85% 110%, rgba(79, 216, 232, 0.06), transparent 60%),
        linear-gradient(rgba(61, 255, 136, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(61, 255, 136, 0.025) 1px, transparent 1px);
    background-size: auto, auto, 44px 44px, 44px 44px;
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px 12px;
    line-height: 1.45;
}

::selection {
    background: var(--phosphor);
    color: #04140a;
}

/* Thin phosphor scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(61, 255, 136, 0.35) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(61, 255, 136, 0.3); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

#app-container {
    width: 1060px;
    max-width: 100%;
    min-height: 700px;
    background: linear-gradient(180deg, #0c1417 0%, #080e11 100%);
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    padding: 26px 30px 30px;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.55),
        0 0 70px rgba(61, 255, 136, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow: hidden;
}

/* CRT scanlines + vignette over the panel (purely decorative) */
#app-container::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.11) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse 120% 100% at 50% 50%, transparent 62%, rgba(0, 0, 0, 0.28) 100%);
    opacity: 0.55;
    z-index: 1;
}
#app-container > * { position: relative; z-index: 2; }

/* ========================================================
   BRAND HEADER
   ======================================================== */
header.brand {
    text-align: center;
    padding: 10px 0 18px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: linear-gradient(180deg, #10241a, #0a1710);
    color: var(--phosphor);
    font-weight: 800;
    font-size: 1.15em;
    letter-spacing: 0;
    box-shadow: var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    margin-bottom: 12px;
    user-select: none;
}

header.brand h1 {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.55em;
    flex-wrap: wrap;
    font-size: clamp(1.25rem, 3.2vw, 1.9rem);
    letter-spacing: 4px;
    margin-bottom: 6px;
}

.brand-main {
    color: var(--phosphor);
    font-weight: 800;
    text-shadow: 0 0 18px rgba(61, 255, 136, 0.5);
}

.brand-classix {
    color: var(--text);
    font-weight: 700;
    text-shadow: 0 0 14px rgba(215, 245, 225, 0.25);
}

.brand-100 {
    background: linear-gradient(180deg, #ffc46b, var(--amber-deep));
    color: #241300;
    font-weight: 800;
    font-size: 0.72em;
    padding: 3px 12px;
    border-radius: 999px;
    letter-spacing: 2px;
    box-shadow: 0 0 20px rgba(255, 180, 84, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transform: translateY(-0.12em);
}

.brand-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1.05em;
    background: var(--phosphor);
    border-radius: 2px;
    box-shadow: 0 0 12px rgba(61, 255, 136, 0.7);
    transform: translateY(0.16em);
    animation: blink 1.15s steps(1) infinite;
}

.brand-tag {
    color: var(--text-faint);
    font-size: 0.72rem;
    letter-spacing: 5px;
    text-transform: uppercase;
}

@keyframes blink {
    0%, 55% { opacity: 1; }
    56%, 100% { opacity: 0; }
}

/* ========================================================
   GLOBAL NAVIGATION BAR
   ======================================================== */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 10px;
    z-index: 60;
    background: rgba(7, 13, 10, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px 12px;
    margin-bottom: 22px;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    padding: 7px 13px;
    font-size: 0.8em;
    letter-spacing: 1.5px;
    border: 1px solid transparent;
    border-radius: 9px;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    text-transform: uppercase;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.nav-link:hover {
    color: var(--phosphor-soft);
    background: rgba(61, 255, 136, 0.09);
}

.nav-link.active {
    color: #04140a;
    background: linear-gradient(180deg, var(--phosphor), var(--phosphor-deep));
    border-color: transparent;
    box-shadow: 0 0 16px rgba(61, 255, 136, 0.4);
    text-shadow: none;
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82em;
    letter-spacing: 1px;
    flex-wrap: wrap;
}

.nav-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
}

.nav-badge .badge-label {
    color: var(--text-faint);
    font-size: 0.78em;
}

.nav-badge .badge-value {
    color: var(--phosphor);
    font-weight: 700;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-badge.team-badge .badge-value {
    color: var(--cyan);
}

.nav-btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 180, 84, 0.55);
    border-radius: 999px;
    color: var(--amber);
    font-size: 0.78em;
    padding: 6px 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 1px;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s;
    text-transform: uppercase;
    user-select: none;
}

.nav-btn-logout:hover {
    background: var(--amber);
    color: #241300;
    box-shadow: 0 0 16px rgba(255, 180, 84, 0.4);
}

#nav-lang-toggle {
    border-color: rgba(79, 216, 232, 0.55);
    color: var(--cyan);
}

#nav-lang-toggle:hover {
    background: var(--cyan);
    color: #062a30;
    box-shadow: 0 0 16px rgba(79, 216, 232, 0.4);
}

/* ========================================================
   RIDDLE CARDS
   ======================================================== */
.riddle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
    margin: 15px 0 20px;
}

.riddle-card {
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.riddle-card:hover {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    box-shadow: var(--glow-soft), 0 14px 30px rgba(0, 0, 0, 0.4);
}

.riddle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.riddle-title {
    color: var(--phosphor);
    font-size: 0.95em;
    font-weight: 700;
}

.riddle-digits {
    font-size: 1.5em;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--phosphor);
    background: var(--bg-inset);
    padding: 12px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    text-align: center;
    text-shadow: 0 0 10px rgba(61, 255, 136, 0.45);
    word-break: break-all;
}

.riddle-sequence {
    font-size: 1.05em;
    color: var(--phosphor-soft);
    letter-spacing: 2px;
    word-break: break-all;
    background: var(--bg-inset);
    padding: 8px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    text-align: center;
}

.riddle-meta {
    font-size: 0.8em;
    color: var(--text-faint);
    letter-spacing: 1px;
}

.riddle-meta span {
    color: var(--phosphor-soft);
}

/* ========================================================
   SCREENS AND WORKSPACE
   ======================================================== */
.screen {
    display: none;
    flex-direction: column;
    flex: 1;
}

.screen.active {
    display: flex;
}

.screen.hidden {
    display: none !important;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.team-name {
    color: var(--amber);
    font-size: 0.85em;
    font-weight: 400;
    text-shadow: 0 0 10px rgba(255, 180, 84, 0.25);
}

.timer-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.timer-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-ring circle {
    fill: transparent;
    stroke: var(--phosphor);
    stroke-width: 2;
    stroke-dasharray: 226;
    stroke-dashoffset: 0;
}

.timer-text {
    text-align: center;
    z-index: 2;
}

.timer-text span {
    display: block;
    font-size: 1.2em;
    font-weight: 700;
    color: var(--phosphor);
}

.timer-text small {
    font-size: 0.5em;
    color: var(--text-dim);
}

h2 {
    color: var(--phosphor);
    letter-spacing: 2px;
    font-size: 1.35em;
    text-shadow: 0 0 14px rgba(61, 255, 136, 0.35);
}

h3 {
    color: var(--phosphor-soft);
    margin-bottom: 10px;
    font-size: 0.95em;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.subtitle {
    color: var(--text-faint);
    font-size: 0.8em;
}

.workspace {
    flex: 1;
}

.competition-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--text-dim);
    font-size: 0.85em;
    letter-spacing: 1px;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    margin-bottom: 14px;
}

.competition-banner a {
    color: var(--amber);
    text-decoration: none;
    font-weight: 700;
}

.competition-banner a:hover {
    text-decoration: underline;
}

/* Unpicked competition: the banner still holds its pick-one link, so flag it */
.competition-banner:has(a) {
    border-color: rgba(255, 180, 84, 0.45);
    animation: banner-attn 2.4s ease-in-out infinite;
}

@keyframes banner-attn {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255, 180, 84, 0.10), 0 0 16px rgba(255, 180, 84, 0.06); }
    50% { box-shadow: 0 0 0 1px rgba(255, 180, 84, 0.30), 0 0 26px rgba(255, 180, 84, 0.16); }
}

/* ========================================================
   EXPRESSION BUILDER
   ======================================================== */
.expression-section {
    margin: 15px 0 20px;
}

.expression-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.digit-counter-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.digit-counter-label {
    font-size: 0.85em;
    color: var(--text-faint);
    letter-spacing: 1.5px;
}

.digit-counter {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--text-dim);
    border: 1px solid var(--line);
    background: var(--bg-inset);
    border-radius: 999px;
    padding: 4px 14px;
    letter-spacing: 2px;
    transition: all 0.25s ease;
}

.digit-counter.limit-reached {
    color: #04140a;
    background: linear-gradient(180deg, var(--phosphor), var(--phosphor-deep));
    border-color: transparent;
    box-shadow: 0 0 14px rgba(61, 255, 136, 0.55);
}

.expression-input-container {
    position: relative;
    width: 100%;
}

.expression-input {
    width: 100%;
    font-size: 1.7em;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--phosphor);
    background: var(--bg-inset);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 16px 18px;
    letter-spacing: 3px;
    outline: none;
    caret-color: var(--phosphor);
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.5);
    transition: border-color 0.2s, box-shadow 0.2s;
    user-select: text;
}

.expression-input:focus {
    border-color: var(--phosphor);
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(61, 255, 136, 0.16), var(--glow);
}

.expression-input::placeholder {
    color: var(--text-faint);
    opacity: 0.55;
    font-size: 0.55em;
    letter-spacing: 1px;
    font-weight: 400;
}

.locked-digits-section {
    margin: 15px 0 20px;
}

.locked-digits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.locked-digits-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}

.locked-digit-box {
    width: 52px;
    height: 68px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.6em;
    font-weight: 700;
    background: linear-gradient(180deg, #14211b, #0c1712);
    border: 1px solid var(--line-strong);
    border-bottom-width: 3px;
    border-radius: 10px;
    color: var(--phosphor);
    letter-spacing: 1px;
    position: relative;
    transition: all 0.25s ease;
    user-select: none;
}

.locked-digit-box .box-idx {
    font-size: 0.35em;
    color: var(--text-faint);
    position: absolute;
    top: 4px;
    inset-inline-start: 6px;
}

.locked-digit-box.used {
    background: linear-gradient(180deg, rgba(61, 255, 136, 0.3), rgba(61, 255, 136, 0.12));
    border-color: var(--phosphor);
    box-shadow: 0 0 14px rgba(61, 255, 136, 0.5);
    color: #ffffff;
}

.slot-container {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-bottom: 20px;
    background: transparent;
    padding: 15px 0;
    flex-wrap: nowrap;
}

.slot {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-inset);
    font-size: 1.4em;
    font-weight: 700;
}

.digit-slot {
    width: 60px;
    height: 80px;
    flex-shrink: 0;
}

.op-slot {
    width: 40px;
    height: 60px;
    flex-shrink: 0;
}

.slot.locked {
    background: #101a18 !important;
    border-color: var(--line) !important;
    color: var(--text-faint) !important;
    cursor: not-allowed;
}

/* Terminal readout */
.result-box {
    background: var(--bg-inset);
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-inline-start: 3px solid var(--phosphor);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    color: var(--text-dim);
    margin-bottom: 20px;
    letter-spacing: 1px;
    line-height: 1.7;
}

.result-box span {
    color: var(--phosphor);
}

.bottom-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    gap: 15px;
}

.input-banks {
    flex: 1;
    min-width: 0;
}

.bank {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.bank-label {
    width: 100px;
    min-width: 100px;
    font-size: 0.85em;
    color: var(--text-faint);
    letter-spacing: 1px;
    flex-shrink: 0;
}

.solving-panel .bank-label {
    width: 190px;
    min-width: 190px;
}

/* Key-cap tokens */
.token {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4em;
    font-weight: 700;
    cursor: grab;
    border: 1px solid var(--line-strong);
    border-bottom-width: 3px;
    border-radius: 10px;
    background: linear-gradient(180deg, #152219, #0c1712);
    color: var(--phosphor);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.18s, color 0.18s;
    user-select: none;
}

.token:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #1a2c20, #0e1b14);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), 0 0 14px rgba(61, 255, 136, 0.35);
}

.token:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

.token.operator {
    color: var(--amber);
    border-color: rgba(255, 180, 84, 0.4);
}

.token.operator:hover {
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 180, 84, 0.35);
}

.token.digit {
    width: 46px;
    height: 66px;
    flex-shrink: 0;
}

.token.operator {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.token.used {
    opacity: 0.25;
    pointer-events: none;
    filter: grayscale(0.6);
}

/* ========================================================
   BUTTONS
   ======================================================== */
.actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 230px;
    flex-shrink: 0;
}

.btn {
    padding: 12px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: linear-gradient(180deg, #14211b, #0c1712);
    color: var(--phosphor-soft);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s, color 0.18s, border-color 0.18s, filter 0.18s ease;
    letter-spacing: 1.5px;
    font-family: inherit;
    font-size: 0.9em;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    user-select: none;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: var(--phosphor);
    color: #eafff2;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4), var(--glow);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.btn.primary {
    background: linear-gradient(180deg, var(--phosphor), var(--phosphor-deep));
    border-color: transparent;
    color: #04140a;
    text-shadow: none;
    box-shadow: 0 0 22px rgba(61, 255, 136, 0.3), 0 3px 0 #0d7a3d;
}

.btn.primary:hover {
    color: #04140a;
    filter: brightness(1.1);
    box-shadow: 0 0 30px rgba(61, 255, 136, 0.5), 0 4px 0 #0d7a3d;
}

.btn.primary:active {
    box-shadow: 0 0 14px rgba(61, 255, 136, 0.3), 0 1px 0 #0d7a3d;
}

.btn.secondary {
    border-color: var(--line);
    color: var(--text-dim);
}

.btn.secondary:hover {
    border-color: var(--phosphor);
    color: var(--phosphor-soft);
}

.btn.warning {
    border-color: rgba(255, 180, 84, 0.55);
    color: var(--amber);
}

.btn.warning:hover {
    background: var(--amber);
    border-color: var(--amber);
    color: #241300;
    box-shadow: 0 0 18px rgba(255, 180, 84, 0.4);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: var(--bg-inset) !important;
    color: var(--text-faint) !important;
    border-color: var(--line) !important;
    box-shadow: none !important;
    transform: none !important;
    filter: none !important;
}

.btn:focus-visible {
    outline: 2px solid var(--phosphor);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(61, 255, 136, 0.18), 0 2px 0 rgba(0, 0, 0, 0.4);
}

.btn.loading {
    pointer-events: none;
    opacity: 0.75;
    position: relative;
}

.btn.loading::after {
    content: '';
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-inline-start: 8px;
    vertical-align: -0.1em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.8s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.guest-hero {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-inset);
    padding: 18px 22px;
    margin-bottom: 22px;
}

.guest-lead {
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0 0 14px;
    letter-spacing: 0.5px;
}

.guest-features {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guest-features li {
    color: var(--phosphor-soft);
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 0.92em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.guest-feat-mark {
    color: var(--phosphor);
    font-weight: 800;
    text-shadow: 0 0 8px rgba(61, 255, 136, 0.6);
}

.guest-rules-link {
    font-size: 0.85em;
    color: var(--text-faint);
    letter-spacing: 1px;
}

.guest-rules-link a {
    color: var(--phosphor);
    text-decoration: none;
    font-weight: 700;
}

.guest-rules-link a:hover {
    text-shadow: 0 0 10px rgba(61, 255, 136, 0.7);
}

.stats-panel {
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px;
    text-align: center;
    margin-inline-end: 20px;
}

.stats-panel h3 {
    margin-bottom: 0;
}

.stats-panel .counter {
    font-size: 2em;
    color: var(--phosphor);
    margin-top: 10px;
    text-shadow: 0 0 14px rgba(61, 255, 136, 0.45);
}

/* ========================================================
   AUTH FORMS (login / signup)
   ======================================================== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 460px;
    margin: 10px 0 20px;
}

.auth-form .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form label {
    font-size: 0.8em;
    letter-spacing: 1.5px;
    color: var(--text-faint);
    text-transform: uppercase;
}

.auth-form input,
.auth-form select {
    font-family: inherit;
    font-size: 1em;
    padding: 11px 13px;
    background: var(--bg-inset);
    color: var(--phosphor);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    outline: none;
    caret-color: var(--phosphor);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-form input:focus,
.auth-form select:focus {
    border-color: var(--phosphor);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(61, 255, 136, 0.14);
}

.auth-form input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--phosphor-deep);
    box-shadow: none;
    flex-shrink: 0;
}

.auth-hint {
    font-size: 0.88em;
    color: var(--text-faint);
    letter-spacing: 1px;
    align-self: center;
}

.auth-hint a {
    color: var(--cyan);
    text-decoration: none;
    border-bottom: 1px dashed rgba(79, 216, 232, 0.6);
    padding-bottom: 1px;
    transition: color 0.18s, text-shadow 0.18s;
}

.auth-hint a:hover {
    color: #a5ecf5;
    text-shadow: 0 0 10px rgba(79, 216, 232, 0.5);
}

/* ========================================================
   TEAM PAGE
   ======================================================== */
.key-row {
    display: flex;
    align-items: stretch;
    gap: 12px;
    flex-wrap: wrap;
    margin: 10px 0 6px;
}

.key-row .key-box {
    flex: 1;
    min-width: 260px;
    word-break: break-all;
    margin-bottom: 0;
}

.key-row .key-box span {
    color: var(--amber);
    text-shadow: 0 0 10px rgba(255, 180, 84, 0.3);
}

.team-note {
    display: block;
    margin-bottom: 24px;
    color: var(--text-faint);
    letter-spacing: 1px;
    font-size: 0.85em;
}

.inline-form {
    flex-direction: row;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    max-width: none;
    margin-bottom: 24px;
}

.inline-form .field {
    flex: 1;
    min-width: 260px;
}

/* ========================================================
   COMPETITIONS & HUBS
   ======================================================== */
.competition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 15px;
    margin-bottom: 25px;
}

.competition-card {
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
}

.competition-card:hover {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    box-shadow: var(--glow-soft), 0 14px 30px rgba(0, 0, 0, 0.4);
}

.competition-card h4 {
    color: var(--phosphor);
    font-size: 1.1em;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.competition-card .meta-item {
    font-size: 0.85em;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.competition-card .meta-item span {
    color: var(--text);
}

.tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.72em;
    font-weight: 700;
    border: 1px solid;
    border-radius: 999px;
    margin-bottom: 8px;
    letter-spacing: 1.5px;
}

.tag.open {
    color: var(--phosphor);
    border-color: rgba(61, 255, 136, 0.5);
    background: rgba(61, 255, 136, 0.08);
}

.tag.exclusive {
    color: var(--amber);
    border-color: rgba(255, 180, 84, 0.5);
    background: rgba(255, 180, 84, 0.08);
}

/* Signup extras */
.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 0.9em;
    cursor: pointer;
}

.checkbox-field a {
    color: var(--cyan);
}

#school-search-field {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-raise);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.autocomplete-list:empty {
    display: none;
}

.autocomplete-option,
.autocomplete-empty {
    padding: 9px 12px;
    color: var(--text);
}

.autocomplete-empty {
    color: var(--text-faint);
}

.autocomplete-option:hover {
    background: rgba(61, 255, 136, 0.12);
    cursor: pointer;
}

.legal-text p {
    color: var(--text-dim);
    line-height: 1.7;
    margin: 0 0 14px;
}

.legal-text a {
    color: var(--cyan);
}

.legal-text h3 {
    color: var(--phosphor);
    margin-top: 18px;
}

/* ========================================================
   ADMIN PANEL
   ======================================================== */
.admin-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.admin-tabs .btn {
    padding: 8px 16px;
    font-size: 0.8em;
}

.admin-tabs .btn.active {
    background: linear-gradient(180deg, var(--phosphor), var(--phosphor-deep));
    color: #04140a;
    border-color: transparent;
    box-shadow: 0 0 14px rgba(61, 255, 136, 0.35);
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-inset);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.admin-table th,
.admin-table td {
    padding: 9px 12px;
    text-align: start;
    vertical-align: top;
    color: var(--text);
    border-bottom: 1px solid var(--line);
}

.admin-table th {
    background: rgba(61, 255, 136, 0.07);
    color: var(--text-dim);
    font-size: 0.85em;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: rgba(61, 255, 136, 0.04);
}

.admin-table tr.deleted td {
    opacity: 0.4;
}

.admin-table select,
.admin-table button,
.admin-filters select,
.admin-filters input {
    font-family: inherit;
    font-size: 0.9em;
    background: var(--bg-inset);
    color: var(--phosphor);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 8px;
}

.admin-table button {
    cursor: pointer;
    margin: 2px 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-table button:hover {
    border-color: var(--phosphor);
    box-shadow: 0 0 8px rgba(61, 255, 136, 0.3);
}

.admin-table button.danger {
    color: var(--error);
    border-color: rgba(255, 107, 107, 0.5);
}

.admin-table button.danger:hover {
    border-color: var(--error);
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.35);
}

.admin-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 12px;
}

.grade-picker {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.lock-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
}

.lock-picker .lock-pair {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    color: var(--text-faint);
    font-size: 0.82em;
    letter-spacing: 1px;
}

.lock-picker .lock-pair select {
    flex: 1;
    min-width: 64px;
}

/* ========================================================
   LEADERBOARD
   ======================================================== */
.comp-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.comp-picker-row label {
    color: var(--text-faint);
    font-size: 0.85em;
    letter-spacing: 1px;
    font-weight: 700;
}

.comp-picker-row select {
    font-family: inherit;
    font-size: 0.95em;
    padding: 9px 12px;
    background: var(--bg-raise);
    color: var(--phosphor);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    flex: 1;
    min-width: 220px;
}

.my-team-banner {
    background: linear-gradient(135deg, rgba(61, 255, 136, 0.13), rgba(61, 255, 136, 0.04));
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin: 15px 0 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: var(--glow-soft);
}

.my-team-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.my-team-stat .label {
    color: var(--text-faint);
    font-size: 0.75em;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.my-team-stat .val {
    color: var(--phosphor);
    font-size: 1.35em;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.my-team-stat .val.highlight {
    color: #ffffff;
    text-shadow: 0 0 10px var(--phosphor);
}

.leaderboard-table-wrap {
    overflow-x: auto;
    margin-top: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-inset);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 16px;
    text-align: start;
    color: var(--text);
    border-bottom: 1px solid var(--line);
}

.leaderboard-table tr:last-child td {
    border-bottom: none;
}

.leaderboard-table th {
    background: rgba(61, 255, 136, 0.07);
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-size: 0.8em;
    text-transform: uppercase;
}

.leaderboard-table tbody tr {
    transition: background 0.15s ease;
}

.leaderboard-table tbody tr:hover {
    background: rgba(61, 255, 136, 0.05);
}

.leaderboard-table tbody tr:nth-child(even) {
    background: rgba(61, 255, 136, 0.025);
}

.leaderboard-table tbody tr:nth-child(even):hover {
    background: rgba(61, 255, 136, 0.06);
}

.leaderboard-table tr.rank-1-row {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.10), rgba(255, 215, 0, 0.02));
}

.leaderboard-table tr.rank-2-row {
    background: linear-gradient(90deg, rgba(215, 221, 227, 0.07), rgba(215, 221, 227, 0.015));
}

.leaderboard-table tr.rank-3-row {
    background: linear-gradient(90deg, rgba(224, 156, 95, 0.07), rgba(224, 156, 95, 0.015));
}

.leaderboard-table tr.rank-1-row .rank-badge {
    font-size: 1em;
    min-width: 40px;
    padding: 4px 11px;
}

.leaderboard-table td.score-cell {
    font-weight: 800;
    color: var(--phosphor-soft);
    letter-spacing: 1px;
}

.leaderboard-table tr.rank-1-row td.score-cell {
    font-size: 1.08em;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.leaderboard-table tr.my-team-row {
    background: rgba(61, 255, 136, 0.12);
    box-shadow: inset 3px 0 0 var(--phosphor);
}

html[dir="rtl"] .leaderboard-table tr.my-team-row {
    box-shadow: inset -3px 0 0 var(--phosphor);
}

.leaderboard-table tr.my-team-row td {
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 6px rgba(61, 255, 136, 0.5);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 3px 9px;
    font-weight: 800;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 0.85em;
    color: var(--text-dim);
}

.rank-1 {
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.6);
    background: rgba(255, 215, 0, 0.1);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.7);
}

.rank-2 {
    color: #d7dde3;
    border-color: rgba(215, 221, 227, 0.55);
    background: rgba(215, 221, 227, 0.08);
    text-shadow: 0 0 8px rgba(192, 192, 192, 0.7);
}

.rank-3 {
    color: #e09c5f;
    border-color: rgba(224, 156, 95, 0.55);
    background: rgba(205, 127, 50, 0.1);
    text-shadow: 0 0 8px rgba(205, 127, 50, 0.7);
}

.tag-my-team {
    margin-inline-start: 8px;
    font-size: 0.68em;
    padding: 3px 8px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--phosphor), var(--phosphor-deep));
    color: #04140a;
    font-weight: 800;
    letter-spacing: 1px;
}

/* ========================================================
   ACCESSIBILITY
   ======================================================== */
:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .brand-cursor {
        animation: none;
        opacity: 1;
    }
}

/* datetime picker indicator readable on dark background */
input[type="datetime-local"] {
    color-scheme: dark;
}

/* ========================================================
   HEBREW / RTL SUPPORT (i18n.js)
   ======================================================== */
html[dir="rtl"] body {
    text-align: right;
}

html[dir="rtl"] .expression-input,
html[dir="rtl"] .digit-counter,
html[dir="rtl"] .riddle-digits,
html[dir="rtl"] #team-key,
html[dir="rtl"] #join-key,
html[dir="rtl"] #creation-sequence,
html[dir="rtl"] #solve-sequence,
html[dir="rtl"] .locked-digits-container,
html[dir="rtl"] .bank,
html[dir="rtl"] code {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Keep digit/operator tokens in natural math order; only the bank's flex direction follows ltr. */
html[dir="rtl"] .expression-input {
    text-align: left;
}

html[dir="rtl"] .result-box {
    border-inline-start: 1px solid var(--line);
    border-inline-end: 3px solid var(--phosphor);
}

html[dir="rtl"] header.brand h1 {
    letter-spacing: 1px;
}

html[dir="rtl"] .brand-tag {
    letter-spacing: 2px;
}

/* ========================================================
   RESPONSIVE
   ======================================================== */
@media (max-width: 860px) {
    #app-container {
        padding: 18px 16px 22px;
        min-height: 0;
    }

    .bottom-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .actions {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .actions .btn {
        flex: 1;
        min-width: 140px;
    }

    .stats-panel {
        margin-inline-end: 0;
        margin-bottom: 14px;
    }
}

@media (max-width: 620px) {
    body {
        padding: 10px 6px;
        align-items: flex-start;
    }

    #app-container {
        border-radius: 14px;
        padding: 14px 12px 18px;
    }

    header.brand {
        padding: 6px 0 12px;
    }

    header.brand h1 {
        letter-spacing: 2px;
        gap: 0.4em;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        margin-bottom: 8px;
    }

    .nav-bar {
        top: 6px;
        padding: 6px 8px;
        gap: 8px;
    }

    /* Single scrollable nav row instead of a 3-row wrap on phones */
    .nav-links {
        flex-wrap: nowrap;
        overflow-x: auto;
        max-width: 100%;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        padding: 8px 10px;
        font-size: 0.75em;
        letter-spacing: 1px;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .nav-badge {
        padding: 4px 10px;
    }

    h2 {
        font-size: 1.15em;
    }

    .expression-input {
        font-size: 1.25em;
        letter-spacing: 1.5px;
        padding: 13px 14px;
    }

    .token.digit {
        width: 38px;
        height: 54px;
        font-size: 1.2em;
    }

    .token.operator {
        width: 34px;
        height: 34px;
        font-size: 1.15em;
    }

    .bank-label,
    .solving-panel .bank-label {
        width: 100%;
        min-width: 0;
        margin-bottom: 2px;
    }

    .locked-digit-box {
        width: 42px;
        height: 56px;
        font-size: 1.3em;
    }

    .my-team-banner {
        padding: 14px 16px;
    }

    .my-team-stat .val {
        font-size: 1.1em;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 9px 10px;
        font-size: 0.85em;
    }
}

/* Brand stays LTR in both languages */
header.brand h1,
.brand-mark {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Admin filter bar: horizontal as intended */
.admin-filters {
    flex-direction: row;
    max-width: none;
    align-items: flex-end;
}

.admin-filters .field {
    min-width: 170px;
    flex: 0 1 auto;
}

.admin-filters .field:first-child {
    flex: 1 1 260px;
}

.admin-filters .checkbox-field {
    padding-bottom: 10px;
}


/* ============================================================
   STAGE B - LOCKED CELL
   ============================================================ */
.tag.stageb {
    color: var(--cyan);
    border-color: rgba(79, 216, 232, 0.55);
    background: rgba(79, 216, 232, 0.1);
    box-shadow: 0 0 12px rgba(79, 216, 232, 0.18);
}

.locked-cell-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--cyan);
    font-size: 0.82em;
    font-weight: 700;
    letter-spacing: 1px;
    background: rgba(79, 216, 232, 0.08);
    border: 1px solid rgba(79, 216, 232, 0.45);
    border-radius: 999px;
    padding: 6px 14px;
    margin: -6px 0 14px;
    text-shadow: 0 0 8px rgba(79, 216, 232, 0.45);
}

.locked-cell-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.locked-cell-word {
    color: var(--text-dim);
    font-size: 0.85em;
    letter-spacing: 1px;
}

.locked-cell-picker select {
    min-width: 74px;
}

.field-hint {
    margin-top: 6px;
    color: var(--text-faint);
    font-size: 0.72em;
    letter-spacing: 1px;
}

.locked-digit-box.stageb-cell {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 14px rgba(79, 216, 232, 0.35);
}

.locked-digit-box.stageb-cell::after {
    content: "";
    position: absolute;
    top: 3px;
    inset-inline-end: 4px;
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234fd8e8' stroke-width='3' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.locked-digit-box.stageb-cell .box-idx {
    color: rgba(79, 216, 232, 0.75);
}

/* ============================================================
   RULES PAGE
   ============================================================ */
.rules-workspace {
    max-width: 1060px;
    margin: 0 auto;
    width: 100%;
}

.rules-hero {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(61, 255, 136, 0.07), rgba(61, 255, 136, 0.02));
    padding: 18px 22px;
    margin-bottom: 18px;
    box-shadow: var(--glow-soft);
}

.rules-lead {
    font-size: 1.02em;
    line-height: 1.75;
    color: var(--text);
}

.rules-demo {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 22px;
    background: var(--bg-inset);
}

.rules-demo-label {
    color: var(--text-faint);
    font-size: 0.78em;
    letter-spacing: 2px;
}

.rules-demo-arrow {
    color: var(--amber);
    font-size: 1.4em;
}

.rules-demo-expr {
    color: var(--text-dim);
    font-size: 0.92em;
    letter-spacing: 1px;
}

.rules-demo-expr b {
    color: var(--phosphor);
    letter-spacing: 3px;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.rule-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--bg-raise), var(--bg-panel));
    padding: 18px;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.rule-card:hover {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    box-shadow: var(--glow-soft);
}

.lock-ico {
    width: 0.85em;
    height: 0.85em;
    vertical-align: -0.08em;
    margin-inline-end: 0.35em;
}

.rule-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-bottom: 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: rgba(61, 255, 136, 0.06);
    color: var(--phosphor);
    font-size: 1.35em;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(61, 255, 136, 0.45);
    box-shadow: var(--glow-soft);
}

.rule-icon .lock-ico {
    width: 22px;
    height: 22px;
    margin: 0;
}

.rule-card h3 {
    color: var(--phosphor);
    font-size: 0.95em;
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(61, 255, 136, 0.4);
}

.rule-card p {
    color: var(--text-dim);
    font-size: 0.88em;
    line-height: 1.8;
}

.rule-card a {
    color: var(--amber);
    text-decoration: none;
}

.rule-card a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .rules-grid {
        grid-template-columns: 1fr;
    }

    .rules-demo .locked-digit-box {
        width: 42px;
        height: 56px;
        font-size: 1.3em;
    }
}

/* ============================================================
   CL-4X COMPANION ROBOT
   ============================================================ */
#cl4x-robot {
    position: fixed;
    bottom: 14px;
    inset-inline-end: 14px;
    width: 92px;
    height: 100px;
    z-index: 60;
    pointer-events: none;
    filter: drop-shadow(0 0 10px rgba(61, 255, 136, 0.25));
    animation: cl4x-bob 4.5s ease-in-out infinite;
}

#cl4x-robot .cl4x-head {
    transform-origin: 60px 49px;
    transition: transform 0.12s ease-out;
}

#cl4x-robot .cl4x-eye,
#cl4x-robot .cl4x-pupil {
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.12s ease-out, opacity 0.1s ease;
}

#cl4x-robot .cl4x-antenna-tip {
    animation: cl4x-beacon 2.6s ease-in-out infinite;
}

#cl4x-robot .cl4x-core {
    animation: cl4x-core-pulse 3.4s ease-in-out infinite;
}

@keyframes cl4x-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes cl4x-beacon {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@keyframes cl4x-core-pulse {
    0%, 100% { opacity: 1; r: 3; }
    50% { opacity: 0.5; r: 2.2; }
}

@media (max-width: 640px) {
    /* On phones CL-4X would cover the input bank - he sits mobile out. */
    #cl4x-robot {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #cl4x-robot,
    #cl4x-robot .cl4x-antenna-tip,
    #cl4x-robot .cl4x-core {
        animation: none;
    }

    .competition-banner:has(a) {
        animation: none;
    }
}

