
.teddy-hud{
    position: fixed;
    top: -13px;
    right: 220px;
    float: right;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px;
    backdrop-filter: blur(6px);
    border: 1px solid var(--hud-border);
    border-radius: 14px;
    box-shadow: var(--hud-shadow);
    margin: 8px;
    margin-left: auto;
}

.teddy-xp{
    width: 13.5rem;
    font-weight: 700;
}

.teddy-xp-row{
    display: flex;
    justify-content: normal;
    align-items: baseline;
    gap: 8px;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    margin: 2px 4px 2px 4px;
}
.teddy-modal .teddy-xp-bar{
    height: 1.6rem;
}

.teddy-level{
    font-weight: 700;
    color: var(--text);
}

.teddy-xp-text{
    font-size: 12px;
    color: var(--muted);
}

.teddy-xp-bar{
    height: 10px;
    margin-top: 6px;
    background: var(--xp-bg);
    border-radius: 999px;
    overflow: hidden;
}

.teddy-xp-fill{
    height: 100%;
    width: 0%;
    background: var(--xp-fill);
    border-radius: 999px;
    transition: width .4s ease;
}

.teddy-nuts{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--pill-bg);
    border: 1px solid var(--hud-border);
    border-radius: 999px;
    color: var(--text);
    font-weight: 600;
    cursor: default;
    justify-content: center;
    margin-left: 0.75rem;
}

.login .teddy-nuts{
    position: absolute;
    left: 13rem;
}

.teddy-nuts .acorn{
    width: 18px;
    height: 18px;
    fill: var(--color-teddy-fill);
}

.teddy-name {
    color: var(--navy-blue);
    font-weight: 600;
    margin: 4px;
}

.teddy-level {
    color: var(--color-teddy-level); /* blue accent */
    font-weight: 700;
}

.teddy-xp-text {
    color: var(--color-teddy-label); /* slate gray */
    font-weight: 700;
}

#teddy-nuts-count {
    color: var(--color-nuts);
    font-weight: 600;
}

.teddy-avatar-wrapper {
    position: relative;
    display: inline-block;
    width: 4rem;
    height: 4.5rem;
    left: 5px;
    top: 4px;
}


.teddy-levelup{
    position: absolute;
    top: 15px;
    left: 120px;
    border-radius: 9999px;
    border: none;
    background: var(--color-teddy-level-back);
    color: var(--color-teddy-level);
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    cursor: pointer;
    animation: levelPulse 1.2s ease-in-out infinite;
    font-size: 32px;
    padding: 1px 5px;
}

.teddy-avatar-levelup{
    position: initial;
}


.teddy-levelup svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}



/* Smooth progress change */
.teddy-xp-fill {
    transition: width 600ms ease;
}

/* Quick flash on the XP bar background */
.teddy-xp-bar.flash {
    animation: teddyFlash 700ms ease-out;
}
@keyframes teddyFlash {
    0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.5); background-color: white; }
    60%  { box-shadow: 0 0 0 10px rgba(37,99,235,0); background-color: white; }
    100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); background-color: white; }
}

/* Level-up pop on the level label */
.teddy-level.level-up {
    animation: levelPop 800ms ease;
}
@keyframes levelPop {
    0%   { transform: scale(1);   text-shadow: none; }
    30%  { transform: scale(1.18); text-shadßow: 0 0 12px rgba(250,204,21,0.9); }
    100% { transform: scale(1);   text-shadow: none; }
}

/* Count bump for nuts */
#teddy-nuts-count.bump {
    animation: countBump 450ms ease;
}
@keyframes countBump {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}


.teddy-avatar.wiggle {
    animation: teddyWiggle 600ms ease;
}
@keyframes teddyWiggle {
    0% { transform: rotate(0deg); }
    20% { transform: rotate(-8deg); }
    40% { transform: rotate(6deg); }
    60% { transform: rotate(-4deg); }
    100% { transform: rotate(0deg); }
}



/* Attention animation when eligible */
.teddy-levelup.is-eligible {
    animation: levelPulse 1000ms ease-in-out infinite, levelBounce 1600ms ease-in-out infinite;
    outline: none;
}

/* soft halo */
.teddy-levelup::after {
    content: "";
    position: absolute;
    inset: 0px;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.6);
    animation: halo 1000ms ease-out infinite;
}

/* Hover/focus affordance */
.teddy-levelup:focus-visible,
.teddy-levelup:hover {
    filter: brightness(1.05);
}

@keyframes levelPulse {
    0%,100% { transform: translateZ(0) scale(1); }
    50%     { transform: translateZ(0) scale(1.06); }
}

@keyframes levelBounce {
    0%, 100% { transform: translateY(0); }
    40%      { transform: translateY(-2px); }
}

@keyframes halo {
    0%   { box-shadow: 0 0 0 0 var(--color-teddy-level); opacity: 1; }
    100%  { box-shadow: 0 0 0 10px var(--color-teddy-level-back); opacity: 0.3; }

}

.teddy-levelup {
    background: var(--color-teddy-level-back);
    color: var(--color-teddy-level);
}



.teddy-avatar.flash {
    animation: avatarHalo 1200ms ease-out;
    border-radius: 50%;
}

@keyframes avatarHalo {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    40% {
        box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.teddy-avatar.flash.gold {
    animation: avatarHaloGold 1200ms ease-out;
}

@keyframes avatarHaloGold {
    0%   { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7); }
    40%  { box-shadow: 0 0 0 15px rgba(250, 204, 21, 0); }
    100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); }
}

.teddy-modal__body{
    display: flex;
}



/* modal customization */
/* Modal */
.teddy-modal{position:fixed;inset:0;display:none;z-index:1000;overflow-x:auto;}
.teddy-modal[aria-hidden="false"]{display:block;}
.teddy-modal__overlay{position:absolute;inset:0;background:rgba(0,0,0,.35);}
.teddy-modal__dialog{
    position:relative; margin:95px auto; max-width:940px; background:var(--color-teddy-modal-back); border-radius:16px;
    box-shadow:0 20px 60px rgba(0,0,0,.25); padding:1rem 2rem 2rem 2rem; width:calc(100% - 24px);
    border: solid 3px var(--color-code-border);
}
.teddy-modal__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;}
.teddy-modal__close{font-size:22px; line-height:1; border:1px solid #e5e7eb; border-radius:10px; padding:6px 10px; cursor:pointer; margin-bottom:1rem;}

.teddy-customizer{
    display: flex;
    flex-direction: column;
    margin-top:10px;}
.teddy-choices{background:var(--color-teddy-choice-back);border:1px solid var(--color-teddy-choice);border-radius:50px; padding:15px; overflow:auto; height: 352px;}
.teddy-preview{display:flex;flex-direction:column;gap:12px;background:var(--color-teddy-choice-back);border-radius:50px;}

.teddy-tabs{justify-content: center; display:flex;gap:6px; margin-top:10px; margin-bottom:20px;}
.teddy-tab{font-size: 18px; min-width:5rem; border-radius: var(--radius-md); border:1px solid var(--color-code-border); }
.teddy-tab.locked{border-radius: var(--radius-md);}

#teddy-items {
    display: flex;
    flex-direction: column;
    margin-right: 10px;
}

.teddy-tab[aria-selected="true"], .teddy-choice-media[aria-selected="true"]{
    background:var(--color-primary);
    color:var(--color-primary-contrast);
    border: 2px solid var(--color-code-border);
    border-radius: 8px;
    box-shadow: 0 0 6px var(--teddy-tab-box-shadow);
}

.teddy-tabs button{
    background: var(--color-teddy-tab-button-back);
    color: var(--color-teddy-tab-button);
    border: 2px solid var(--color-teddy-tab-button-border);
    padding: 12px;
}

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

.teddy-choice{
    border:1px solid var(--color-teddy-choice); border-radius:25px; padding:8px; background:var(--color-choice-back); cursor:pointer;
    display:flex; align-items:center; justify-content:center; aspect-ratio:1/1; transition:transform .1s ease;
}

.buyable .teddy-choice:hover{
    background: var(--color-buyable-back);
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--color-buyable-hover);
}

.buyable.teddy-choice{
    background: var(--color-buyable-choice);
}


.teddy-stage{
    position:relative; aspect-ratio:1/1;
    border:1px dashed var(--teddy-stage-border); border-radius:50px;
    overflow:hidden;
}

#avatar-teddy-stage{
    height: 4.3rem;
}

.tz-layer{
    position:absolute; width:90%; height:auto; object-fit:contain; user-select:none; pointer-events:none;
    left:50%; transform:translateX(-50%);
    border-radius: 15%;
    padding: 12px;
}
.avatar-tz-layer{position:absolute; object-fit:contain; user-select:none; pointer-events:none; width:90%;}
.teddy-choice{ display:flex; flex-direction:column; gap:6px;}
.teddy-choice-media{ position: relative; display:grid; place-items:center; aspect-ratio:1/1; }
.teddy-choice-meta{ display:flex; align-items:center; justify-content:space-between; }
.teddy-choice-name{ font-weight:600; font-size:13px; }
.teddy-price-pill{ font-size: 1.6rem; font-weight:800;z-index: 2;position: absolute; bottom:0;right:0;display:inline-flex; align-items:center; gap:4px; background:var(--color-price-back); border:1px solid var(--color-teddy-choice); border-radius:999px; padding:2px 8px; }
.teddy-price-icon{ width:14px; height:14px; fill:var(--color-teddy-fill); }


.teddy-name-edit {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 1rem;
    margin: auto;
}

.teddy-name-label {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
}

.teddy-name-input {
    padding: 14px 18px;
    font-size: 18px;
    font-weight: 550;
    border: 2px solid var(--color-teddy-name-input-border);
    border-radius: 100px;
    background: var(--color-choice-back);
    color: var(--color-teddy-name-input);
    box-shadow: inset 0 1px 4px rgba(0,0,0,.08);
    transition: border-color .2s, box-shadow .2s;
    margin: 0px 10px 12px 10px;
    text-align: center;
}

.teddy-name-input:focus {
    outline: none;
    border-color: var(--xp-fill);
    box-shadow: 0 0 0 4px var(--input-box-shadow);
}

.teddy-name-input::placeholder {
    color: var(--color-teddy-name-input-placeholder);
    font-style: italic;
}


.teddy-modal__dialog * {
    font-family: "Segoe UI Rounded", system-ui, -apple-system, sans-serif;
}

.teddy-modal__header {
    font-weight: 800;
}

#teddy-modal-title {
    margin: 0;
    margin-bottom: 20px;
    font-weight: 550;
}

.teddy-stats {
    display: flex;
    margin-top: 10px;
    gap:15px;
}

#teddy-items .acorn{
    width: 64px;
    height: 64px;
    fill: var(--color-teddy-fill);
}

.teddy-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--color-teddy-level-avatar-background);
    border: 1px solid var(--color-teddy-level-avatar-boder);
    border-radius: 999px;
    font-weight: 700;
    color: var(--color-teddy-level-avatar);
}

.teddy-level-label {
    font-size: 14px;
    color: var(--color-teddy-label);
}

.teddy-stats .teddy-level {
    font-size: 32px;
    padding-right: 20px;
    min-width: 5rem;
    background: var(--color-teddy-stats-back);
    border: 2px solid var(--color-buyable-border);
}

.teddy-stats .teddy-xp {
    margin-left: 10px;
    width: 11.2rem;
    align-self: center;
}

.teddy-stats .teddy-xp-top {
    display: flex;
    justify-content: flex-end;
}

.teddy-stats .teddy-xp-top span{
    font-size: 18px;
}

.teddy-stats .teddy-xp-label{
    margin-right: 10px;
}

#teddy-items .teddy-nuts {
    font-size: 1.6rem;
    background: var(--color-selection);
    border: 2px solid var(--color-teddy-avatar-nuts-reward);
    padding: 10px 20px;
    margin-top: 12px;
    margin-left: 0px;
    max-width: 13rem;
    align-self: center;

}

.teddy-acorn-value {
    background: var(--color-bg);
    border-radius: 20px;
    padding: 6px;
    min-width: 5rem;
    text-align: center;
}

.teddy-avatar-level {
    display: flex;
    background: var(--color-selection);
    border: 2px solid var(--color-teddy-avatar-nuts-reward);
    border-radius: 100px;
    padding: 10px 20px;
}

.teddy-avatar-level-label {
    font-size: 32px;
    margin: 2px 10px;
    font-weight: 700;
}

.nocursor {
    pointer-events: none;
    cursor: not-allowed;
}

.locked {
    pointer-events: none;
    cursor: not-allowed;
    background: var(--color-locked-back) !important;
    color: var(--color-locked);
    border: 2px solid var(--color-locked-border) !important;
    opacity: 0.9;
    padding:5px 10px;
    border-radius: 999px;
}

button.teddy-tab.locked::after {
    content: "🔒";
    font-size: 0.8em;
    margin-left: 0.4em;
    opacity: 0.9;
}

.button.locked {
    pointer-events: none;
    cursor: not-allowed;
    text-align: center;
    justify-content: center;
    padding: 5px 10px;
}

locked:hover {
    background: var(--color-locked-back);
    color: var(--color-locked);
    border-color: var(--color-locked-border);
}


.buyable {
    color: var(--color-buyable);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    border: 2px solid var(--color-buyable-border);
    background: var(--color-teddy-stats-back);
    text-align: center;
    justify-content: center;
    padding: 5px 10px;
}

.buyable:hover {
    background: var(--color-teddy-stats-back);              /* brighter teal on hover */
    transform: scale(1.05);
    box-shadow: 0 0 10px var(--color-buyable-hover);
}

body.modal-open {
    overflow: hidden;                 /* no background scroll */
    overscroll-behavior: none;        /* stop overscroll chain on Android/Chrome */
}

.teddy-reward{
    margin-top:auto;
    display: flex;
    flex-direction: column;
    line-height: 2rem;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}


.teddy-reward .acorn{
    padding: 2px;
    height: 2rem;
    margin-left: 0.2rem;
}

.teddy-reward-info {
    display: inline-flex;
    position: relative;
    left: 1.5rem;
    justify-content: flex-end;
    border: 2px solid var(--color-teddy-avatar-nuts-reward);
    border-radius: 16px;
    background: var(--color-reward-back);
    padding-left:0.6rem;
    color: var(--color-nuts);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.2);
}

html[data-examination="on"] .gamification {
    display: none;
}


@media (max-width: 1300px) {
    .teddy-hud{
        top:auto;
        bottom: 0px;
        right:0px;
    }

    .teddy-stats {
      justify-content: center;
    }

}

@media (max-width: 1000px){
    .teddy-modal__dialog{ margin:0px; width:100%;}
    .teddy-modal__body {
        flex-direction: column-reverse;
    }

    .teddy-modal .teddy-nuts{
        margin-bottom: 16px;
        order:-1;
    }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .teddy-xp-fill,
    .teddy-xp-bar.flash,
    .teddy-level.level-up,
    #teddy-nuts-count.bump,
    .teddy-avatar.wiggle {
        animation: none !important;
        transition: none !important;
    },
    .teddy-avatar.flash {
        animation: none !important;
    },
    .teddy-levelup.is-eligible,
    .teddy-levelup.is-eligible::after {
        animation: none !important;
    }
}
