@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #18314b;
  --muted: #6a7b8b;
  --primary: #087e8b;
  --primary-dark: #06636d;
  --mint: #dff7ef;
  --sky: #eaf5ff;
  --sun: #ffce62;
  --paper: #ffffff;
  --line: #dce6ed;
  --background: #f4f8fb;
  --danger: #a83243;
  --success: #177b58;
  --shadow: 0 16px 44px rgba(27, 64, 89, .09);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 10% 8%, #e3f6ef 0, transparent 26rem),
              radial-gradient(circle at 90% 10%, #e7f0ff 0, transparent 28rem),
              var(--background);
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.8;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(8, 126, 139, .25);
  outline-offset: 2px;
}
.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(22px, calc((100% - 1180px) / 2));
  background: rgba(255,255,255,.85);
  border-bottom: 1px solid rgba(211,225,234,.8);
  backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; }
.brand-icon { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 13px; background: #fff1c9; font-size: 23px; }
.user-tools { display: flex; align-items: center; gap: 12px; }
.logout-form { margin: 0; }
.user-greeting { font-weight: 700; }
.page-wrap { width: min(1180px, calc(100% - 36px)); margin: 34px auto 60px; min-height: 65vh; }
.footer { color: #8594a0; text-align: center; padding: 18px; font-size: 12px; }
.hero { display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 35px; padding: 34px 38px; border: 1px solid #e0eaf0; border-radius: 28px; background: linear-gradient(120deg, rgba(255,255,255,.96), rgba(240,250,247,.92)); box-shadow: var(--shadow); overflow: hidden; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(26px, 4vw, 39px); line-height: 1.45; }
h1 span { color: var(--primary); }
h2 { margin-bottom: 8px; font-size: 21px; }
h3 { margin-bottom: 6px; font-size: 17px; }
.lead { max-width: 610px; color: var(--muted); font-size: 17px; }
.hero-art { min-height: 260px; position: relative; display: grid; grid-template-columns: 1fr 1fr; place-items: center; border-radius: 22px; background: linear-gradient(145deg, #daf5e9, #e9f3ff); overflow: hidden; }
.hero-art:before, .hero-art:after { content: ""; position: absolute; border-radius: 50%; border: 1px dashed rgba(8,126,139,.22); }
.hero-art:before { width: 245px; height: 245px; }
.hero-art:after { width: 170px; height: 170px; }
.orb { position: relative; z-index: 1; display: grid; place-items: center; width: 80px; height: 80px; border-radius: 24px; background: #fff; box-shadow: 0 10px 28px rgba(20,70,95,.10); font-size: 39px; transform: rotate(-5deg); }
.orb-wind, .orb-earth { transform: rotate(5deg); }
.hero-bolt { position: absolute; z-index: 2; display: grid; place-items: center; left: calc(50% - 24px); top: calc(50% - 24px); width: 48px; height: 48px; border-radius: 50%; background: var(--sun); box-shadow: 0 4px 18px rgba(255,188,49,.35); font-size: 27px; }
.login-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 25px; }
.choice-card { min-height: 185px; display: flex; flex-direction: column; align-items: flex-start; padding: 24px 27px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: 0 8px 25px rgba(33,67,91,.04); transition: transform .18s ease, box-shadow .18s ease; }
.choice-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.choice-icon { display: grid; place-items: center; width: 49px; height: 49px; margin-bottom: 10px; border-radius: 16px; background: var(--mint); font-size: 25px; }
.teacher-choice .choice-icon { background: var(--sky); }
.choice-title { font-size: 20px; font-weight: 800; }
.choice-description { color: var(--muted); font-size: 13px; }
.choice-link { margin-top: auto; padding-top: 9px; color: var(--primary); font-size: 13px; font-weight: 800; }
.small-note { margin: 17px 0 0; text-align: center; color: #7f8e9a; font-size: 12px; }
.messages { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: white; font-size: 13px; }
.message-error { color: var(--danger); background: #fff4f4; border-color: #f1d0d4; }
.message-success { color: var(--success); background: #effcf5; border-color: #c4ebd6; }
.message-info { color: #235d85; background: #eff8ff; border-color: #d0e6f6; }
.auth-shell, .result-shell { max-width: 600px; margin: 0 auto; }
.back-link { display: inline-block; margin: 0 0 12px; color: var(--primary); font-size: 13px; font-weight: 700; }
.auth-card, .result-card { padding: 31px; border: 1px solid var(--line); border-radius: 25px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.auth-symbol, .result-icon { display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 12px; border-radius: 24px; background: #e7f7f0; font-size: 36px; }
.muted { color: var(--muted); font-size: 13px; }
.stack-form { display: flex; flex-direction: column; gap: 9px; text-align: right; }
.stack-form label { margin-top: 7px; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-width: 0; padding: 11px 12px; border: 1px solid #d8e3e9; border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus { border-color: var(--primary); outline: 3px solid rgba(8,126,139,.10); }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 17px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; font-weight: 800; font-size: 13px; transition: background .15s ease, transform .15s ease; text-align: center; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .65; cursor: wait; transform: none; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-outline { background: #fff; border-color: #cfdee5; color: var(--ink); }
.button-small { min-height: 32px; padding: 5px 11px; border-radius: 9px; font-size: 12px; white-space: nowrap; }
.button-wide { width: 100%; margin-top: 13px; }
.game-intro { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.game-intro h1 { margin-bottom: 4px; font-size: clamp(23px, 3vw, 32px); }
.game-intro p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); }
.mission-pill, .teacher-badge { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 10px 14px; border-radius: 13px; background: #fff3d0; color: #79540a; font-size: 12px; font-weight: 800; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(265px, .8fr); gap: 20px; align-items: start; }
.game-panel, .sidebar-card, .teacher-card { border: 1px solid var(--line); border-radius: 21px; background: white; box-shadow: 0 8px 25px rgba(27,64,89,.045); }
.game-panel { padding: 24px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.panel-heading h2 { margin-bottom: 3px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.level-chip { flex-shrink: 0; padding: 5px 9px; border-radius: 9px; background: #edf7ff; color: #27638a; font-size: 11px; font-weight: 800; }
.sudoku-grid { width: min(100%, 460px); aspect-ratio: 1; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); margin: 0 auto; border: 3px solid #24445c; border-radius: 12px; overflow: hidden; direction: ltr; background: #fff; }
.sudoku-cell { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 3px; border: 1px solid #cad8e0; border-radius: 0; background: white; cursor: pointer; transition: background .12s ease; color: var(--ink); }
.sudoku-cell:nth-child(4n) { border-right: 0; }
.sudoku-cell:nth-last-child(-n+4) { border-bottom: 0; }
.sudoku-cell.block-end-col { border-right: 4px solid #24445c; }
.sudoku-cell.block-end-row { border-bottom: 4px solid #24445c; }
.sudoku-cell.cell-fixed { background: #eff8f5; cursor: default; }
.sudoku-cell.cell-editable:hover { background: #f0fbff; }
.sudoku-cell.cell-selected { background: #fff3cd; box-shadow: inset 0 0 0 3px #e9b942; }
.sudoku-cell.cell-drop-target { background: #dcf8ec; }
.sudoku-cell.cell-empty { color: #bdcbd3; font-size: 23px; }
.cell-symbol { font-size: clamp(23px, 4vw, 37px); line-height: 1.2; }
.cell-symbol-label { color: #71808b; font-size: clamp(8px, 1.6vw, 10px); line-height: 1.2; }
.game-status { min-height: 47px; display: flex; align-items: center; margin-top: 14px; padding: 10px 13px; border: 1px solid #d7ece7; border-radius: 11px; background: #f2fbf8; color: #276657; font-size: 12px; }
.game-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.submit-form { margin: 0; }
.game-sidebar { display: grid; gap: 17px; }
.sidebar-card { padding: 20px; }
.energy-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.energy-card { min-height: 95px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; padding: 10px 6px; border: 1px solid #e0eaf0; border-radius: 15px; background: #fbfdff; color: var(--ink); cursor: grab; font-size: 12px; font-weight: 700; transition: border .15s ease, background .15s ease, transform .15s ease; }
.energy-card:hover { transform: translateY(-2px); border-color: #9dcfd0; }
.energy-card.is-selected { border: 2px solid var(--primary); background: #e9faf6; box-shadow: 0 0 0 3px rgba(8,126,139,.08); }
.energy-icon { font-size: 32px; line-height: 1.2; }
.story-card { background: linear-gradient(145deg, #f4fbff, #f4fff9); }
.story-icon { display: inline-block; margin-bottom: 5px; font-size: 31px; }
.story-card p { color: #526c7b; font-size: 13px; }
.tip { padding: 11px 12px; border-radius: 10px; background: #fff5d9; color: #785c19; font-size: 11px; line-height: 1.9; }
.result-card { padding: 36px; }
.result-icon { background: #fff3ce; font-size: 39px; }
.score-ring { width: 144px; height: 144px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 25px auto; border: 9px solid #cbeee2; border-radius: 50%; background: #f3fcf8; }
.score-ring strong { font-size: 44px; line-height: 1.25; }
.score-ring span { color: var(--muted); font-size: 11px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.result-stats div { display: flex; flex-direction: column; gap: 3px; padding: 12px 5px; border-radius: 12px; background: #f5f9fb; }
.result-stats strong { font-size: 12px; }
.result-stats span { color: var(--muted); font-size: 10px; }
.result-message { padding: 12px 14px; border-radius: 12px; background: #f1faf6; color: #2d6856; font-size: 13px; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 19px; }
.teacher-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.teacher-header h1 { margin-bottom: 4px; }
.teacher-grid { display: grid; grid-template-columns: 1fr .85fr; gap: 18px; align-items: start; margin-bottom: 20px; }
.teacher-card { padding: 22px; margin-bottom: 20px; }
.teacher-card .stack-form { margin-top: 15px; }
.teacher-summary { display: grid; gap: 14px; }
.mini-stat { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf1f3; }
.mini-stat:last-of-type { border-bottom: 0; }
.mini-stat-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 13px; background: #eff8ff; font-size: 21px; }
.mini-stat div { display: flex; flex-direction: column; }
.mini-stat strong { font-size: 15px; }
.mini-stat span:not(.mini-stat-icon) { color: var(--muted); font-size: 11px; }
.table-card { padding: 20px 0 0; overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 20px 12px; }
.section-heading h2 { margin-bottom: 2px; }
.section-heading p { margin: 0; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; font-size: 12px; }
th, td { padding: 12px 14px; border-top: 1px solid #eaf0f3; text-align: right; vertical-align: middle; }
th { background: #f7fafb; color: #607383; font-weight: 800; white-space: nowrap; }
td code { font-family: Consolas, monospace; direction: ltr; display: inline-block; color: #24677c; }
.inline-reset-form { display: grid; grid-template-columns: 120px 120px auto; gap: 5px; align-items: center; min-width: 340px; }
.inline-reset-form input { padding: 7px; font-size: 11px; }
.score-chip { display: inline-block; padding: 4px 8px; border-radius: 7px; background: #edf5ff; color: #2d6188; font-weight: 800; white-space: nowrap; }
.score-perfect { background: #e4f8ed; color: #18724e; }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; padding: 24px; }
  .hero-art { min-height: 225px; }
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar { grid-template-columns: 1fr 1fr; }
  .teacher-grid { grid-template-columns: 1fr; }
  .teacher-summary { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
  .topbar { padding-inline: 14px; }
  .user-greeting { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .page-wrap { width: calc(100% - 22px); margin-top: 20px; }
  .hero { padding: 21px; border-radius: 20px; }
  .hero-art { min-height: 190px; }
  .orb { width: 65px; height: 65px; border-radius: 19px; font-size: 32px; }
  .login-choices { grid-template-columns: 1fr; gap: 12px; }
  .choice-card { min-height: 160px; padding: 19px; }
  .auth-card, .result-card { padding: 23px 17px; }
  .game-intro, .teacher-header { align-items: flex-start; flex-direction: column; }
  .game-panel { padding: 13px; }
  .panel-heading { flex-direction: column; }
  .level-chip { align-self: flex-start; }
  .game-actions { align-items: stretch; flex-direction: column; }
  .game-actions .button, .submit-form, .submit-form .button { width: 100%; }
  .game-sidebar { grid-template-columns: 1fr; }
  .sudoku-grid { width: 100%; }
  .cell-symbol { font-size: clamp(22px, 7vw, 34px); }
  .cell-symbol-label { font-size: 8px; }
  .result-stats { grid-template-columns: 1fr; }
  .result-stats div { padding: 10px; }
  .result-actions { flex-direction: column; }
  .result-actions .button { width: 100%; }
  .teacher-card { padding-inline: 14px; }
}
