/* ============================================================
   Ierbarul Otiliei — stiluri
   Estetică: hârtie caldă, verde salvie, accente florale discrete.
   Fonturi de sistem: serif pentru titluri, sans-serif pentru corp.
   ============================================================ */

:root {
  --paper: #f6efe1;
  --paper-strong: #fdf8ec;
  --paper-shadow: #d8cbb2;
  --ink: #3d4736;
  --ink-soft: #5d6653;
  --sage: #7ea55c;
  --sage-dark: #5c7c45;
  --sage-deep: #3f5836;
  --earth: #8a6b4f;
  --earth-dark: #6d523a;
  --accent: #d9a95c;
  --danger: #a3573f;
  --danger-dark: #83432f;
  --focus: #c98a2e;
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
  --shadow-soft: 0 6px 18px rgba(52, 44, 30, 0.16);
}

[hidden] { display: none !important; }

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overscroll-behavior: none;
  background-color: #2a3527;
}

button,
select,
input {
  touch-action: manipulation;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 12%, rgba(246, 239, 225, 0.12), transparent 42%),
    linear-gradient(180deg, #33402f 0%, #2a3527 100%);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.noscript {
  max-width: 640px;
  margin: 40px auto;
  padding: 20px;
  background: var(--paper);
  border-radius: var(--radius);
  font-family: var(--sans);
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Ecrane ---------- */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  gap: 14px;
}

.screen[hidden] {
  display: none;
}

.screen:focus {
  outline: none;
}

/* Pe ecrane mici conținutul poate depăși înălțimea: panoul se centrează când
   există spațiu și devine derulabil când nu există. */
.panel {
  margin: auto;
}

.screen-game {
  position: relative;
  padding: 0;
  justify-content: center;
  overflow: hidden;
}

.screen-overlay {
  background:
    radial-gradient(circle at 50% 18%, rgba(246, 239, 225, 0.1), transparent 55%),
    linear-gradient(180deg, #33402f 0%, #2a3527 100%);
}

.panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 42%),
    var(--paper);
  border: 1px solid var(--paper-shadow);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 28px 26px;
}

.wide-panel {
  max-width: 860px;
}

.modal-panel {
  max-width: 460px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-sub {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--sage-dark);
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  color: var(--sage-deep);
  margin: 0 0 10px;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 6vw, 2.9rem);
  letter-spacing: 0.01em;
}

h2 {
  font-size: clamp(1.5rem, 4.5vw, 2rem);
}

h3 {
  font-size: 1.15rem;
}

.section-label {
  margin: 22px 0 8px;
  color: var(--sage-dark);
  font-size: 1.02rem;
  border-bottom: 2px dotted rgba(90, 110, 70, 0.35);
  padding-bottom: 4px;
}

/* ---------- Meniu ---------- */

.screen-menu {
  position: relative;
  overflow: hidden;
}

.menu-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sprig {
  position: absolute;
  top: 50%;
  width: clamp(120px, 22vw, 200px);
  height: auto;
  opacity: 0.5;
}

.sprig-left {
  left: max(-30px, calc(50% - 500px));
  transform: translateY(-58%);
}

.sprig-right {
  right: max(-30px, calc(50% - 500px));
  transform: translateY(-62%);
}

.menu-panel {
  text-align: center;
  max-width: 560px;
  z-index: 1;
}

.menu-subtitle {
  margin: 0 auto 12px;
  max-width: 40ch;
  color: var(--ink-soft);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.menu-banner {
  display: block;
  width: min(100%, 380px);
  height: auto;
  margin: 0 auto 6px;
  image-rendering: auto;
}

.progress-badge {
  display: inline-block;
  margin: 4px 0 16px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(126, 165, 92, 0.16);
  border: 1px solid rgba(126, 165, 92, 0.4);
  color: var(--sage-dark);
  font-weight: 600;
  font-size: 0.94rem;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 330px;
  margin: 0 auto;
}

.menu-footnote {
  position: relative;
  z-index: 1;
  margin: 0;
  color: rgba(246, 239, 225, 0.75);
  font-size: 0.9rem;
  text-align: center;
}

.warning {
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(217, 169, 92, 0.18);
  border: 1px solid rgba(217, 169, 92, 0.5);
  font-size: 0.9rem;
  color: #6d523a;
  text-align: left;
}

/* ---------- Butoane ---------- */

.btn {
  appearance: none;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--earth-dark);
  background: linear-gradient(180deg, var(--paper-strong), #ece1cb);
  border: 2px solid #cdbfa8;
  border-radius: 14px;
  padding: 11px 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 #c6b79c;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  min-height: 44px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #c6b79c;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #c6b79c;
}

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  color: #f8f4e8;
  background: linear-gradient(180deg, #8cae66, var(--sage-dark));
  border-color: var(--sage-deep);
  box-shadow: 0 3px 0 var(--sage-deep);
}

.btn-primary:hover {
  box-shadow: 0 4px 0 var(--sage-deep);
}

.btn-primary:active {
  box-shadow: 0 1px 0 var(--sage-deep);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
  border-color: rgba(109, 82, 58, 0.35);
}

.btn-danger {
  color: #fdf6ee;
  background: linear-gradient(180deg, #b4674d, var(--danger-dark));
  border-color: #6d3626;
  box-shadow: 0 3px 0 #6d3626;
}

.btn-small {
  font-size: 0.9rem;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 12px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.stack-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  margin: 10px auto 0;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions {
  justify-content: flex-end;
}

/* ---------- Niveluri ---------- */

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 12px;
  background: var(--paper-strong);
  border: 2px solid var(--paper-shadow);
  border-radius: 14px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--paper-shadow);
  transition: transform 120ms ease, box-shadow 120ms ease;
  min-height: 44px;
}

.level-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--paper-shadow);
}

.level-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.level-card.locked {
  cursor: not-allowed;
  opacity: 0.72;
  filter: saturate(0.55);
}

.level-card.completed {
  border-color: rgba(126, 165, 92, 0.66);
}

.level-thumb {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--paper-shadow);
  display: block;
}

.level-card-title {
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--sage-deep);
  margin: 0;
}

.level-card-plants {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.level-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(63, 88, 54, 0.85);
  color: #f6efe1;
}

.level-card.available .level-badge {
  background: rgba(126, 165, 92, 0.92);
}

.level-card.completed .level-badge {
  background: rgba(92, 124, 69, 0.95);
}

/* ---------- Joc / HUD ---------- */

/* În timpul jocului pagina nu derulează și nu lasă gesturi de browser să
   interfereze (pull-to-refresh, zoom prin dublu tap pe suprafața de joc). */
body.playing {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Scena umple tot spațiul ecranului. Viewport-ul logic se adaptează la
   aspectul dispozitivului (vezi game.js), deci nu apar benzi negre și
   imaginea nu este deformata. */
.game-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #cfe6f2;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.paper-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, transparent 62%, rgba(74, 60, 38, 0.16) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px);
  mix-blend-mode: multiply;
}

/* Stare de încărcare: acoperă scena cât se preîncarcă ilustrațiile nivelului. */
.game-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(42, 53, 39, 0.55);
  z-index: 5;
}

.game-loading[hidden] {
  display: none;
}

.game-loading p {
  margin: 0;
  padding: 12px 22px;
  background: rgba(253, 248, 236, 0.97);
  border: 1px solid var(--paper-shadow);
  border-radius: 14px;
  font-size: 0.98rem;
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(30, 24, 14, 0.3);
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
  pointer-events: none;
  z-index: 2;
}

.hud > * {
  pointer-events: auto;
}

.hud-actions {
  display: flex;
  gap: 8px;
  flex: none;
  margin-left: auto;
}

.hud-title {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--sage-deep);
  background: rgba(253, 248, 236, 0.9);
  border: 1px solid var(--paper-shadow);
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}

.hud-collectibles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(253, 248, 236, 0.9);
  border: 1px solid var(--paper-shadow);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.86rem;
  color: var(--ink);
  white-space: nowrap;
}

.hud-chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sage);
  flex: none;
}

.hud-chip.done {
  background: rgba(126, 165, 92, 0.92);
  border-color: var(--sage-dark);
  color: #f8f4e8;
}

.hud-chip.done .dot {
  background: #f8f4e8;
}

/* ---------- Controale tactile ---------- */

.touch-controls {
  position: absolute;
  inset: auto 0 0 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 calc(18px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  pointer-events: none;
  z-index: 2;
}

body.touch .touch-controls {
  display: flex;
}

/* Portret: scena umple ecranul, lumea este centrată vertical (cer deasupra,
   pământ dedesubt), iar HUD-ul se așază pe două rânduri ca să nu se înghesuie. */
@media (orientation: portrait) {
  .hud {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .hud-collectibles {
    order: 3;
    flex-basis: 100%;
  }

  body.touch .touch-btn {
    width: 84px;
    height: 84px;
    font-size: 1.7rem;
  }

  body.touch .touch-jump {
    width: 98px;
    height: 98px;
    font-size: 1.9rem;
  }
}

.touch-move {
  display: flex;
  gap: 12px;
}

.touch-btn {
  pointer-events: auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid rgba(92, 124, 69, 0.6);
  background: rgba(253, 248, 236, 0.82);
  color: var(--sage-deep);
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 0 rgba(92, 124, 69, 0.4);
}

.touch-btn.active {
  background: rgba(126, 165, 92, 0.95);
  color: #f8f4e8;
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(92, 124, 69, 0.4);
}

.touch-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.touch-jump {
  width: 86px;
  height: 86px;
  font-size: 1.7rem;
  border-color: rgba(138, 107, 79, 0.65);
  box-shadow: 0 4px 0 rgba(138, 107, 79, 0.4);
}

/* ---------- Ierbar ---------- */

.herbarium-panel {
  background:
    linear-gradient(90deg, rgba(138, 107, 79, 0.14) 0 2px, transparent 2px) 34px 0 / 100% 100% repeat-y,
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 40%),
    var(--paper);
  padding-left: 34px;
}

.herbarium-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.specimen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.specimen-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 14px;
  background: var(--paper-strong);
  border: 1px solid var(--paper-shadow);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--paper-shadow);
  transition: transform 120ms ease;
}

.specimen-card::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 62px;
  height: 18px;
  background: rgba(217, 201, 168, 0.75);
  border-left: 1px dashed rgba(138, 107, 79, 0.4);
  border-right: 1px dashed rgba(138, 107, 79, 0.4);
}

.specimen-card:hover {
  transform: translateY(-2px);
}

.specimen-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.specimen-card.locked {
  filter: saturate(0.5);
}

.specimen-card.locked .specimen-name {
  color: var(--ink-soft);
  font-style: italic;
}

.specimen-art {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
}

.specimen-art.large {
  max-width: 260px;
}

.specimen-name {
  font-family: var(--serif);
  font-size: 1.06rem;
  color: var(--sage-deep);
  font-weight: 700;
}

.specimen-sci {
  font-size: 0.86rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0;
}

.detail-back {
  margin-bottom: 12px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 640px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

.detail-figure {
  text-align: center;
  background: rgba(253, 248, 236, 0.85);
  border: 1px solid var(--paper-shadow);
  border-radius: 12px;
  padding: 12px;
}

.detail-body p {
  margin: 0 0 12px;
}


/* ---------- Fișă botanică extinsă ---------- */
.plant-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 2px 0 18px;
}

.plant-fact {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid rgba(90, 110, 70, 0.24);
  border-radius: 10px;
  background: rgba(126, 165, 92, 0.08);
}

.plant-fact-label {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.plant-fact-value {
  color: var(--sage-dark);
  font-family: var(--serif);
  font-size: 0.94rem;
  line-height: 1.25;
}

.detail-body > p {
  max-width: 72ch;
  line-height: 1.62;
}

@media (max-width: 480px) {
  .plant-facts {
    grid-template-columns: 1fr;
    gap: 7px;
  }
}

.detail-body ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.detail-body a {
  color: var(--sage-dark);
}

.sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.92rem;
}

.sources-list li {
  margin-bottom: 8px;
}

.source-status {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(217, 169, 92, 0.2);
  border: 1px solid rgba(217, 169, 92, 0.5);
  color: #6d523a;
}

.source-status.verified {
  background: rgba(126, 165, 92, 0.2);
  border-color: rgba(126, 165, 92, 0.5);
  color: var(--sage-dark);
}

.notice {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px dashed rgba(138, 107, 79, 0.4);
  font-size: 0.86rem;
  color: var(--ink-soft);
}

/* ---------- Ecran de final / specii ---------- */

.species-strip,
.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 10px 0 4px;
}

.species-tile {
  position: relative;
  background: var(--paper-strong);
  border: 1px solid var(--paper-shadow);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  box-shadow: 0 3px 0 var(--paper-shadow);
}

.species-tile canvas {
  width: 100%;
  max-width: 150px;
  height: auto;
}

.species-tile .specimen-name {
  display: block;
}

.species-count {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.badge-new {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #4a3a1c;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(138, 107, 79, 0.5);
}

.complete-message {
  margin: 0 0 4px;
  color: var(--sage-dark);
  font-weight: 600;
}

/* ---------- Toast, dialog, orientare ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  max-width: min(92vw, 560px);
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(253, 248, 236, 0.97);
  border: 1px solid var(--paper-shadow);
  box-shadow: 0 8px 22px rgba(30, 24, 14, 0.3);
  color: var(--ink);
  font-size: 0.95rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.touch .toast {
  top: calc(64px + env(safe-area-inset-top));
  bottom: auto;
}

/* Ținte de atingere mai mari pe ecrane tactile. */
body.touch .btn {
  min-height: 48px;
}

body.touch .btn-small {
  min-height: 44px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 34, 24, 0.62);
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.orientation-hint {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(253, 248, 236, 0.97);
  border: 1px solid var(--paper-shadow);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(30, 24, 14, 0.3);
  z-index: 45;
  max-width: min(92vw, 440px);
}

.orientation-hint[hidden] {
  display: none;
}

.orientation-hint p {
  margin: 0;
  font-size: 0.9rem;
  text-align: center;
}

/* Pe portret: HUD-ul are două rânduri, deci mesajele coboară sub el. */
@media (orientation: portrait) {
  body.touch .toast {
    top: calc(132px + env(safe-area-inset-top));
  }
}

/* Sugestia de orientare apare doar când telefonul este ținut pe orizontală:
   o așezăm între grupurile de butoane tactile, ca să nu le acopere. */
@media (orientation: landscape) {
  .orientation-hint {
    max-width: min(44vw, 300px);
  }
}

/* ---------- Setări ---------- */

.controls-list {
  margin: 0;
  padding-left: 20px;
}

.controls-list li {
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
}

.settings-row label {
  font-weight: 600;
}

.settings-row select {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid var(--paper-shadow);
  background: var(--paper-strong);
  color: var(--ink);
  font: inherit;
  max-width: 100%;
}

.settings-row select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0;
  cursor: pointer;
  min-height: 44px;
}

.settings-check input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--sage-dark);
  flex: none;
}

.settings-check input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Indicația unică de control (nivelul 1) ---------- */

.tutorial-hint {
  position: absolute;
  top: calc(88px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 430px);
  padding: 8px 12px;
  background: rgba(253, 248, 236, 0.96);
  border: 1px solid var(--paper-shadow);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(30, 24, 14, 0.25);
  z-index: 3;
}

.tutorial-hint[hidden] {
  display: none;
}

.tutorial-hint p {
  margin: 0;
  font-size: 0.9rem;
  white-space: normal;
}

@media (orientation: portrait) {
  .tutorial-hint {
    top: calc(124px + env(safe-area-inset-top));
  }
}

/* Pictograme pe butoane (pachetul „split”). */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  min-width: 42px;
}

.btn-icon-img {
  width: 26px;
  height: 26px;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.touch-icon {
  width: 58%;
  height: 58%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Use the original paper CSS rather than oversized nine-slice exports.
   The old 26px/18px image borders consumed the phone HUD and clipped text. */
.panel { border-image: none; border: 1px solid var(--paper-shadow); }
.btn { border-image: none; border-width: 1px; }
.btn-icon { width: 44px; height: 44px; min-height: 44px; min-width: 44px; padding: 8px; flex: none; }
.hud { align-items: start; }
.hud-actions { align-items: start; }
.hud-title { margin-top: 3px; }
.hud-collectibles { margin-top: 3px; }
.tutorial-hint { width: min(460px, calc(100vw - 32px)); max-width: none; }
.tutorial-hint p { flex: 1; min-width: 0; line-height: 1.5; }
.tutorial-hint .btn { flex: none; white-space: nowrap; }

@media (max-width: 640px) {
  .hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title actions" "plants plants";
    gap: 8px;
  }
  .hud-title { grid-area: title; align-self: center; margin: 0; padding: 7px 9px; }
  .hud-actions { grid-area: actions; margin: 0; gap: 6px; }
  .hud-collectibles { grid-area: plants; margin: 0; flex-wrap: wrap; }
  .hud-chip { padding: 4px 9px; }
  .tutorial-hint { top: calc(106px + env(safe-area-inset-top)); padding: 10px 12px; }
  .tutorial-hint p { font-size: 0.82rem; }
  .tutorial-hint .btn { font-size: 0.78rem; padding: 8px 10px; }
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .panel {
    padding: 20px 16px;
  }

  .herbarium-panel {
    padding-left: 22px;
    background-size: 100% 100%;
  }

  .hud-title {
    font-size: 0.82rem;
    padding: 4px 8px;
  }

  .hud-chip {
    font-size: 0.78rem;
    padding: 3px 8px;
  }

  .btn-small {
    padding: 7px 10px;
  }

  .touch-btn {
    width: 68px;
    height: 68px;
  }

  .touch-jump {
    width: 80px;
    height: 80px;
  }
}

/* Telefoane pe orizontală: meniurile se compactează ca să încapă pe înălțime. */
@media (max-height: 560px) and (orientation: landscape) {
  .screen {
    padding: 12px;
  }

  .panel {
    padding: 16px 18px;
  }

  h1 {
    font-size: 1.7rem;
    margin-bottom: 6px;
  }

  h2 {
    font-size: 1.35rem;
  }

  .section-label {
    margin: 14px 0 6px;
  }

  .menu-art,
  .sprig {
    display: none;
  }

  .menu-actions {
    max-width: 560px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .menu-actions .btn {
    flex: 1 1 160px;
  }

  .levels-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
  }

  .specimen-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .detail-layout {
    grid-template-columns: minmax(160px, 220px) 1fr;
  }
}

/* ---------- Mișcare redusă ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .sprig {
    display: none;
  }
}

/* Volume II: compact campaign navigation, no extra pickup popups. */
.chapter-heading { grid-column: 1 / -1; text-align: left; padding: 20px 4px 6px; border-bottom: 1px solid #bcbea8; }
.chapter-heading h3 { margin: 0 0 5px; font-size: 1.4rem; color: #40583c; }
.chapter-heading p { margin: 0 0 8px; color: #727861; font-size: .9rem; }
.level-result { display: block; margin-top: 8px; color: #8b703e; font-size: .82rem; }
.run-stats { color: #736340; padding: 12px 18px; background: #ede6ce; border-radius: 13px; font-size: .95rem; line-height: 1.6; }
.expedition-strip { display: flex; align-items: center; gap: 10px; grid-column: 1 / -1; grid-row: 3; padding: 2px 6px 0; color: #566547; font-size: 12px; min-width: 0; }
#expedition-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 57%; }
#expedition-progress { flex: 1; min-width: 20px; max-width: 160px; height: 6px; accent-color: #77926a; border: 0; border-radius: 4px; }
#expedition-leaves { white-space: nowrap; color: #926d2c; margin-left: auto; }
@media (max-width: 600px) {
  .menu-panel { padding-top: 20px; padding-bottom: 22px; }
  .menu-subtitle { font-size: .96rem; }
  .progress-badge { font-size: .79rem; }
  .chapter-heading h3 { font-size: 1.18rem; }
  .expedition-strip { gap: 6px; font-size: 10px; }
  .run-stats { font-size: .8rem; padding: 8px 10px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .expedition-strip { grid-row: 2; padding: 0 4px; font-size: 10px; }
  .hud { row-gap: 3px; }
}

.hud { display:grid; grid-template-columns:minmax(180px,.9fr) minmax(220px,1.2fr) auto; grid-template-areas:"title plants actions" "trail trail trail"; gap:6px 10px; }
.hud-title { grid-area:title; }
.hud-collectibles { grid-area:plants; }
.hud-actions { grid-area:actions; }
.expedition-strip { grid-area:trail; width:min(520px,100%); background:rgba(250,245,230,.88); border-radius:9px; padding:4px 9px; }
@media (max-width:640px) {
 .hud {grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"title actions" "plants plants" "trail trail";gap:5px;}
 .expedition-strip {width:100%;padding:4px 7px;}
 .tutorial-hint {top:calc(144px + env(safe-area-inset-top));}
}
@media (max-height:500px) and (orientation:landscape) {
 .hud {grid-template-columns:minmax(160px,1fr) minmax(170px,1.2fr) auto;grid-template-areas:"title plants actions" "trail trail trail";gap:3px 6px;padding-top:4px;}
 .hud-title {font-size:12px;padding:4px 8px;}
 .hud-chip {font-size:11px;padding:3px 7px;}
 .expedition-strip {padding:3px 7px;}
 .tutorial-hint {top:88px;}
}

#expedition-progress {appearance:none;overflow:hidden;background:#dedfce;border-radius:6px;}
#expedition-progress::-webkit-progress-bar {background:#dedfce;border-radius:6px;}
#expedition-progress::-webkit-progress-value {background:#789168;border-radius:6px;}
#expedition-progress::-moz-progress-bar {background:#789168;border-radius:6px;}
