/* המרוץ לעצמאות - מסכים כלליים (פתיחה, תחקיר, מודאלים).
   הפלטה מיושרת ל-css/board.css. הכיוון כהה בלבד, אז אין כאן ערכת בהיר. */

:root {
  --bg: #05050e;
  --surface: #11102a;
  --surface-2: #191740;
  --line: #2a2752;
  --text: #e9e9ff;
  --muted: #8d8bc4;
  --accent: #22e8ff;
  --accent-dim: #0e4a58;
  --warn: #ffd83f;
  --danger: #ff5c7a;
  --info: #22e8ff;
  --purple: #b475ff;
  --radius: 14px;
  --shadow: 0 10px 30px -14px #000;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Assistant', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

body {
  min-height: 100svh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }

.view { display: none; }
.view.active { display: block; }

h1 { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: -0.4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
p  { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- כרטיסים ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ---------- כפתורים ---------- */
button {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.06s ease, opacity 0.15s ease;
  /* ל-iOS יש מטריקות מרכוז משלו ל-button. זה מיישר אותו לשאר הדפדפנים. */
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* מספרים וסכומים בתוך משפט עברי מתהפכים בלי הבידוד הזה. */
.num, .money { unicode-bidi: isolate; direction: ltr; display: inline-block; }
/* display:inline-flex למעלה דורס את [hidden] של הדפדפן. בלי השורה הזו כפתור מוסתר עדיין מוצג. */
button[hidden], [hidden] { display: none !important; }

button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(160deg, #5cf3ff, var(--accent)); color: #04121a;
  box-shadow: 0 0 20px rgba(34,232,255,.35); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
button.wide { width: 100%; }
.btn-row { display: flex; gap: 10px; }
.btn-row > button { flex: 1; }

/* ---------- שורת מצב עליונה ---------- */
.status {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.status-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.age { font-size: 0.85rem; color: var(--muted); }
.age b { color: var(--text); font-size: 1rem; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.metric .label { font-size: 0.7rem; color: var(--muted); display: block; }
.metric .value { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric.good .value { color: var(--accent); }
.metric.bad .value { color: var(--danger); }

/* פס ההתקדמות לניצחון */
.progress { margin-top: 10px; }
.progress-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 99px;
  transition: width 0.5s ease;
}
.progress-label { font-size: 0.78rem; color: var(--muted); margin-top: 5px; display: flex; justify-content: space-between; }

/* ---------- הקוביה ---------- */
.roll-area { text-align: center; padding: 8px 0 4px; }
.die {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.die.rolling { animation: tumble 0.5s ease-in-out; }
@keyframes tumble {
  0%   { transform: rotate(0deg)   scale(1); }
  50%  { transform: rotate(180deg) scale(1.25); }
  100% { transform: rotate(360deg) scale(1); }
}
.square-now { font-size: 0.9rem; color: var(--muted); margin-bottom: 12px; }
.square-now b { color: var(--text); }

/* ---------- דוח פיננסי ---------- */
.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ledger td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.ledger td:last-child { text-align: left; font-weight: 700; white-space: nowrap; }
.ledger tr:last-child td { border-bottom: none; }
.ledger tr.total td { border-top: 2px solid var(--line); padding-top: 10px; font-weight: 800; }
.ledger .pos { color: var(--accent); }
.ledger .neg { color: var(--danger); }
.ledger .sub td { color: var(--muted); font-size: 0.88rem; padding-right: 12px; }

details.group { margin-bottom: 12px; }
details.group > summary {
  cursor: pointer;
  font-weight: 700;
  padding: 10px 0;
  list-style: none;
  display: flex;
  justify-content: space-between;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "▾"; color: var(--muted); }
details.group[open] > summary::after { content: "▴"; }

/* ---------- מודאל קלף ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.overlay.open { display: flex; }
.sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 4px solid var(--line);
  width: 100%;
  max-width: 560px;
  max-height: 88svh;
  overflow-y: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: rise 0.24s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; border-top-width: 4px; }
}

.kicker {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.k-deal { color: var(--info); }
.k-big  { color: var(--purple); }
.k-temp { color: var(--warn); }
.k-life { color: var(--info); }
.k-mkt  { color: var(--warn); }
.sheet h3 { font-size: 1.25rem; margin: 0 0 8px; }

.numbers { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin: 14px 0; }
.numbers .row { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.numbers .row.head { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 800; }
.risk {
  border-right: 3px solid var(--warn);
  padding: 4px 12px 4px 0;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

/* ---------- תחקיר ---------- */
.debrief-block { margin-bottom: 20px; }
.debrief-block h3 { font-size: 1rem; margin: 0 0 8px; color: var(--accent); }
.chart { width: 100%; height: 150px; display: block; }
.stat-big { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pill {
  display: inline-block;
  background: var(--surface-2);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 6px 6px;
}
.assumptions { font-size: 0.85rem; color: var(--muted); }
.assumptions li { margin-bottom: 5px; }

.toast {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  right: 50%;
  transform: translateX(50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.toast.show { opacity: 1; }
