:root {
  --ink: #1d2b4f;
  --ink-soft: #46557a;
  --paper: #f7f2e8;
  --card: #fffdf8;
  --line: #e4dccb;
  --accent: #c73e1d;
  --accent-hover: #a93216;
  --sky: #2f7fd0;
  --gold: #ffc93c;
  --mat: #2c6a58;
  --focus: #ffb000;
  --bar-h: 58px;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(29, 43, 79, 0.14), 0 2px 6px rgba(29, 43, 79, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Polin", "Assistant", "Heebo", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
h1, h2 { line-height: 1.15; margin: 0; }
h1:focus, h2:focus { outline: none; }

/* ---- סרגל עליון ---- */
.bar {
  height: var(--bar-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  background: var(--ink);
  color: #fff;
  z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: inherit; font: inherit; font-weight: 700; font-size: 1.15rem;
  cursor: pointer; padding: 6px 4px; min-height: 44px;
}
.brand svg { width: 34px; height: 34px; }
.tools { display: flex; gap: 8px; }
.tool {
  display: flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 0 12px;
  border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, 0.35);
  background: transparent; color: #fff; font: inherit; font-size: 0.92rem; font-weight: 500; cursor: pointer;
}
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: rgba(255, 255, 255, 0.1); }
.tool[aria-pressed="true"] { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.7); }
#sound-btn .cross { display: none; }
#sound-btn[aria-pressed="false"] .cross { display: inline; }
#sound-btn[aria-pressed="false"] .waves { display: none; }

/* ---- כפתורים ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 24px;
  border-radius: 14px; border: 2px solid transparent;
  font: inherit; font-weight: 700; font-size: 1.05rem;
  cursor: pointer; transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 0 #8f2b12; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { box-shadow: 0 3px 0 #8f2b12; transform: translateY(3px); }
.btn.primary:disabled { background: #b9b2a5; box-shadow: 0 6px 0 #8f887b; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover { background: rgba(29, 43, 79, 0.06); }
.btn.ghost:disabled { opacity: 0.4; cursor: default; }
.btn.big { min-height: 58px; font-size: 1.2rem; padding: 0 34px; }
.link {
  background: none; border: 0; padding: 8px 2px; color: var(--ink-soft);
  font: inherit; font-size: 0.95rem; text-decoration: underline; text-underline-offset: 4px; cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.actions.col { flex-direction: column; align-items: stretch; }

/* ---- מסכים ---- */
main { flex: 1; position: relative; min-height: 0; }
.screen { position: absolute; inset: 0; overflow: auto; }

/* פתיחה */
.home { display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, #5aa2e3 0%, #a9d6f3 55%, #fbeccd 100%); }
.home-sky { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.home-sky .loop { position: absolute; inset: 8% 0 auto 0; width: 100%; height: 50%; opacity: 0.85; }
.cloud { position: absolute; background: #fff; border-radius: 999px; opacity: 0.85; height: 38px; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 50px; height: 50px; top: -24px; right: 18px; }
.cloud::after { width: 36px; height: 36px; top: -16px; left: 16px; }
.c1 { width: 130px; top: 14%; right: 8%; animation: drift 38s linear infinite; }
.c2 { width: 100px; top: 32%; left: 6%; animation: drift 52s linear infinite reverse; }
.c3 { width: 160px; bottom: 16%; right: 22%; opacity: 0.6; animation: drift 64s linear infinite; }
@keyframes drift { from { transform: translateX(-40px); } 50% { transform: translateX(40px); } to { transform: translateX(-40px); } }
.home-card {
  position: relative; max-width: 560px; width: 100%;
  background: var(--card); border-radius: 26px; padding: 34px 30px 26px; box-shadow: var(--shadow);
  text-align: center;
}
.home-card::before {
  content: ""; position: absolute; inset: 10px; border: 2px dashed var(--line); border-radius: 18px; pointer-events: none;
}
.home h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 900; letter-spacing: -0.5px; }
.lead { font-size: 1.15rem; color: var(--ink-soft); margin: 10px auto 22px; max-width: 30ch; }
.how { list-style: none; padding: 0; margin: 28px 0 10px; display: grid; gap: 10px; text-align: start; }
.how li { display: flex; align-items: center; gap: 12px; background: var(--paper); border-radius: 12px; padding: 10px 14px; }
.how .num {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-weight: 900;
}
.install { margin-top: 14px; }
.install .btn { min-height: 46px; font-size: 1rem; }
.install img { border-radius: 7px; }
.install-ios { margin: 14px auto 0; max-width: 34ch; font-size: 0.95rem; background: #e7eefb; color: #23407a; border-radius: 12px; padding: 8px 12px; }
.note { font-size: 0.88rem; color: var(--ink-soft); margin: 14px 0 0; }

/* בחירת מטוס */
.pick { background: var(--paper); }
.pick-inner { max-width: 1060px; margin: 0 auto; padding: 28px 18px 40px; }
.pick h2 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 900; }
.sub { color: var(--ink-soft); margin: 6px 0 22px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  width: 100%; height: 100%; text-align: start; display: flex; flex-direction: column; gap: 10px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px 18px 18px;
  font: inherit; color: inherit; cursor: pointer; box-shadow: 0 2px 0 var(--line);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--ink); box-shadow: var(--shadow); }
.card canvas { width: 100%; height: 150px; border-radius: 12px; background: linear-gradient(180deg, #8cc4ee, #d9eefb); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-name { font-size: 1.5rem; font-weight: 900; }
.level { font-size: 0.85rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #e7eefb; color: #23407a; }
.level.l2 { background: #fff1d1; color: #7a4d00; }
.level.l3 { background: #fde2da; color: #8f2b12; }
.blurb { margin: 0; color: var(--ink-soft); }
.stats { display: grid; gap: 4px; margin: 2px 0 0; padding: 0; list-style: none; font-size: 0.9rem; }
.stats li { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 8px; }
.bar5 { display: flex; gap: 3px; }
.bar5 i { flex: 1; height: 8px; border-radius: 3px; background: #e9e3d6; }
.bar5 i.on { background: var(--sky); }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; font-size: 0.9rem; color: var(--ink-soft); }
.mini-stars { color: var(--gold); font-size: 1.15rem; letter-spacing: 2px; -webkit-text-stroke: 0.6px #b88400; }
.mini-stars .off { color: #e6dfcf; -webkit-text-stroke: 0.6px #cfc6b2; }

/* מסך עם במה ולוח צד (קיפול, מוכן) */
.fold, .ready { display: grid; grid-template-columns: 1fr minmax(300px, 380px); }
.stage { position: relative; min-height: 0; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.mat {
  background-color: var(--mat);
  background-image:
    linear-gradient(rgba(255,255,255,0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.09) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  background-position: center;
}
.skybox { background: radial-gradient(ellipse at 70% 20%, #fff6d6 0%, rgba(255,246,214,0) 40%), linear-gradient(180deg, #4f9be0, #a9d6f3 60%, #fbeccd); }
.stage-tip {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  margin: 0; padding: 8px 16px; border-radius: 999px;
  background: rgba(29, 43, 79, 0.82); color: #fff; font-size: 0.95rem; font-weight: 500;
  white-space: nowrap; pointer-events: none; transition: opacity 0.3s;
}
.stage-tip:empty { display: none; }
.panel {
  background: var(--card); border-inline-start: 1px solid var(--line);
  padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; overflow: auto;
}
.eyebrow { margin: 0; font-weight: 700; color: var(--accent); font-size: 0.95rem; }
.panel h2 { font-size: 1.9rem; font-weight: 900; }
.dots { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.dots li { width: 26px; height: 8px; border-radius: 4px; background: #e9e3d6; }
.dots li.done { background: var(--sky); }
.dots li.now { background: var(--accent); }
.instr { font-size: 1.15rem; margin: 0; min-height: 3.2em; }
.kind { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 0.95rem; color: var(--ink-soft); }
.kind::before { content: ""; width: 44px; height: 0; border-top: 3px dashed var(--accent); flex: none; }
.kind.mountain::before { border-top-style: dotted; border-top-width: 4px; }
.colors { border: 0; padding: 0; margin: 6px 0 0; }
.colors legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; width: 44px; height: 44px; margin: 0; cursor: pointer; }
.swatch span {
  display: block; width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); background: var(--c);
}
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--ink); }
.swatch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 4px; }
.panel .link { align-self: flex-start; margin-top: auto; }

/* טיסה */
.fly { display: grid; grid-template-rows: 1fr auto; }
.fly .stage { background: #a9d6f3; }
.hud {
  position: absolute; top: 12px; right: 12px; left: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; pointer-events: none;
}
.hud li {
  display: flex; align-items: baseline; gap: 6px;
  background: rgba(255, 253, 248, 0.92); border-radius: 12px; padding: 6px 12px; box-shadow: 0 2px 8px rgba(29,43,79,0.12);
}
.hud .k { font-size: 0.85rem; color: var(--ink-soft); }
.hud .v { font-size: 1.35rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud .u { font-size: 0.85rem; }
.hud .wind { margin-inline-start: auto; }
.hud .wind .v { font-size: 1rem; font-weight: 700; }
.lift {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  min-height: 64px; padding: 0 28px; border-radius: 999px;
  border: 3px solid #fff; background: var(--ink); color: #fff;
  font: inherit; font-weight: 700; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 8px 20px rgba(29,43,79,0.3); touch-action: none; user-select: none; -webkit-user-select: none;
  white-space: nowrap;
}
.lift svg { width: 26px; height: 26px; }
.lift.on { background: var(--accent); transform: translateX(-50%) scale(0.97); }
.fly .stage-tip { bottom: auto; top: 74px; }
.aim {
  display: flex; align-items: center; gap: 18px 26px; flex-wrap: wrap;
  padding: 14px max(18px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--card); border-top: 1px solid var(--line);
}
.field { display: grid; grid-template-columns: auto 1fr 3.4em; align-items: center; gap: 10px; flex: 1 1 220px; }
.field label { font-weight: 700; }
.field output { font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); cursor: pointer; }
.aim .btn { flex: 0 0 auto; }

/* תוצאה */
.result {
  border: 0; border-radius: 24px; padding: 28px 26px 24px; width: min(420px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); text-align: center;
}
.result::backdrop { background: rgba(29, 43, 79, 0.45); }
.result h2 { font-size: 2rem; font-weight: 900; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 14px 0 6px; }
.stars svg { width: 58px; height: 58px; }
.stars .on path { fill: var(--gold); stroke: #b88400; }
.stars .off path { fill: #ece6d8; stroke: #cfc6b2; }
.stars .on { animation: pop 0.45s cubic-bezier(.2,1.6,.4,1) both; }
.stars .on:nth-child(2) { animation-delay: 0.15s; }
.stars .on:nth-child(3) { animation-delay: 0.3s; }
@keyframes pop { from { transform: scale(0.2) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
.best { display: inline-block; margin: 4px 0 0; padding: 4px 14px; border-radius: 999px; background: var(--gold); font-weight: 900; }
.numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 8px; }
.numbers div { background: var(--paper); border-radius: 12px; padding: 8px 4px; }
.numbers dt { font-size: 0.85rem; color: var(--ink-soft); }
.numbers dd { margin: 0; font-size: 1.3rem; font-weight: 900; }
.numbers .total { background: var(--ink); color: #fff; }
.numbers .total dt { color: #cfd8ee; }
.next { color: var(--ink-soft); margin: 6px 0 16px; min-height: 1.5em; }

/* ---- טלפון ומסכים צרים ---- */
@media (max-width: 820px) {
  .fold, .ready { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) auto; }
  .panel { border-inline-start: 0; border-top: 1px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); gap: 10px; max-height: 48dvh; }
  .panel h2 { font-size: 1.45rem; }
  .instr { font-size: 1.05rem; min-height: 0; }
  .fold .actions { flex-wrap: nowrap; }
  .fold .actions .btn { flex: 1; padding: 0 12px; }
  .fold .colors { margin: 0; }
  .swatches { gap: 8px; }
  .tool span { display: none; }
  .tool { padding: 0 10px; }
  .stage-tip { font-size: 0.85rem; white-space: normal; text-align: center; width: max-content; max-width: 90%; }
  .aim { gap: 8px 14px; padding-top: 10px; }
  .field { flex-basis: 100%; }
  .aim .btn { flex: 1 1 100%; }
  .hud .v { font-size: 1.1rem; }
  .hud li { padding: 4px 10px; }
  .lift { min-height: 58px; bottom: 14px; }
  .fly .stage-tip { top: 108px; }
  .fold .stage-tip { bottom: 8px; padding: 6px 12px; font-size: 0.8rem; }
}
@media (max-width: 420px) {
  body { font-size: 16px; }
  .brand span { font-size: 1.05rem; }
  .home-card { padding: 26px 18px 20px; }
}

/* ---- פחות תנועה ---- */
.reduce *, .reduce *::before, .reduce *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- ניגודיות גבוהה של מערכת ההפעלה ---- */
@media (forced-colors: active) {
  .btn, .card, .tool, .lift { border: 2px solid ButtonText; }
  .swatch span { forced-color-adjust: none; }
}

.noscript { position: fixed; inset: auto 16px 16px; margin: 0; padding: 14px; border-radius: 12px; background: var(--ink); color: #fff; text-align: center; z-index: 10; }
