/* ============================================================
   Start menu — full-screen overlay shown before the game.
   ============================================================ */

/* Hide the in-game UI until the menu is dismissed */
body.pre-game .topbar,
body.pre-game .layout,
body.pre-game #toast,
body.pre-game #day-flash { display: none !important; }

.start-menu {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #0c1420 0%, #131f2d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  /* Allow vertical scrolling on short / mobile viewports — audit finding
     E21. The previous overflow: hidden made the bottom of the panel
     (Start button + How to Play details) unreachable when the viewport
     was shorter than the panel + difficulty grid stacked into one column. */
  overflow: auto;
  animation: smFadeIn 400ms var(--ease);
}
body:not(.pre-game) .start-menu {
  pointer-events: none;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 320ms ease, transform 320ms var(--ease);
}
@keyframes smFadeIn {
  from { opacity: 0; transform: scale(1.03); }
  to   { opacity: 1; transform: scale(1); }
}

.sm-bg { position: absolute; inset: 0; pointer-events: none; }
.sm-bg-svg { width: 100%; height: 100%; }

.sm-panel {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: var(--sp-6) var(--sp-6);
  max-width: 880px;
  width: calc(100% - 48px);
  box-shadow: 0 18px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(79,195,247,0.06);
}

/* ---------- brand title ---------- */
.sm-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.sm-logo {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(79,195,247,0.12);
  color: var(--accent);
  border-radius: 14px;
  border: 1px solid rgba(79,195,247,0.25);
}
.sm-logo svg { width: 32px; height: 32px; }
.sm-title {
  margin: 0;
  font-size: 32px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.5px;
  line-height: 1;
}
.sm-tagline {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: var(--fs-md);
}

/* ---------- difficulty grid ---------- */
.sm-section-label {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: var(--fw-bold);
  color: var(--text-dim);
  margin-bottom: var(--sp-2);
}
.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.diff-card {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-3);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.diff-card:hover {
  transform: translateY(-2px);
  border-color: var(--diff-color, var(--border-strong));
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
}
.diff-card:focus-visible {
  outline: none;
  border-color: var(--diff-color, var(--accent));
  box-shadow: 0 0 0 3px rgba(79,195,247,0.35);
}
.diff-card.selected {
  border-color: var(--diff-color, var(--accent));
  background: linear-gradient(180deg, var(--bg-card), rgba(79,195,247,0.06));
  box-shadow: 0 0 0 1px var(--diff-color, var(--accent)),
              0 8px 24px rgba(0,0,0,0.45);
}
.diff-card.selected::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--diff-color, var(--accent));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.diff-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.diff-icon {
  font-size: 26px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--diff-color, var(--bg-shell));
  color: #fff;
  border-radius: 10px;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.diff-name {
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  line-height: 1.1;
}
.diff-name-label {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: var(--fw-bold);
  color: var(--diff-color, var(--text-dim));
  margin-bottom: 2px;
}
.diff-tagline {
  color: var(--text-dim);
  font-size: var(--fs-sm);
  font-style: italic;
}
.diff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.diff-list li {
  font-size: var(--fs-sm);
  color: var(--text);
  padding-left: 18px;
  position: relative;
}
.diff-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--diff-color, var(--accent));
  font-weight: var(--fw-bold);
}

/* ---------- actions + how-to-play ---------- */
.sm-actions {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-3);
}
.sm-start-btn {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  padding: 12px var(--sp-6);
  letter-spacing: 0.5px;
  min-width: 280px;
}

.sm-howto details {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
}
.sm-howto summary {
  cursor: pointer;
  font-weight: var(--fw-semi);
  color: var(--text-dim);
  font-size: var(--fs-sm);
  user-select: none;
  list-style: none;
}
.sm-howto summary::-webkit-details-marker { display: none; }
.sm-howto summary::before {
  content: "▸ ";
  color: var(--accent);
  transition: transform var(--dur-fast) var(--ease);
  display: inline-block;
}
.sm-howto details[open] summary::before { content: "▾ "; }
.sm-howto ol {
  margin: var(--sp-2) 0 0 0;
  padding-left: var(--sp-4);
  color: var(--text-dim);
  font-size: var(--fs-sm);
}
.sm-howto ol li { margin: 4px 0; }
.sm-howto b { color: var(--text); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .difficulty-grid { grid-template-columns: 1fr; }
  .sm-panel { padding: var(--sp-4); }
  .sm-title { font-size: 26px; }
}

/* ---------- Continue card + Delete save link + divider ---------- */
.sm-continue-section {
  margin-bottom: var(--sp-3);
}
.sm-continue-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: var(--fw-bold);
  text-align: left;
  transition: filter var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.sm-continue-card:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.sm-continue-label {
  font-size: var(--fs-lg);
}
.sm-continue-meta {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  opacity: 0.85;
}
.sm-continue-meta.sm-continue-error {
  color: #7a1200;
  font-weight: var(--fw-bold);
  opacity: 1;
}
.sm-delete-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: var(--fs-xs);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
}
.sm-delete-link:hover { color: var(--bad); }
.sm-delete-link.armed {
  color: var(--bad);
  font-weight: var(--fw-bold);
  text-decoration: none;
}
.sm-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-3) 0;
  color: var(--text-dim);
  font-size: var(--fs-xs);
}
.sm-divider span {
  white-space: nowrap;
  padding: 0 var(--sp-2);
  flex: 0 0 auto;
}
.sm-divider::before,
.sm-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Two-click overwrite confirm on the Start button when a save exists.
   Reuses the scrap-armed-pulse keyframes from css/base.css. */
.sm-start-btn.armed {
  background: var(--bad) !important;
  color: white !important;
  animation: scrap-armed-pulse 0.8s ease-in-out infinite;
}
