:root {
  --ink: #251a32;
  --plum: #51344f;
  --rose: #c86f78;
  --peach: #efa574;
  --gold: #f5cf82;
  --cream: #fff6df;
  --jade: #4b8c7b;
  --glass: rgba(38, 25, 48, 0.88);
  --line: rgba(255, 224, 166, 0.36);
  --shadow: 0 28px 80px rgba(20, 9, 30, 0.45);
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: #1d1427; }

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  background:
    radial-gradient(circle at 16% 12%, rgba(223, 107, 121, 0.2), transparent 32%),
    radial-gradient(circle at 87% 17%, rgba(240, 177, 102, 0.18), transparent 31%),
    radial-gradient(circle at 50% 100%, rgba(76, 142, 122, 0.16), transparent 37%),
    linear-gradient(145deg, #281935, #39233d 48%, #1e2532);
  font-family: Inter, ui-rounded, "Segoe UI", Arial, sans-serif;
}

button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.ambient i { position: absolute; width: 38vw; aspect-ratio: 1; border: 1px solid rgba(247, 208, 134, 0.08); border-radius: 50%; }
.ambient i:nth-child(1) { left: -16vw; top: -17vw; }
.ambient i:nth-child(2) { right: -21vw; bottom: -19vw; }
.ambient i:nth-child(3) { width: 18vw; left: 42%; top: 18%; box-shadow: 0 0 70px rgba(243, 165, 105, 0.08); }

.app-shell { width: min(1280px, calc(100% - 24px)); margin: 0 auto; padding: clamp(14px, 2vw, 26px) 0 28px; position: relative; z-index: 1; }

.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 15px;
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 25px 10px 25px 10px;
  background: linear-gradient(135deg, rgba(87, 48, 72, 0.82), rgba(38, 31, 50, 0.86));
  box-shadow: 0 18px 55px rgba(20, 9, 30, 0.28);
  backdrop-filter: blur(14px);
}

.hero-mark { width: 62px; height: 62px; display: grid; place-items: center; border: 1px solid rgba(255, 222, 159, 0.45); border-radius: 50%; color: #ffe0a0; background: radial-gradient(circle, rgba(239, 162, 112, 0.26), rgba(78, 48, 68, 0.3)); font-family: Georgia, serif; font-size: 2rem; box-shadow: 0 0 30px rgba(239, 161, 106, 0.12); }
.eyebrow { margin: 0 0 2px; color: var(--gold); font-size: 0.67rem; font-weight: 900; letter-spacing: 0.16em; text-transform: uppercase; }
.hero h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.85rem, 4vw, 3.1rem); font-weight: 500; line-height: 1; background: linear-gradient(180deg, #fff 5%, #ffe7aa 60%, #eca36d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero span { display: block; margin-top: 5px; color: rgba(255, 247, 226, 0.7); font-size: 0.82rem; }
.help-button { width: 44px; height: 44px; border: 1px solid rgba(255, 222, 159, 0.4); border-radius: 50%; color: var(--gold); background: rgba(255, 255, 255, 0.07); cursor: pointer; font-weight: 900; }
.help-button:hover, .help-button:focus-visible { outline: 3px solid rgba(245, 207, 130, 0.25); background: rgba(255, 255, 255, 0.12); }

.help-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 14px; padding: 12px; border: 1px solid rgba(245, 207, 130, 0.28); border-radius: 18px; background: rgba(31, 24, 42, 0.76); }
.help-panel[hidden] { display: none; }
.help-panel div { padding: 10px; border-radius: 13px; background: rgba(255, 255, 255, 0.055); }
.help-panel b { display: block; color: var(--gold); font-family: Georgia, serif; }
.help-panel span { display: block; margin-top: 3px; color: rgba(255, 247, 226, 0.66); font-size: 0.72rem; line-height: 1.42; }

.learning-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr); gap: 15px; align-items: start; }
.soroban-card, .practice-card { border: 1px solid var(--line); border-radius: 32px 13px 32px 13px; background: linear-gradient(150deg, rgba(65, 42, 70, 0.91), rgba(29, 29, 44, 0.94)); box-shadow: var(--shadow), inset 0 0 40px rgba(255, 231, 182, 0.035); backdrop-filter: blur(15px); }
.soroban-card { padding: clamp(14px, 2vw, 23px); }
.practice-card { position: sticky; top: 12px; padding: 19px; }

.value-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.value-header small { display: block; color: rgba(255, 247, 226, 0.6); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
#totalValue { display: block; min-width: 3ch; color: #ffe09c; font-family: Georgia, serif; font-size: clamp(2.8rem, 7vw, 5rem); line-height: 0.95; text-shadow: 0 0 28px rgba(245, 181, 103, 0.18); }
.soft-button, .secondary-button { min-height: 42px; padding: 8px 13px; border: 1px solid rgba(255, 224, 166, 0.32); border-radius: 999px; color: var(--cream); background: rgba(255, 255, 255, 0.07); cursor: pointer; font-weight: 800; }
.soft-button:hover, .secondary-button:hover { background: rgba(255, 255, 255, 0.12); }
.place-breakdown { margin: 10px 0 13px; padding: 8px 11px; border-radius: 11px; color: rgba(255, 244, 218, 0.72); background: rgba(255, 255, 255, 0.045); font-size: 0.75rem; text-align: center; }

.soroban-frame {
  min-height: 400px;
  position: relative;
  padding: 20px 24px;
  overflow: hidden;
  border: 5px solid #8a5838;
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(255, 224, 169, 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(155deg, #382738, #211e2d);
  box-shadow: inset 0 0 0 2px rgba(255, 218, 149, 0.34), inset 0 0 48px rgba(0, 0, 0, 0.45), 0 18px 42px rgba(14, 7, 22, 0.38);
}
.soroban-frame::before, .soroban-frame::after { content: ""; position: absolute; left: 0; right: 0; height: 13px; z-index: 4; background: linear-gradient(180deg, #c1874d, #6c3f2b); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4); }
.soroban-frame::before { top: 0; }
.soroban-frame::after { bottom: 0; transform: scaleY(-1); }
.frame-decoration { position: absolute; left: 10px; right: 10px; height: 1px; z-index: 5; background: linear-gradient(90deg, transparent, rgba(255, 220, 153, 0.5), transparent); }
.frame-decoration.top { top: 17px; } .frame-decoration.bottom { bottom: 17px; }
.rods { min-height: 350px; display: grid; grid-template-columns: repeat(3, 1fr); position: relative; z-index: 2; }

.rod { min-width: 0; position: relative; display: grid; grid-template-rows: 40px 78px 24px 188px; place-items: stretch center; border-right: 1px solid rgba(255, 225, 171, 0.12); }
.rod:last-child { border-right: 0; }
.place-label { align-self: center; text-align: center; }
.place-label strong { display: block; color: var(--gold); font-family: Georgia, serif; font-size: 1.05rem; }
.place-label small { display: block; color: rgba(255, 247, 226, 0.52); font-size: 0.6rem; text-transform: uppercase; }
.rod-stick { width: 7px; position: absolute; top: 39px; bottom: 12px; z-index: 0; border-radius: 5px; background: linear-gradient(90deg, #9b6a43, #efbd76 48%, #70442f); box-shadow: 0 0 8px rgba(0, 0, 0, 0.4); }
.heaven-zone, .earth-zone { width: 100%; position: relative; }
.reckoning-bar { width: 100%; height: 24px; position: relative; z-index: 3; background: linear-gradient(180deg, #b97942, #6c3d2b); box-shadow: 0 5px 12px rgba(0, 0, 0, 0.42), inset 0 1px rgba(255, 224, 169, 0.3); }
.reckoning-bar i { width: 13px; height: 13px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 2px solid #f4cf84; border-radius: 50%; background: #4b2d31; }

.bead { width: min(128px, 72%); height: 28px; position: absolute; left: 50%; z-index: 2; transform: translateX(-50%); border: 1px solid rgba(255, 239, 207, 0.33); border-radius: 50% 50% 44% 44%; background: linear-gradient(180deg, #eea681 3%, #c65f68 43%, #7a304f 100%); box-shadow: 0 7px 12px rgba(9, 4, 16, 0.42), inset 0 4px 5px rgba(255, 235, 204, 0.26); cursor: grab; transition: top 0.25s cubic-bezier(.2,.75,.22,1), box-shadow 0.2s, filter 0.2s; touch-action: none; }
.bead::after { content: ""; width: 15px; height: 100%; position: absolute; left: 50%; top: 0; transform: translateX(-50%); background: rgba(57, 28, 45, 0.58); box-shadow: inset 2px 0 rgba(255,255,255,.08); }
.bead:hover, .bead:focus-visible { outline: 3px solid rgba(245, 207, 130, 0.26); filter: brightness(1.1); }
.bead:active { cursor: grabbing; }
.bead.is-counting { box-shadow: 0 0 20px rgba(244, 164, 112, 0.22), 0 7px 12px rgba(9, 4, 16, 0.42), inset 0 4px 5px rgba(255, 235, 204, 0.3); }
.heaven-bead { top: 7px; background: linear-gradient(180deg, #f3c388, #d17c68 48%, #7c3f4d); }
.heaven-bead.is-counting { top: 48px; }
.earth-bead { top: var(--bead-top, 55px); }

.place-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 11px; }
.place-card { padding: 8px; border: 1px solid rgba(255, 224, 166, 0.17); border-radius: 12px; background: rgba(255, 255, 255, 0.045); text-align: center; }
.place-card small { display: block; color: rgba(255, 247, 226, 0.56); font-size: 0.62rem; text-transform: uppercase; }
.place-card strong { display: block; margin-top: 2px; color: var(--gold); font-size: 1.1rem; }
.touch-hint { margin: 10px 0 0; color: rgba(255, 247, 226, 0.48); font-size: 0.68rem; text-align: center; }

.practice-heading { display: flex; justify-content: space-between; gap: 10px; }
.practice-heading p { margin: 0; color: var(--peach); font-size: 0.66rem; font-weight: 900; letter-spacing: 0.13em; text-transform: uppercase; }
.practice-heading h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 1.5rem; font-weight: 500; }
.task-number { align-self: flex-start; padding: 5px 9px; border-radius: 999px; color: var(--gold); background: rgba(255, 255, 255, 0.07); font-size: 0.65rem; }
.selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 17px; }
.selectors label { color: rgba(255, 247, 226, 0.62); font-size: 0.62rem; font-weight: 800; text-transform: uppercase; }
.selectors select { width: 100%; min-height: 42px; margin-top: 5px; padding: 7px 9px; border: 1px solid rgba(255, 224, 166, 0.25); border-radius: 11px; color: var(--cream); background: #3d2d43; }
.equation { min-height: 104px; display: flex; align-items: center; justify-content: center; gap: clamp(9px, 2vw, 18px); margin-top: 17px; border: 1px solid rgba(255, 224, 166, 0.24); border-radius: 20px; background: radial-gradient(circle, rgba(234, 143, 105, 0.13), rgba(255, 255, 255, 0.035)); font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.2rem); }
.equation b { color: var(--peach); font-weight: 500; }.equation em { min-width: 1.2em; color: var(--gold); font-style: normal; text-align: center; }
.task-instruction { margin: 9px 0 14px; color: rgba(255, 247, 226, 0.58); font-size: 0.72rem; text-align: center; }
.answer-preview { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.055); }
.answer-preview span { color: rgba(255, 247, 226, 0.6); font-size: 0.73rem; }.answer-preview strong { color: var(--gold); font-size: 1.4rem; }
.feedback { min-height: 51px; display: grid; place-items: center; margin-top: 9px; padding: 8px 10px; border-radius: 12px; color: rgba(255, 247, 226, 0.66); background: rgba(255, 255, 255, 0.04); font-size: 0.73rem; text-align: center; }
.feedback.success { color: #c9ffe9; background: rgba(75, 140, 123, 0.2); }.feedback.error { color: #ffe0d2; background: rgba(200, 83, 94, 0.18); }
.practice-actions { display: grid; gap: 8px; margin-top: 11px; }
.primary-button { min-height: 48px; border: 1px solid rgba(255, 235, 194, 0.4); border-radius: 14px; color: #34202f; background: linear-gradient(135deg, #f6d18a, #eda276); cursor: pointer; font-weight: 900; box-shadow: 0 11px 24px rgba(29, 13, 32, 0.25); }
.primary-button:hover { filter: brightness(1.06); }
.progress-row { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 8px; margin-top: 15px; color: rgba(255, 247, 226, 0.58); font-size: 0.7rem; }
.progress-row strong { color: var(--gold); }.progress-track { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.07); }.progress-track i { width: 0%; height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width 0.35s ease; }

@media (max-width: 950px) {
  .learning-layout { grid-template-columns: 1fr; }
  .practice-card { position: relative; top: auto; }
  .practice-actions { grid-template-columns: 1.4fr 1fr 1fr; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 12px, 1280px); padding-top: 6px; }
  .hero { gap: 9px; padding: 9px; border-radius: 19px 8px 19px 8px; }.hero-mark { width: 48px; height: 48px; font-size: 1.45rem; }.hero span { font-size: 0.68rem; }.help-button { width: 40px; height: 40px; }
  .help-panel { grid-template-columns: 1fr; }
  .soroban-card, .practice-card { padding: 10px; border-radius: 22px 9px 22px 9px; }
  .soroban-frame { min-height: 330px; padding: 16px 4px; border-width: 4px; }
  .rods { min-height: 290px; }.rod { grid-template-rows: 34px 64px 21px 160px; }.rod-stick { top: 33px; }.reckoning-bar { height: 21px; }.bead { width: min(102px, 80%); height: 25px; }.heaven-bead.is-counting { top: 36px; }
  .place-label strong { font-size: 0.9rem; }.place-label small { font-size: 0.5rem; }
  .place-cards { gap: 4px; }.place-card { padding: 6px 3px; }.place-card small { font-size: 0.52rem; }
  .selectors { grid-template-columns: 1fr; }.practice-actions { grid-template-columns: 1fr; }.equation { min-height: 86px; }
}

@media (max-width: 390px) {
  .hero .eyebrow { display: none; }.hero h1 { font-size: 1.55rem; }
  #totalValue { font-size: 2.7rem; }.soft-button { min-height: 38px; padding: 6px 9px; font-size: 0.72rem; }
  .soroban-frame { min-height: 310px; }.rods { min-height: 270px; }.rod { grid-template-rows: 32px 61px 20px 145px; }.bead { height: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  .bead, .progress-track i { transition: none !important; }
}


/* Soroban active-bead and unit-marker polish */
/* A helyiertek-jelolo pont csak az Einer (utolso) palcan jelenjen meg. */
.rod:not(:last-child) .reckoning-bar i {
  display: none;
}

/* Az alapallapot is teljesen tomor, atlatszosag nelkul. */
.bead,
.heaven-bead {
  opacity: 1;
}

/* Minden hasznalt gyongy ugyanarra a kontrasztos szinre valt. */
.bead.is-counting,
.heaven-bead.is-counting {
  opacity: 1;
  border-color: #b9f3d9;
  background: linear-gradient(180deg, #8ce4be 3%, #4fa988 46%, #245b50 100%);
  box-shadow:
    0 0 22px rgba(94, 220, 170, 0.48),
    0 7px 12px rgba(9, 4, 16, 0.48),
    inset 0 4px 5px rgba(232, 255, 245, 0.38);
  filter: saturate(1.12) brightness(1.04);
}
