/* ---------- Paper panel ---------- */
.paper {
  position: relative;
  background:
    radial-gradient(120% 80% at 30% 0%, var(--paper-hi), transparent 60%),
    var(--paper);
  border: var(--outline) solid var(--ink);
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 3px var(--paper-hi),
    inset 0 0 0 5px var(--paper-edge),
    var(--drop);
  color: var(--ink);
}

/* ---------- Sticky note ---------- */
.sticky-note {
  position: relative;
  background: linear-gradient(170deg, #fbe488, var(--note) 60%, #eecb58);
  border: var(--outline) solid var(--ink);
  border-radius: 4px 4px 18px 4px;
  box-shadow: var(--drop-sm);
  padding: 18px 16px 14px;
  color: var(--ink);
}
.sticky-note::before {
  /* strip of masking tape */
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  width: 72px;
  height: 22px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(233, 222, 190, 0.85);
  border: 2px solid rgba(29, 24, 18, 0.35);
  border-radius: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-face: var(--paper);
  --btn-ring: var(--paper-edge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 18px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: linear-gradient(180deg, var(--paper-hi), var(--btn-face) 55%);
  border: var(--outline) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow:
    inset 0 0 0 3px var(--paper-hi),
    inset 0 0 0 6px var(--btn-ring),
    0 5px 0 var(--ink),
    0 10px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease, filter var(--t-fast);
  touch-action: manipulation;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.04); }
.btn:active:not(:disabled) {
  transform: translateY(4px) scale(.985);
  box-shadow:
    inset 0 0 0 3px var(--paper-hi),
    inset 0 0 0 6px var(--btn-ring),
    0 1px 0 var(--ink),
    0 3px 6px rgba(0, 0, 0, 0.3);
}
.btn:disabled {
  --btn-face: #b9b6b0;
  --btn-ring: #8d8a85;
  background: linear-gradient(180deg, #d2cfca, var(--btn-face) 55%);
  box-shadow:
    inset 0 0 0 3px #d2cfca,
    inset 0 0 0 6px var(--btn-ring),
    0 5px 0 var(--ink);
  color: #5a5750;
  cursor: not-allowed;
}
.btn:disabled .btn__icon { filter: grayscale(1) opacity(0.6); }

.btn--gold { --btn-ring: var(--gold); --btn-face: #f5e3b8; }
.btn--danger { --btn-ring: var(--red); }

.btn--lg { min-height: 56px; font-size: 1.35rem; padding: 10px 24px; }
.btn--xl { min-height: 64px; font-size: 1.5rem; padding: 10px 26px; width: 100%; }
.btn--sm { min-height: 42px; }

.btn--icon {
  width: 52px;
  min-height: 52px;
  padding: 0;
}
.btn--icon.btn--sm { width: 44px; min-height: 44px; }
.btn__icon { width: 1.6em; }
.btn--icon .btn__icon { width: 60%; }

/* ---------- Toggle (matches the pill switches in UI buttons_panels.png) ---------- */
.toggle {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 60px;
  height: 32px;
  margin: 0;
  border: var(--outline) solid var(--ink);
  border-radius: 999px;
  background: #4a4642;
  box-shadow: inset 0 0 0 2px var(--paper-edge), 0 3px 0 var(--ink);
  cursor: pointer;
  transition: background var(--t-med);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
  transition: transform var(--t-med) var(--ease-pop);
}
.toggle:checked { background: var(--blue); }
.toggle:checked::after { transform: translateX(28px); }
.toggle:disabled { filter: grayscale(1); opacity: 0.6; cursor: not-allowed; }

/* ---------- Form fields ---------- */
.select,
.text-input {
  min-height: 44px;
  padding: 6px 12px;
  font-weight: 800;
  background: var(--paper-hi);
  border: var(--outline) solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.12);
}
.select { padding-right: 34px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.text-input { width: 100%; font-size: 1.05rem; }
.text-input::placeholder { color: #9a8a6c; }
.text-input:disabled { opacity: 0.55; }

/* ---------- Ribbon title ---------- */
.ribbon-title {
  position: relative;
  display: inline-block;
  padding: 8px 34px 10px;
  font-size: clamp(1.5rem, 4.5vw, 2.25rem);
  color: var(--paper-hi);
  text-shadow: 0 2px 0 var(--ink);
  background: linear-gradient(180deg, #2a62b8, var(--blue) 60%, var(--blue-deep));
  border: var(--outline) solid var(--ink);
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.15), var(--drop-sm);
  -webkit-text-stroke: 1px var(--ink);
  paint-order: stroke fill;
}

/* ---------- Modal ---------- */
.modal {
  width: min(360px, calc(100vw - 32px));
  padding: 26px 22px 22px;
}
.modal::backdrop { background: rgba(15, 11, 8, 0.65); backdrop-filter: blur(2px); }
.modal__title { font-size: 2rem; text-align: center; margin-bottom: 16px; }
.modal__actions { display: grid; gap: 14px; }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 62px);
  left: 50%;
  z-index: 50;
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 8px 16px;
  font-weight: 900;
  text-align: center;
  background: var(--paper);
  border: var(--outline) solid var(--ink);
  border-radius: 999px;
  box-shadow: var(--drop-sm);
  animation: toast-in var(--t-med) var(--ease-pop);
}
.toast--success { background: #dff0c9; }
.toast--capture { background: #fdf0c4; border-color: var(--ink); font-family: var(--font-display); font-weight: 400; font-size: 1.1rem; }
.toast--warn { background: #f6d4cf; }
.toast--leaving { opacity: 0; transform: translateY(-8px); transition: all 300ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(0.9); } }

/* ---------- Achievement pop-ups (js/ui/achievementView.js) ---------- */
/* A rosette card that slides in when a person earns an achievement in play. Never clickable. */
.achievement-pops {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 62px);
  right: max(16px, env(safe-area-inset-right));
  z-index: 55;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.achievement-pop {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 14px 14px 12px;
  color: var(--ink);
  background: var(--paper-hi);
  border: var(--outline) solid var(--ink);
  border-left-width: 10px;
  border-left-color: var(--edge-deep, var(--gold-deep));
  border-radius: var(--radius-sm);
  box-shadow: var(--drop-sm);
  animation: achievement-in 320ms var(--ease-pop);
}
.achievement-pop .badge__rosette { width: 54px; height: 54px; }
.achievement-pop .badge__rosette::before, .achievement-pop .badge__rosette::after { width: 13px; height: 20px; bottom: -12px; }
.achievement-pop .badge__icon { width: 30px; }
.achievement-pop__text { display: grid; gap: 1px; min-width: 0; }
.achievement-pop__kicker { font-size: 0.72rem; font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; color: var(--tier-ink, var(--ink-soft)); }
.achievement-pop__name { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; line-height: 1.1; }
.achievement-pop__desc { font-size: 0.86rem; line-height: 1.25; overflow-wrap: anywhere; }
.achievement-pop.is-leaving { opacity: 0; transform: translateX(18px); transition: opacity 280ms ease, transform 280ms ease; }
@keyframes achievement-in { from { opacity: 0; transform: translateX(28px) scale(0.92); } }
html[data-effects='reduced'] .achievement-pop { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }

/* ---------- First-game tutorial coach marks (js/ui/tutorial.js) ---------- */
/* A taped sticky note beside the control it explains; non-modal, so play continues underneath. */
.coach-mark {
  position: fixed;
  z-index: 55;
  width: min(300px, calc(100vw - 24px));
  padding: 16px 14px 12px;
  font-size: 0.95rem;
  line-height: 1.35;
  transform: rotate(-0.6deg);
  animation: coach-in var(--t-med) var(--ease-pop);
}
.coach-mark__count { margin: 0 0 2px; font-size: 0.75rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.coach-mark__body { margin: 0; }
.coach-mark__title { font-family: var(--font-display); font-weight: 400; font-size: 1.1rem; }
.coach-mark__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 10px; }
/* Paper arrow pointing at the target. */
.coach-mark::after {
  content: '';
  position: absolute;
  left: calc(var(--arrow-x, 50%) - 9px);
  width: 16px;
  height: 16px;
  background: #f5d96b;
  border: var(--outline) solid var(--ink);
  border-top: 0;
  border-left: 0;
}
.coach-mark[data-side='above']::after { bottom: -10px; transform: rotate(45deg); }
.coach-mark[data-side='below']::after { top: -10px; transform: rotate(225deg); }
/* Inside a dialog (Develop Now, city event, results): a note at the top, no arrow. */
.coach-mark--inline { position: relative; z-index: auto; width: auto; margin: 6px 0 14px; transform: none; }
.coach-mark--inline::after { display: none; }
@keyframes coach-in { from { opacity: 0; transform: translateY(6px) rotate(-0.6deg); } }

.setting-row--action { cursor: default; }

/* ---------- Offline app update prompt (js/pwa.js) ---------- */
.update-banner {
  position: fixed;
  /* The toast slot (on the start and title screens: over the street, see css/title.css). */
  top: calc(max(10px, env(safe-area-inset-top)) + 62px);
  left: 50%;
  z-index: 60;
  width: min(520px, calc(100vw - 32px));
  padding: 10px 12px 10px 18px;
  transform: translateX(-50%);
  box-shadow: var(--drop-sm);
  animation: toast-in var(--t-med) var(--ease-pop);
}
.update-banner:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.update-banner__text { flex: 1 1 200px; font-weight: 900; }
/* Later · Reload stay together on one row, at the end. */
.update-banner__actions { display: flex; gap: 8px; margin-left: auto; }
