/* Python review — Grade 10 */
:root {
  --bg0: #f3f5f4;
  --bg1: #fafafa;
  --ink: #15201c;
  --ink-soft: #3d4f48;
  --muted: #66756e;
  --line: rgba(20, 32, 28, 0.12);
  --teal: #0f766e;
  --teal-deep: #0a5c56;
  --teal-soft: #e6f4f1;
  --gold: #b45309;
  --gold-soft: #fef3c7;
  --rose: #be123c;
  --rose-soft: #fff1f2;
  --ok: #047857;
  --ide-bg: #1e1e2e;
  --ide-panel: #181825;
  --ide-line: #313244;
  --ide-text: #cdd6f4;
  --ide-muted: #6c7086;
  --ide-green: #a6e3a1;
  --ide-blue: #89b4fa;
  --ide-peach: #fab387;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(21, 32, 28, 0.08);
  --font: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef2f0 0%, var(--bg1) 28%, #fff 100%);
  line-height: 1.55;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

button, input, select { font: inherit; }
a { color: var(--teal); }

.screen { display: none; min-height: 100dvh; }
.screen.is-on { display: block; }

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

/* —— Byte mascot —— */
.byte {
  width: 96px;
  height: 112px;
  position: relative;
  flex-shrink: 0;
}
.byte__body {
  position: absolute;
  inset: 18px 12px 8px;
  background: linear-gradient(160deg, #14b8a6, var(--teal-deep));
  border-radius: 22px 22px 18px 18px;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,0.12), var(--shadow);
}
.byte__screen {
  position: absolute;
  left: 50%;
  top: 36px;
  transform: translateX(-50%);
  width: 52px;
  height: 34px;
  background: #042f2e;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.25);
  overflow: hidden;
}
.byte__screen::after {
  content: "";
  position: absolute;
  inset: 6px 8px;
  background:
    linear-gradient(var(--ide-green) 0 0) 0 0 / 60% 3px no-repeat,
    linear-gradient(var(--ide-blue) 0 0) 0 10px / 80% 3px no-repeat,
    linear-gradient(var(--gold) 0 0) 0 20px / 45% 3px no-repeat;
  opacity: 0.9;
  animation: scan 2.4s var(--ease) infinite;
}
.byte__eye {
  position: absolute;
  top: 28px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  box-shadow: inset 0 -2px 0 #0f172a;
}
.byte__eye--l { left: 28px; }
.byte__eye--r { right: 28px; }
.byte__antenna {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 4px;
  height: 18px;
  background: var(--teal);
  transform: translateX(-50%);
  border-radius: 4px;
}
.byte__antenna::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--gold);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.7);
}
.byte.is-think .byte__screen::after { animation-duration: 0.7s; }
.byte.is-happy { animation: hop 0.6s var(--ease); }
.byte.is-cheer .byte__body { background: linear-gradient(160deg, #34d399, #0f766e); }

@keyframes scan {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(4px); opacity: 1; }
}
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes popin {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .byte__screen::after, .byte.is-happy, .island, .xp__fill { animation: none !important; }
}

/* —— HUD —— */
.hud {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(247, 246, 243, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.hud__back {
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
}
.hud__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
}
.xp {
  width: min(160px, 28vw);
  height: 10px;
  background: #dce7e3;
  border-radius: 99px;
  overflow: hidden;
}
.xp__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), #34d399);
  transition: width 0.45s var(--ease);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #92400e;
  font-weight: 800;
  font-size: 0.85rem;
}

/* —— Buttons —— */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--teal-deep);
  color: #fff;
  box-shadow: 0 6px 18px rgba(10, 92, 86, 0.22);
}
.btn--primary:hover { background: var(--teal); }
.btn--ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn--warn {
  background: var(--gold-soft);
  color: #92400e;
}
.btn--ide {
  background: #313244;
  color: var(--ide-text);
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
}
.btn--run {
  background: linear-gradient(135deg, #22c55e, #15803d);
  color: #fff;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* —— Gate / Home —— */
.gate {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 2rem 1rem 3rem;
}
.gate__card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
  animation: popin 0.4s var(--ease);
}
.gate__kicker {
  display: inline-block;
  margin-bottom: 0.55rem;
  color: var(--teal-deep);
  font-weight: 700;
  font-size: 0.85rem;
}
.gate h1 {
  font-size: clamp(1.65rem, 4.5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 0.4rem;
}
.gate__lead { color: var(--ink-soft); margin-bottom: 1.25rem; }
.field { text-align: right; margin-bottom: 0.85rem; }
.field label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
}
.field input, .field select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--teal);
}
.gate__err {
  min-height: 1.25rem;
  color: var(--rose);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0.35rem 0 0.75rem;
}
.gate__note { margin-top: 0.9rem; font-size: 0.8rem; color: var(--muted); }

/* —— Map / levels —— */
.map {
  padding: 1.5rem 0 3rem;
}
.map__hero {
  margin: 0.35rem 0 1.35rem;
}
.map__hero h2 {
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.map__hero p {
  color: var(--ink-soft);
  margin-top: 0.25rem;
  font-size: 0.98rem;
}
.islands {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
.island {
  position: relative;
  appearance: none;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.95rem;
  align-items: start;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  text-align: right;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.island:hover:not(:disabled) {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 10px 32px rgba(21, 32, 28, 0.1);
}
.island:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.island:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.45);
  outline-offset: 2px;
}
.island__num {
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.island:disabled .island__num {
  background: #ecefeb;
  color: var(--muted);
}
.island__body { min-width: 0; }
.island__lock {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: #33403b;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.island__stars {
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}
.island h3 {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
}
.island p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}
.island__q {
  margin-top: 0.7rem;
  font-weight: 700;
  color: var(--teal);
  font-size: 0.85rem;
}

.map__tools {
  margin-top: 1.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* —— Level brief —— */
.camp {
  padding: 1.5rem 0 2rem;
}
.camp__card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
  box-shadow: var(--shadow);
  max-width: 560px;
}
.camp__card h2 { font-size: 1.4rem; margin-bottom: 0.35rem; }
.camp__card > p { color: var(--ink-soft); margin-bottom: 1rem; }
.camp__list {
  list-style: none;
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.camp__list li {
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-weight: 600;
  font-size: 0.95rem;
}

/* —— Play —— */
.play {
  padding: 1rem 0 2.5rem;
}
.play__grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1rem;
  align-items: start;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.panel__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.badge {
  display: inline-block;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-weight: 800;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}
.panel h2 { font-size: clamp(1.15rem, 2.5vw, 1.45rem); font-weight: 800; }
.prompt {
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0.5rem 0 0.85rem;
}
.progress-q {
  height: 8px;
  background: #e7eeeb;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.85rem;
}
.progress-q > span {
  display: block;
  height: 100%;
  background: var(--teal);
  width: 10%;
  transition: width 0.35s var(--ease);
}
.hint-box {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  background: var(--gold-soft);
  color: #92400e;
  font-weight: 700;
  line-height: 1.7;
}
.hint-box.is-on { display: block; }
.ltr-run, code.ltr-run {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-family: var(--mono);
  font-weight: 600;
  color: #0f766e;
  background: rgba(15, 118, 110, 0.08);
  padding: 0.05em 0.35em;
  border-radius: 6px;
  margin-inline: 0.1em;
}
.feedback .ltr-run { color: var(--teal-deep); }
.hint-code {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  display: block;
  margin: 0.55rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #11111b;
  color: #a6e3a1;
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* IDE */
.ide {
  background: var(--ide-bg);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #11111b;
  direction: ltr;
  text-align: left;
  font-family: var(--mono);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
}
.ide__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--ide-panel);
  color: var(--ide-muted);
  font-size: 0.8rem;
}
.ide__dots { display: flex; gap: 6px; }
.ide__dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: #45475a;
}
.ide__dots span:nth-child(1) { background: #f38ba8; }
.ide__dots span:nth-child(2) { background: #f9e2af; }
.ide__dots span:nth-child(3) { background: #a6e3a1; }
.ide__file {
  color: var(--ide-text);
  font-weight: 600;
}
.ide__body { display: grid; grid-template-columns: 52px 1fr; min-height: 220px; }
.ide__gutter {
  background: #11111b;
  color: var(--ide-muted);
  padding: 0.85rem 0.4rem;
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.55;
  user-select: none;
  white-space: pre;
}
.ide__editor {
  width: 100%;
  min-height: 220px;
  border: 0;
  resize: vertical;
  padding: 0.85rem 0.75rem;
  background: transparent;
  color: var(--ide-text);
  font: 600 0.95rem/1.55 var(--mono);
  tab-size: 4;
  outline: none;
}
.ide__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: #11111b;
  border-top: 1px solid var(--ide-line);
}
.ide__console {
  border-top: 1px solid var(--ide-line);
  background: #11111b;
  padding: 0.65rem 0.85rem 0.9rem;
  min-height: 88px;
}
.ide__console-label {
  color: var(--ide-muted);
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.ide__out {
  color: var(--ide-green);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  min-height: 1.4em;
}
.ide__out.is-err { color: #f38ba8; }

.feedback {
  display: none;
  margin-top: 1rem;
  border-radius: 16px;
  padding: 1rem;
  animation: popin 0.35s var(--ease);
}
.feedback.is-on { display: block; }
.feedback.is-ok { background: #ecfdf5; border: 1px solid #a7f3d0; }
.feedback.is-no { background: var(--rose-soft); border: 1px solid #fecdd3; }
.feedback h3 { font-size: 1.1rem; margin-bottom: 0.35rem; }
.feedback p { color: var(--ink-soft); }
.feedback .tip {
  margin-top: 0.7rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.7);
  font-weight: 700;
  color: var(--teal-deep);
}
.play__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

/* —— Result —— */
.result {
  padding: 2rem 0 3rem;
}
.result__card {
  width: min(480px, 100%);
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.3rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.result__stars {
  font-size: 1.5rem;
  color: var(--gold);
  letter-spacing: 0.12em;
  margin: 0 0 0.55rem;
}
.result__card h2 { font-size: 1.7rem; margin-bottom: 0.35rem; }
.result__card p { color: var(--ink-soft); margin-bottom: 1rem; }
.result__actions { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center; }

/* —— Tips drawer —— */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  background: rgba(15, 23, 42, 0.45);
  padding: 1rem;
}
.drawer.is-on { display: grid; place-items: center; }
.drawer__card {
  width: min(520px, 100%);
  max-height: min(80dvh, 640px);
  overflow: auto;
  background: #fff;
  border-radius: 22px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.drawer__card h3 { margin-bottom: 0.75rem; }
.drawer__card section { margin-bottom: 1rem; }
.drawer__card h4 { color: var(--teal); margin-bottom: 0.35rem; }
.drawer__card ul { padding-inline-start: 1.2rem; color: var(--ink-soft); }

.loading-py {
  display: none;
  position: fixed;
  inset: auto 1rem 1rem auto;
  z-index: 50;
  background: var(--ide-bg);
  color: var(--ide-text);
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 0.8rem;
  box-shadow: var(--shadow);
}
.loading-py.is-on { display: block; }

@media (max-width: 900px) {
  .islands { grid-template-columns: 1fr; }
  .play__grid { grid-template-columns: 1fr; }
}
