:root {
  --pine: #1E4032; --ember: #CE7A0E; --oat: #ECE3D0; --bark: #241015; --bg: #F6F1E6; --card: #FFFDF8;
  --line: #D9CDB4; --soft: #5C5140; --sky: #DCEBEF; --ok: #DCE9DF; --warn: #FBE4DC;
  --title: Georgia, 'Times New Roman', serif; --text: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--bark); font-family: var(--text); font-size: 16px; line-height: 1.45; }
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
h1, h2 { font-family: var(--title); margin: 0; line-height: 1.15; }
h1 { font-size: 26px; } h2 { font-size: 20px; }
p { margin: 0; }
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ember); outline-offset: 2px; }
.muted { color: var(--soft); font-size: 14px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--soft); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.btn { min-height: 52px; border: 0; border-radius: 16px; padding: 0 18px; font-weight: 700; font-size: 16px; background: var(--pine); color: var(--card); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.ember { background: var(--ember); color: var(--bark); }
.btn.ghost { background: var(--card); color: var(--pine); border: 2px solid var(--pine); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 12px 0 6px; border-radius: 17px; background: var(--pine); color: var(--card); font-weight: 700; font-size: 14px; }
.pill img { width: 22px; height: 22px; }
.pill.warm { background: #F8E3C2; color: var(--bark); padding: 0 12px; }
.field { width: 100%; min-height: 56px; border: 2px solid var(--line); border-radius: 16px; background: var(--card); padding: 0 16px; font-size: 22px; font-weight: 700; letter-spacing: .12em; text-align: center; text-transform: uppercase; }
.err { background: var(--warn); border-radius: 14px; padding: 10px 14px; font-size: 15px; }

/* corbul */
.raven { display: flex; align-items: flex-end; gap: 8px; }
.raven img { width: 84px; height: 84px; object-fit: contain; flex: none; animation: bob 2.6s ease-in-out infinite; }
.bubble { flex: 1; background: var(--card); border: 2px solid var(--line); border-radius: 18px 18px 18px 4px; padding: 12px 14px; font-size: 15px; }
.bubble.good { background: var(--ok); border-color: #9DC2A8; }
.bubble.oops { background: var(--warn); border-color: #E7B5A5; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* animale */
.animals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.animal { position: relative; border: 3px solid transparent; border-radius: 50%; background: none; padding: 0; aspect-ratio: 1; }
.animal img { width: 100%; height: 100%; display: block; border-radius: 50%; }
.animal[aria-pressed="true"] { border-color: var(--ember); transform: scale(1.06); }
.animal.taken img { filter: grayscale(.9); opacity: .45; }
.animal.taken::after { content: 'luat'; position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%); background: var(--bark); color: var(--card); font-size: 10px; font-weight: 700; border-radius: 8px; padding: 1px 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid var(--line); background: var(--card); font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--pine); border-color: var(--pine); color: var(--card); }
.pinpad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pinpad button { aspect-ratio: 1.15; border: 2px solid var(--line); border-radius: 16px; background: var(--card); padding: 8px; }
.pinpad img { width: 100%; height: 100%; object-fit: contain; }
.slots { display: flex; gap: 8px; justify-content: center; }
.slot { width: 58px; height: 58px; border-radius: 14px; border: 2px dashed #B9AC90; display: flex; align-items: center; justify-content: center; }
.slot img { width: 44px; height: 44px; object-fit: contain; animation: pop .25s ease-out; }

/* harta */
.me { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.bar { height: 12px; border-radius: 6px; background: #DDD2BA; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pine); border-radius: 6px; transition: width .6s ease; }
.map { background: var(--sky); border-radius: 22px; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.week { display: flex; align-items: center; gap: 10px; }
.week:nth-child(even) { flex-direction: row-reverse; text-align: right; }
.isle { position: relative; width: 104px; height: 92px; flex: none; }
.isle > img { width: 100%; height: 100%; object-fit: contain; }
.week.locked .isle > img { filter: grayscale(1); opacity: .5; }
.isle .fly { position: absolute; left: -16px; top: -26px; width: 60px; height: 60px; animation: fly 3s ease-in-out infinite; }
@keyframes fly { 50% { transform: translate(6px, -8px) rotate(4deg); } }
.badge { position: absolute; right: 0; bottom: 6px; width: 26px; height: 26px; border-radius: 50%; background: var(--pine); color: var(--card); border: 2px solid var(--bg); font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.week.locked .badge { background: var(--soft); }
.week h2 { font-size: 17px; }
.lessons { display: flex; flex-direction: column; gap: 8px; }
.lesson { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); text-align: left; width: 100%; font-weight: 700; }
.lesson .n { width: 34px; height: 34px; border-radius: 50%; background: var(--oat); display: flex; align-items: center; justify-content: center; flex: none; }
.lesson.done .n { background: var(--pine); color: var(--card); }
.lesson.next { border-color: var(--ember); background: #FFF6E6; }
.lesson:disabled { opacity: .55; }
.lesson small { display: block; font-weight: 400; color: var(--soft); }
nav.tabs { display: flex; gap: 6px; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 4px; margin-top: auto; position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); }
nav.tabs a { flex: 1; min-height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 700; font-size: 14px; color: #3D352A; }
nav.tabs a[aria-current="page"] { background: var(--pine); color: var(--card); }

/* lecția */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.back { width: 44px; height: 44px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-size: 22px; font-weight: 700; line-height: 1; }
.dots { display: flex; gap: 6px; }
.dots i { flex: 1; height: 8px; border-radius: 4px; background: #DDD2BA; }
.dots i.done { background: var(--pine); } .dots i.now { background: var(--ember); }
.editor { border-radius: 18px; background: var(--pine); padding: 10px 10px 8px; display: flex; flex-direction: column; gap: 8px; }
.files { display: flex; gap: 6px; }
.files button { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; color: #CFE2D4; font-weight: 700; font-size: 13px; }
.files button[aria-selected="true"] { background: var(--bg); color: var(--pine); }
.editor textarea { width: 100%; min-height: 150px; resize: vertical; border: 0; border-radius: 12px; background: #17332A; color: #F6F1E6; padding: 10px 12px; font-family: var(--mono); font-size: 15px; line-height: 1.6; tab-size: 2; white-space: pre; overflow: auto; }
.keys { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.keys button { flex: none; min-width: 40px; height: 40px; border-radius: 10px; border: 0; background: #2F5A47; color: #F6F1E6; font-family: var(--mono); font-size: 16px; font-weight: 700; }
.preview { width: 100%; height: 190px; border: 2px solid var(--line); border-radius: 18px; background: #fff; }
.actions { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 12px -6px var(--bg); }
.actions .btn { flex: 1; } .actions .btn.main { flex: 1.6; }

/* clasament */
.toggle { display: flex; gap: 6px; background: #EFE7D4; border-radius: 16px; padding: 4px; }
.toggle button { flex: 1; min-height: 44px; border: 0; border-radius: 12px; background: transparent; font-weight: 700; }
.toggle button[aria-pressed="true"] { background: var(--card); }
.podium { display: flex; align-items: flex-end; gap: 8px; }
.podium > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-weight: 700; font-size: 13px; }
.podium img { width: 64px; height: 64px; border-radius: 50%; }
.podium .step { width: 100%; border-radius: 16px 16px 6px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.podium .step b { font-family: var(--title); font-size: 26px; line-height: 1; }
.rank { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 4px 12px; border-radius: 14px; border: 2px solid #E4DAC4; background: var(--card); }
.rank.me { background: var(--pine); border-color: var(--pine); color: var(--card); }
.rank img { width: 40px; height: 40px; border-radius: 50%; }
.rank .pos { width: 20px; font-family: var(--title); font-weight: 700; font-size: 18px; }
.rank small { display: block; font-size: 12px; opacity: .8; }

/* sărbătoare */
.party { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 24px; flex: 1; justify-content: center; overflow: hidden; }
.party > img { width: 190px; height: 190px; object-fit: contain; animation: pop .5s ease-out; }
.earned { font-family: var(--title); font-size: 34px; font-weight: 700; color: var(--pine); animation: pop .6s ease-out .2s both; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--bark); color: var(--card); padding: 10px 16px; border-radius: 14px; font-weight: 600; max-width: 90vw; z-index: 5; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
td img { width: 34px; height: 34px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* panoul profesorului */
.prof #app { max-width: 760px; }
.field.plain { text-transform: none; letter-spacing: 0; font-size: 17px; font-weight: 400; text-align: left; }
.klasses { display: grid; gap: 10px; }
.klass { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.klass:hover { border-color: var(--pine); }
.code { text-align: center; font-family: var(--mono); font-weight: 700; font-size: 20px; letter-spacing: .08em; background: var(--oat); border-radius: 14px; padding: 8px 12px; flex: none; }
.code .label { display: block; letter-spacing: .04em; font-family: var(--text); }
.bigcode { text-align: center; background: var(--pine); border-color: var(--pine); color: var(--card); }
.bigcode .label, .bigcode .muted { color: #CFE2D4; }
.bigcode b { display: block; font-family: var(--mono); font-size: clamp(40px, 12vw, 72px); letter-spacing: .1em; line-height: 1.2; }
summary { font-weight: 700; cursor: pointer; min-height: 32px; }
@media (min-width: 640px) { .klasses { grid-template-columns: 1fr 1fr; } }
