body {
  background-color: #fefce8;
  background-image: radial-gradient(#fde68a 0.75px, transparent 0.75px);
  background-size: 20px 20px;
}

/* 3D Card Flip */
.perspective-1000 {
  perspective: 1000px;
}
.transform-style-3d {
  transform-style: preserve-3d;
}
.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.rotate-y-180 {
  transform: rotateY(180deg);
}

/* Floating Toast Animation */
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(12px) scale(0.96); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(-3px) scale(1); }
  100% { opacity: 0; transform: translateY(-16px) scale(0.96); }
}
.animate-float-toast {
  animation: floatUp 3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Immersive 3D farm: the scene fills the window below the tab bar, the toolbar floats on top */
body.farm-immersive {
  overflow: hidden;
}
body.farm-immersive #farm3dWrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--farm-bottom, 0px);
  top: var(--farm-top, 120px);
  z-index: 30;
  max-width: none;
  margin: 0;
}
body.farm-immersive #farm3dCanvasWrap {
  height: 100% !important;
  border-radius: 0;
}
body.farm-immersive #farmToolbar {
  position: fixed;
  top: calc(var(--farm-top, 120px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  width: min(calc(100% - 24px), 960px);
  padding: 8px 12px;
  background: rgba(255, 251, 235, 0.62);
  border-color: rgba(253, 230, 138, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
body.farm-immersive #moveModeHelperNotice {
  position: fixed;
  left: 50%;
  bottom: calc(var(--farm-bottom, 0px) + 16px);
  transform: translateX(-50%);
  z-index: 35;
  width: min(calc(100% - 24px), 640px);
}
body.farm-immersive #questsCard {
  display: none;
}
body.farm-immersive.quests-open #questsCard {
  display: block;
  position: fixed;
  right: 12px;
  bottom: calc(var(--farm-bottom, 0px) + 12px);
  z-index: 36;
  width: min(380px, calc(100% - 24px));
  max-height: 55vh;
  overflow-y: auto;
}
body.farm-immersive #questsList {
  grid-template-columns: 1fr;
}

/* Phones: keep the floating toolbar compact so the farm stays visible */
@media (max-width: 640px) {
  body.farm-immersive #farmToolbar {
    padding: 6px 8px;
    gap: 6px;
    border-radius: 16px;
  }
  body.farm-immersive #farmToolbar > div:first-child {
    gap: 6px;
  }
  body.farm-immersive #farmToolbar > div:last-child {
    display: none;
  }
}

/* ==================================================
   CARTOON MOBILE-GAME UI LAYER
   Fredoka font, chunky 3D buttons with a darker bottom edge that squish on press and spring back,
   resource pills, springy modals and a round-icon tab bar at the bottom. Warm palette kept.
   ================================================== */
:root {
  --spring: cubic-bezier(0.34, 1.75, 0.5, 1);
  --edge-default: #d9a75a;
  --ink: #451a03;
  --tabbar-h: 84px;
}

body {
  font-family: 'Fredoka', ui-rounded, system-ui, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
}
.font-black { font-weight: 700; }
.font-extrabold { font-weight: 700; }

/* ---------- Chunky 3D buttons ----------
   Applies to every coloured button (also ones rendered from JS), except tabs, list rows,
   segmented toggles and anything inside .no-3d. */
button:is([class*="bg-"], [class*="hover:bg-stone-100"]):not(.tab-btn):not(.text-left):not(.absolute):not([id^="langBtn"]):not(.no-3d):not(.no-3d *),
.icon-btn-3d {
  --edge: var(--edge-default);
  position: relative;
  border-radius: 999px;
  border: 2px solid rgba(69, 26, 3, 0.12);
  font-weight: 700;
  box-shadow: 0 4px 0 0 var(--edge), 0 6px 10px -4px rgba(69, 26, 3, 0.35);
  transform: translateY(0);
  transition: transform 0.38s var(--spring), box-shadow 0.38s var(--spring), filter 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
button:is([class*="bg-"], [class*="hover:bg-stone-100"]):not(.tab-btn):not(.text-left):not(.absolute):not([id^="langBtn"]):not(.no-3d):not(.no-3d *):hover,
.icon-btn-3d:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}
button:is([class*="bg-"], [class*="hover:bg-stone-100"]):not(.tab-btn):not(.text-left):not(.absolute):not([id^="langBtn"]):not(.no-3d):not(.no-3d *):active,
.icon-btn-3d:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: 0 0 0 0 var(--edge), 0 2px 4px -2px rgba(69, 26, 3, 0.3);
  transition-duration: 0.06s;
}
button.flex-col:is([class*="bg-"]):not(.no-3d *) { border-radius: 22px; }
button[disabled], button.cursor-not-allowed, button.cursor-default, button.opacity-50 { filter: saturate(0.7); }
button.cursor-default:active, button.cursor-not-allowed:active, button[disabled]:active { transform: none !important; }

/* Edge colours per button colour (darker shade of the face) */
button:is([class~="bg-amber-800"], [class~="bg-amber-900"], [class~="bg-amber-600"]) { --edge: #3b1705; }
button:is([class~="bg-amber-400"], [class~="bg-amber-300"]) { --edge: #b45309; }
button:is([class~="bg-amber-50"], [class~="bg-amber-100"], [class~="bg-white"]) { --edge: #e0ae5c; }
button:is([class~="bg-emerald-600"], [class~="bg-emerald-700"], [class~="bg-emerald-800"]) { --edge: #064e3b; }
button:is([class~="bg-emerald-50"], [class~="bg-emerald-100"]) { --edge: #5fbf8f; }
button:is([class~="bg-sky-500"], [class~="bg-sky-600"]) { --edge: #075985; }
button:is([class~="bg-sky-50"], [class~="bg-sky-100"]) { --edge: #6fb6dc; }
button:is([class~="bg-rose-600"], [class~="bg-rose-700"]) { --edge: #881337; }
button:is([class~="bg-rose-50"], [class~="bg-rose-100"]) { --edge: #f19aa8; }
button:is([class~="bg-orange-50"], [class~="bg-orange-100"]) { --edge: #f2a66a; }
button:is([class~="bg-violet-600"], [class~="bg-violet-700"]) { --edge: #4c1d95; }
button:is([class~="bg-stone-100"], [class~="bg-stone-200"]) { --edge: #b8b0a8; }
/* "Cancel" buttons had no face colour – give them a soft cream one */
button[class*="hover:bg-stone-100"]:not([class~="bg-stone-100"]):not(.no-3d *) { background-color: #f5efe4; --edge: #cdbfa8; }

/* Round × close buttons in modals */
button[onclick^="closeModal"].text-xl:not(.modal-close) {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fde7d9;
  color: #9f1239;
  font-weight: 700;
  border: 2px solid rgba(159, 18, 57, 0.15);
  box-shadow: 0 3px 0 0 #f0a7a7;
  transition: transform 0.38s var(--spring), box-shadow 0.38s var(--spring);
}
button[onclick^="closeModal"].text-xl:not(.modal-close):active { transform: translateY(3px) scale(0.94); box-shadow: 0 0 0 0 #f0a7a7; transition-duration: 0.06s; }

/* Segmented toggles (2D/3D, study mode, import source): pill track with a raised active chip */
.seg-group {
  border-radius: 999px !important;
  padding: 3px;
  gap: 3px;
  background: #fbe3b4 !important;
  border: 2px solid rgba(69, 26, 3, 0.12) !important;
  box-shadow: inset 0 2px 0 rgba(69, 26, 3, 0.1) !important;
}
.seg-group > button {
  border-radius: 999px !important;
  transition: transform 0.35s var(--spring), background-color 0.15s ease;
}
.seg-group > button:active { transform: scale(0.94); }
.seg-group > button:is([class~="bg-amber-800"], [class~="bg-white"], [class~="bg-violet-600"], [class~="bg-amber-600"], [class~="bg-emerald-700"]) {
  box-shadow: 0 3px 0 0 rgba(59, 23, 5, 0.45);
}

/* ---------- Top bar ---------- */
.cartoon-header {
  background: linear-gradient(180deg, #ffe7a8 0%, #ffd77a 100%);
  border-bottom: 3px solid #e0a94d;
  box-shadow: 0 4px 0 0 rgba(180, 83, 9, 0.18);
}
.brand-badge {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: 16px;
  background: #fff8e6;
  border: 3px solid #e0a94d;
  box-shadow: 0 4px 0 0 #c98a2e;
}
.res-pill {
  --pill-bg: #fff;
  --pill-edge: #e0ae5c;
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 14px 0 34px;
  margin-left: 14px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 3px solid var(--pill-edge);
  box-shadow: inset 0 -4px 0 rgba(69, 26, 3, 0.08), 0 3px 0 0 var(--pill-edge);
  color: var(--ink);
  min-width: 0;
}
.res-icon {
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 3px 0 rgba(69, 26, 3, 0.25));
  transition: transform 0.4s var(--spring);
}
.res-pill:hover .res-icon { transform: translateY(-50%) scale(1.12) rotate(-6deg); }
.res-value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.res-water { --pill-bg: #e6f6ff; --pill-edge: #63b4e6; color: #0c4a6e; }
.res-coins { --pill-bg: #fff6d6; --pill-edge: #e9b23f; color: #713f12; }
.res-xp { --pill-bg: #eafbe7; --pill-edge: #6cc05a; color: #14532d; padding-left: 36px; }
.res-icon-star {
  filter: none;
  width: 42px;
  height: 42px;
  left: -14px;
  font-size: 16px;
  font-weight: 700;
  color: #713f12;
  background: radial-gradient(circle at 35% 30%, #fff3a6, #f7c531 60%, #e2a10d);
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 92%, 50% 71%, 21% 92%, 32% 57%, 2% 35%, 39% 34%);
}
.res-xp-body { display: flex; flex-direction: column; gap: 3px; min-width: 64px; }
.res-xp-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; line-height: 1; }
.res-xp-track {
  height: 9px;
  border-radius: 999px;
  background: #cfeec7;
  box-shadow: inset 0 2px 0 rgba(20, 83, 45, 0.18);
  overflow: hidden;
}
.res-xp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #8ee26f, #3fa63a);
  transition: width 0.5s var(--spring);
}
.lang-group {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #fff3d1;
  border: 2px solid #e0a94d;
}
.lang-group button { border-radius: 999px !important; }
.icon-btn-3d {
  --edge: #c98a2e;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: #fff8e6;
  border: 2px solid #e0a94d;
}

@media (max-width: 640px) {
  .res-pill { height: 32px; padding: 0 10px 0 26px; margin-left: 12px; border-width: 2px; }
  .res-icon { width: 36px; height: 36px; font-size: 24px; left: -13px; }
  .res-value { font-size: 15px; }
  .res-xp { padding-left: 28px; }
  .res-icon-star { width: 34px; height: 34px; left: -12px; font-size: 13px; }
  .res-xp-label { display: none; }
  .res-xp-body { min-width: 38px; }
  .brand-badge { width: 38px; height: 38px; font-size: 22px; border-radius: 13px; }
  .lang-group { display: none; }
  .icon-btn-3d { width: 34px; height: 34px; font-size: 16px; }
}

/* ---------- Bottom tab bar ---------- */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #ffe2a1, #f9cd6f);
  border-top: 3px solid #e0a94d;
  box-shadow: 0 -4px 0 0 rgba(180, 83, 9, 0.12), 0 -10px 24px -12px rgba(69, 26, 3, 0.3);
}
.tab-bar-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 6px;
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0;
  color: #7c3a0e;
  -webkit-tap-highlight-color: transparent;
}
.tab-icon {
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: 999px;
  background: #fff3d1;
  border: 3px solid #e0a94d;
  box-shadow: 0 4px 0 0 #c98a2e;
  transition: transform 0.4s var(--spring), box-shadow 0.4s var(--spring), background-color 0.2s ease;
}
.tab-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}
.tab-btn:hover .tab-icon { transform: translateY(-2px); }
.tab-btn:active .tab-icon {
  transform: translateY(4px) scale(0.92);
  box-shadow: 0 0 0 0 #c98a2e;
  transition-duration: 0.06s;
}
.tab-btn.is-active { color: #451a03; }
.tab-btn.is-active .tab-icon {
  background: radial-gradient(circle at 35% 30%, #ffb661, #f08a24 70%);
  border-color: #b4560f;
  box-shadow: 0 5px 0 0 #8a3c08, 0 8px 14px -6px rgba(138, 60, 8, 0.6);
  transform: translateY(-8px) scale(1.08);
}
.tab-btn.is-active .tab-label {
  background: #7c2d12;
  color: #fff7e6;
  padding: 1px 9px;
  border-radius: 999px;
  margin-top: -4px;
}
@media (max-width: 380px) {
  .tab-icon { width: 46px; height: 46px; font-size: 23px; }
  .tab-label { font-size: 11px; }
}

/* ---------- Springy modals ---------- */
@keyframes modalBackdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPopIn {
  0% { opacity: 0; transform: scale(0.6) translateY(24px); }
  55% { opacity: 1; transform: scale(1.05) translateY(-4px); }
  75% { transform: scale(0.98) translateY(1px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
div[id^="modal"].fixed:not(.hidden) {
  animation: modalBackdropIn 0.2s ease-out both;
}
div[id^="modal"].fixed:not(.hidden) > div {
  animation: modalPopIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  border-width: 3px;
  box-shadow: 0 8px 0 0 rgba(180, 83, 9, 0.35), 0 24px 48px -12px rgba(69, 26, 3, 0.45);
}
div[id^="modal"].fixed { z-index: 60; }

@media (prefers-reduced-motion: reduce) {
  div[id^="modal"].fixed:not(.hidden),
  div[id^="modal"].fixed:not(.hidden) > div { animation: none; }
  button, .tab-icon, .res-icon { transition: none !important; }
}

/* Very narrow phones: drop the logo badge and shrink pills so nothing overlaps */
@media (max-width: 400px) {
  #appHeader .brand-badge { display: none; }
  .res-pill { padding: 0 8px 0 22px; margin-left: 10px; }
  .res-icon { width: 30px; height: 30px; font-size: 20px; left: -11px; }
  .res-xp { padding-left: 24px; }
  .res-icon-star { width: 30px; height: 30px; left: -10px; font-size: 12px; }
  .res-xp-body { min-width: 26px; }
  .res-value { font-size: 14px; }
}

/* ==================================================
   GAME ICONS – icon(name, size) from js/icons.js
   ================================================== */
.gi {
  --gi: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--gi);
  height: var(--gi);
  flex-shrink: 0;
  line-height: 1;
  font-size: calc(var(--gi) * 0.8);
  vertical-align: middle;
}
.gi img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
}
.gi-inline { vertical-align: -0.28em; margin: 0 0.05em; }
.gi-3d img { filter: drop-shadow(0 2px 0 rgba(69, 26, 3, 0.22)); }

/* Control icons: white Kenney glyph on a coloured round chip with a darker bottom edge */
.gi-ui:not(.gi-emoji) {
  --chip: #e08a2a;
  --chip-edge: #a85a14;
  padding: calc(var(--gi) * 0.2);
  border-radius: 999px;
  background: var(--chip);
  box-shadow: inset 0 calc(var(--gi) * -0.08) 0 var(--chip-edge), 0 2px 0 rgba(69, 26, 3, 0.25);
}
.gi-ui:not(.gi-emoji) img { filter: brightness(0) invert(1); }
.gi-ui.gi-tint-rose { --chip: #ef5b6b; --chip-edge: #b42338; }
.gi-ui.gi-tint-green { --chip: #4caf50; --chip-edge: #2e7d32; }
.gi-ui.gi-tint-sky { --chip: #38a3e0; --chip-edge: #1b6fa8; }
.gi-ui.gi-tint-stone { --chip: #9b8f84; --chip-edge: #6e645b; }
.gi-ui.gi-tint-amber { --chip: #f0a030; --chip-edge: #b8680f; }

/* XP star in the HUD: 3D star with the level number on top */
.res-icon-star {
  background: none !important;
  clip-path: none !important;
}
.res-level {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 3px;
  font-size: 15px;
  font-weight: 700;
  color: #713f12;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Modal close button = the rose chip itself, with a press */
button.modal-close {
  background: none;
  border: 0;
  padding: 0;
  display: inline-flex;
  transition: transform 0.38s var(--spring);
}
button.modal-close:active { transform: translateY(2px) scale(0.9); transition-duration: 0.06s; }
.card-row-btn { opacity: 0.55; transition: opacity 0.15s, transform 0.3s var(--spring); }
.card-row-btn:hover { opacity: 1; }
.card-row-btn:active { transform: scale(0.88); }
.tab-icon .gi, .res-icon .gi { pointer-events: none; }

/* ==================================================
   REWARD FX, PARTICLES, LEVEL-UP (js/fx.js)
   ================================================== */
#fxLayer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.fx-fly, .fx-p { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
.fx-fly { width: 34px; height: 34px; filter: drop-shadow(0 4px 4px rgba(69, 26, 3, 0.35)); }
.fx-drop {
  width: 9px; height: 12px;
  background: radial-gradient(circle at 35% 35%, #d6f1ff, #3fa2e0 70%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
}
.fx-drop-small { width: 6px; height: 7px; }
.fx-leaf { width: 13px; height: 7px; border-radius: 0 100% 0 100%; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); }
.fx-dust {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 214, 178, 0.9), rgba(232, 214, 178, 0) 70%) !important;
}
.fx-spark {
  width: 16px; height: 16px;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  filter: drop-shadow(0 0 4px rgba(255, 236, 140, 0.9));
}

/* Counter pill bump when a reward lands */
@keyframes hudBump {
  0% { transform: scale(1); }
  30% { transform: scale(1.18); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}
@keyframes hudIconSpin {
  0% { transform: translateY(-50%) scale(1) rotate(0deg); }
  35% { transform: translateY(-62%) scale(1.25) rotate(-12deg); }
  100% { transform: translateY(-50%) scale(1) rotate(0deg); }
}
.res-pill.hud-bump { animation: hudBump 0.42s var(--spring); }
.res-pill.hud-bump .res-icon { animation: hudIconSpin 0.42s var(--spring); }

/* Level-up window */
.levelup-card { position: relative; overflow: hidden; }
.levelup-rays {
  position: absolute;
  left: 50%; top: 90px;
  width: 520px; height: 520px;
  margin: -260px 0 0 -260px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 214, 102, 0.35) 0deg 10deg, rgba(255, 214, 102, 0) 10deg 20deg);
  border-radius: 50%;
  mask-image: radial-gradient(circle, #000 25%, transparent 65%);
  -webkit-mask-image: radial-gradient(circle, #000 25%, transparent 65%);
  animation: raysSpin 14s linear infinite;
  pointer-events: none;
}
@keyframes raysSpin { to { transform: rotate(360deg); } }
.levelup-star { display: inline-flex; justify-content: center; animation: starPop 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes starPop {
  0% { transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.12) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
.levelup-number {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding-top: 8px;
  font-size: 38px; font-weight: 700; color: #713f12;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
}
.levelup-card > *:not(.levelup-rays) { position: relative; }
.levelup-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 18px;
  background: #fff7e0;
  border: 2px solid #f3d28c;
  font-weight: 600; font-size: 14px; color: #451a03;
  animation: itemIn 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.levelup-note { font-size: 12px; color: #92400e; text-align: center; padding-top: 4px; animation: itemIn 0.5s ease both; }
@keyframes itemIn {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
#modalLevelUp { z-index: 65; }

/* Volume panel under the speaker button */
.sound-panel {
  position: absolute;
  right: 0; top: calc(100% + 10px);
  width: 200px;
  padding: 12px;
  border-radius: 20px;
  background: #fffaf0;
  border: 3px solid #e0a94d;
  box-shadow: 0 5px 0 0 #c98a2e, 0 14px 24px -10px rgba(69, 26, 3, 0.4);
  z-index: 50;
  animation: modalPopIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  transform-origin: top right;
}
.sound-slider { width: 100%; accent-color: #e08a2a; height: 22px; }

@media (prefers-reduced-motion: reduce) {
  .levelup-rays, .levelup-star, .levelup-item, .res-pill.hud-bump, .res-pill.hud-bump .res-icon { animation: none; }
}

/* Toasts sit just under the top bar so flying rewards and counter bumps stay visible */
/* Toast deck (js/app.js Toasts): phones = top centre under the bar, computers = top right */
#toastContainer {
  position: fixed; top: calc(var(--farm-top, 64px) + 8px); left: 50%; transform: translateX(-50%);
  width: min(92vw, 22rem); z-index: 55; pointer-events: none;
}
@media (min-width: 768px) {
  #toastContainer { left: auto; right: 16px; transform: none; }
}
.toast-card {
  --depth: 0;
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.9rem;
  border-radius: 1rem; background: rgba(69, 26, 3, 0.95); color: #fef3c7; border: 1px solid rgba(245, 158, 11, 0.4);
  box-shadow: 0 10px 22px -10px rgba(0, 0, 0, 0.5); font-size: 0.75rem; font-weight: 700;
  /* older cards peek out below the newest one as a narrower, dimmer edge */
  transform: translateY(calc(var(--depth) * 9px)) scale(calc(1 - var(--depth) * 0.06));
  transform-origin: top center;
  opacity: calc(1 - var(--depth) * 0.2);
  z-index: calc(10 - var(--depth));
  transition: transform 0.22s ease, opacity 0.22s ease;
  animation: toastIn 0.28s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.toast-card.is-top { pointer-events: auto; cursor: pointer; }
.toast-card:not(.is-top) { background: #7c4a1e; border-color: rgba(245, 158, 11, 0.6); }
.toast-card:not(.is-top) .toast-text, .toast-card:not(.is-top) .toast-count, .toast-card:not(.is-top) > span:first-child { visibility: hidden; }
.toast-card.is-leaving { opacity: 0; transform: translateY(-10px) scale(0.96); }
.toast-card.is-bumped { animation: toastBump 0.3s ease; }
.toast-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-count { flex-shrink: 0; padding: 0.05rem 0.45rem; border-radius: 999px; background: #f59e0b; color: #451a03; font-size: 0.72rem; font-weight: 900; }
.toast-count:empty { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(0.95); } }
@keyframes toastBump { 40% { transform: scale(1.05); } }
.levelup-star { margin: -24px 0 -22px; }

/* ==================================================
   HUD PILLS v2 – icon sits inside the pill in a round badge, everything centred
   ================================================== */
.res-pill {
  gap: 7px;
  height: 42px;
  margin-left: 0;
  padding: 0 14px 0 4px;
}
.res-xp { padding-left: 4px; padding-right: 12px; }
.res-icon,
.res-icon-star {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85) !important;
  box-shadow: inset 0 -2px 0 rgba(69, 26, 3, 0.1);
  filter: none;
  clip-path: none !important;
}
.res-water .res-icon { background: #ffffff !important; }
.res-icon .gi { filter: drop-shadow(0 1px 0 rgba(69, 26, 3, 0.2)); }
.res-pill:hover .res-icon { transform: scale(1.1) rotate(-6deg); }
.res-level {
  padding-top: 2px;
  font-size: 12px;
  line-height: 1;
}
.res-xp-body { justify-content: center; }

@keyframes hudIconSpin {
  0% { transform: scale(1) rotate(0deg); }
  35% { transform: scale(1.3) rotate(-12deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@media (max-width: 640px) {
  .res-pill { height: 34px; gap: 5px; padding: 0 10px 0 3px; margin-left: 0; }
  .res-xp { padding-left: 3px; padding-right: 8px; }
  .res-icon, .res-icon-star { width: 28px; height: 28px; left: auto; }
  .res-icon .gi { width: 24px !important; height: 24px !important; }
  .res-level { font-size: 11px; }
}
@media (max-width: 400px) {
  .res-pill { padding: 0 8px 0 3px; margin-left: 0; gap: 4px; }
  .res-icon, .res-icon-star { width: 24px; height: 24px; left: auto; }
  .res-icon .gi { width: 21px !important; height: 21px !important; }
  .res-level { font-size: 10px; }
}

/* ==================================================
   FARM TOOLS – ring menu + drag cursor (js/tools.js)
   ================================================== */
.tool-menu {
  position: fixed;
  width: 0;
  height: 0;
  z-index: 75;
}
.tool-chip {
  position: absolute;
  left: -32px;
  top: -32px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fffaf0;
  border: 3px solid #e0a94d;
  box-shadow: 0 5px 0 0 #c98a2e, 0 10px 18px -8px rgba(69, 26, 3, 0.5);
  transform: translate(var(--tx), var(--ty));
  animation: toolChipIn 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  transition: box-shadow 0.2s ease;
}
.tool-chip:active { cursor: grabbing; }
.tool-chip.is-selected { background: #fff1c9; border-color: #f08a24; box-shadow: 0 5px 0 0 #b4560f, 0 0 0 4px rgba(240, 138, 36, 0.25), 0 10px 18px -8px rgba(69, 26, 3, 0.5); }
.tool-chip.is-locked { background: #efe8dc; border-color: #c8b99a; box-shadow: 0 5px 0 0 #a8997e; cursor: not-allowed; }
.tool-chip.is-locked .gi { filter: grayscale(0.85) opacity(0.6); }
.tool-badge {
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #7c2d12;
  color: #fff7e6;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.tool-chip.is-locked .tool-badge { background: #8a7b66; }
.tool-hint {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, var(--ty));
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(69, 26, 3, 0.85);
  color: #fff3d6;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  animation: toolChipIn 0.4s 0.15s ease both;
}
.tool-menu.is-dragging .tool-chip,
.tool-menu.is-dragging .tool-hint { opacity: 0; pointer-events: none; transition: opacity 0.15s; }
@keyframes toolChipIn {
  from { opacity: 0; transform: translate(0, 0) scale(0.3); }
  to { opacity: 1; transform: translate(var(--tx, 0), var(--ty, 0)) scale(1); }
}
.tool-hint { --tx: -50%; }
@keyframes toolHintIn { from { opacity: 0; } to { opacity: 1; } }
.tool-hint { animation-name: toolHintIn; }

.tool-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 85;
  pointer-events: none;
  filter: drop-shadow(0 6px 4px rgba(69, 26, 3, 0.35));
}
.tool-cursor .gi { animation: toolBob 0.5s ease-in-out infinite alternate; }
.tool-cursor-harvest .gi { animation: toolSwing 0.32s ease-in-out infinite alternate; transform-origin: 30% 80%; }
.tool-cursor-water .gi { animation: toolPour 0.6s ease-in-out infinite alternate; transform-origin: 40% 70%; }
.tool-cursor-collect .gi { animation: toolSwing 0.4s ease-in-out infinite alternate; transform-origin: 50% 90%; } /* basket of eggs / milk (js/animals.js) */
@keyframes toolBob { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-5px) rotate(6deg); } }
@keyframes toolSwing { from { transform: rotate(-35deg); } to { transform: rotate(25deg); } }
@keyframes toolPour { from { transform: rotate(10deg); } to { transform: rotate(38deg); } }
body.tool-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
body.tool-dragging #farm3dCanvasWrap canvas { touch-action: none; }

/* Silo capacity pill turns red when full */
#barnStorageCapacity.silo-full { background: #ffe1e1; border-color: #f19aa8; color: #9f1239; }

/* New study card pop-in (outer wrapper, so it does not fight the flip transform) */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.card-enter { animation: cardEnter 0.25s ease-out; }

/* ==================================================
   STORAGE WINDOW – silo / barn (js/storage.js)
   ================================================== */
.storage-gauge {
  position: relative;
  height: 26px;
  border-radius: 999px;
  background: #f3e6c8;
  border: 3px solid #e0a94d;
  box-shadow: inset 0 3px 0 rgba(69, 26, 3, 0.12);
  overflow: hidden;
}
.storage-gauge-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, #8ee26f, #3fa63a);
  transition: width 0.5s var(--spring);
}
.storage-gauge-fill.is-full { background: linear-gradient(180deg, #ff9a8a, #e0412f); }
.storage-gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #451a03;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
.storage-list { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; padding: 2px; }
.storage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 12px 6px 6px;
  border-radius: 18px;
  background: #fff7e0;
  border: 2px solid #f3d28c;
  text-align: left;
  transition: transform 0.3s var(--spring), border-color 0.15s, background-color 0.15s;
}
button.storage-row:active { transform: scale(0.97); }
.storage-row.is-selected { background: #ffe9b8; border-color: #f08a24; box-shadow: 0 0 0 3px rgba(240, 138, 36, 0.22); }
.storage-row.is-static { background: #faf5ea; }
.storage-row.is-ok { border-color: #8fd18a; background: #f0fbec; }
.storage-row.is-missing { border-color: #f5b5b5; background: #fff3f3; }
.storage-row-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; color: #451a03; }
.storage-row-price { font-size: 12px; font-weight: 600; color: #92400e; display: inline-flex; align-items: center; }
.storage-row-count {
  min-width: 34px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #7c2d12;
  color: #fff7e6;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}
.storage-empty { text-align: center; font-size: 13px; color: #92400e; padding: 14px 0; }
.storage-subhead { margin-top: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #b45309; }
.qty-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff3d1;
  border: 2px solid #e0a94d;
  box-shadow: 0 3px 0 0 #c98a2e;
  font-weight: 700;
  font-size: 18px;
  color: #7c2d12;
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--spring);
}
.qty-btn:active { transform: translateY(3px); box-shadow: 0 0 0 0 #c98a2e; transition-duration: 0.06s; }
.qty-all { font-size: 13px; }
.qty-value { min-width: 40px; text-align: center; font-size: 20px; font-weight: 700; color: #451a03; }
.storage-label { cursor: default; }

/* Found building part flying to the barn */
.fx-item { width: 46px; height: 46px; z-index: 2; }
.fx-item-glow {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 140, 0.85), rgba(255, 236, 140, 0) 70%);
  animation: itemGlow 0.6s ease-in-out infinite alternate;
}
@keyframes itemGlow { from { transform: scale(0.85); opacity: 0.7; } to { transform: scale(1.1); opacity: 1; } }

/* ==================================================
   SILO FULL – alert, HUD fill ring (the 3D field shake is in farm3d.js)
   ================================================== */

.silo-alert {
  position: fixed;
  left: 50%;
  top: calc(var(--farm-top, 64px) + 10px);
  z-index: 58;
  width: min(360px, calc(100% - 24px));
  padding: 12px 14px;
  border-radius: 22px;
  background: #fff7f2;
  border: 3px solid #f19aa8;
  box-shadow: 0 5px 0 0 #d9707f, 0 16px 28px -12px rgba(69, 26, 3, 0.45);
  transform: translate(-50%, -20px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s var(--spring), opacity 0.2s ease;
}
.silo-alert.is-open { transform: translate(-50%, 0) scale(1); opacity: 1; pointer-events: auto; }
.silo-alert-close { background: none; border: 0; padding: 0; flex-shrink: 0; }
.silo-alert-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  transition: transform 0.35s var(--spring), box-shadow 0.35s var(--spring);
}
.silo-alert-btn:active { transform: translateY(3px); box-shadow: none; transition-duration: 0.06s; }
.silo-alert-btn.is-sell { background: #047857; color: #fff; box-shadow: 0 4px 0 0 #064e3b; }
.silo-alert-btn.is-upgrade { background: #fbbf24; color: #451a03; box-shadow: 0 4px 0 0 #b45309; }

/* HUD: small silo fill ring – tap opens the silo */
.hud-silo {
  --fill: 0%;
  --ring: #6cc05a;
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: conic-gradient(var(--ring) var(--fill), #f0dcae 0);
  box-shadow: 0 3px 0 0 #c98a2e;
  transition: transform 0.35s var(--spring);
}
.hud-silo::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: #fffaf0;
}
.hud-silo > .gi { position: relative; }
.hud-silo.is-high { --ring: #e0412f; box-shadow: 0 3px 0 0 #b42338; }
.hud-silo.is-high::before { background: #ffecec; }
.hud-silo:active { transform: translateY(2px) scale(0.94); transition-duration: 0.06s; }
@media (max-width: 640px) {
  .hud-silo { width: 32px; height: 32px; }
  .hud-silo > .gi { width: 20px !important; height: 20px !important; }
  .hud-silo::before { inset: 3px; }
}

/* ==================================================
   PRODUCTION BUILDINGS (js/buildings.js)
   ================================================== */
@keyframes productBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-9px) scale(1.08, 0.95); }
  55% { transform: translateY(0) scale(0.95, 1.05); }
  70% { transform: translateY(-3px); }
}
.product-bounce { display: inline-flex; animation: productBounce 1.1s ease-in-out infinite; }
.product-label { padding: 3px !important; box-shadow: 0 4px 0 0 #e0a94d, 0 8px 14px -6px rgba(69, 26, 3, 0.45) !important; border-width: 2px !important; }
.build-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 20px;
  background: #ecfbe7;
  border: 3px solid #6cc05a;
  box-shadow: 0 4px 0 0 #3f8a3a;
}
.build-notice.hidden { display: none; }
body.farm-immersive #buildModeNotice {
  position: fixed;
  left: 50%;
  bottom: calc(var(--farm-bottom, 0px) + 16px);
  transform: translateX(-50%);
  z-index: 35;
  width: min(calc(100% - 24px), 560px);
}
.prod-recipe { padding: 10px; border-radius: 18px; background: #fff7e0; border: 2px solid #f3d28c; }
.prod-input { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px 1px 2px; border-radius: 999px; font-size: 12px; }
.prod-input.is-ok { background: #e8f8e2; color: #14532d; }
.prod-input.is-missing { background: #ffe8e8; color: #9f1239; }
.prod-slot { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 6px 10px 6px 6px; border-radius: 16px; border: 2px dashed #e7cf9b; background: #fffaf0; }
.prod-slot.is-busy { border-style: solid; border-color: #f3d28c; background: #fff7e0; }
.prod-slot.is-ready { border-style: solid; border-color: #8fd18a; background: #f0fbec; }
.prod-slot-empty { width: 100%; text-align: center; font-size: 12px; color: #b08a4a; font-weight: 600; }
.prod-bar { height: 7px; border-radius: 999px; background: #f0dcae; overflow: hidden; margin: 3px 0 2px; }
.prod-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(180deg, #ffd166, #f08a24); transition: width 0.9s linear; }

/* Production window v2: need/have rows, red when missing, buy-slot tile */
.prod-input {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 3px 10px 3px 4px;
  border-radius: 14px;
  border: 2px solid transparent;
  font-size: 13px;
}
.prod-input-name { flex: 1; font-weight: 600; }
.prod-input-count { font-weight: 700; font-size: 12px; white-space: nowrap; }
.prod-input.is-ok { background: #ecf9e6; border-color: #b9e3ae; color: #14532d; }
.prod-input.is-missing { background: #ffe4e4; border-color: #f19aa8; color: #b91c1c; }
.prod-input.is-missing .prod-input-count { color: #dc2626; }
.prod-time { font-size: 12px; font-weight: 700; color: #92400e; background: #fde9bf; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.prod-slot-buy {
  justify-content: flex-start;
  border: 2px dashed #e0a94d;
  background: #fff3d1;
  cursor: pointer;
  transition: transform 0.3s var(--spring), background-color 0.15s;
}
.prod-slot-buy:hover { background: #ffe9b8; }
.prod-slot-buy:active { transform: scale(0.96); }
.prod-slot-buy.is-poor { opacity: 0.7; }
#modalProduction > div { max-height: calc(100vh - 32px); overflow-y: auto; }

/* Farm tab without WebGL */
.farm-unsupported {
  padding: 28px 20px;
  border-radius: 28px;
  background: #fff7e0;
  border: 3px dashed #e0a94d;
  text-align: center;
}
.farm-unsupported.hidden { display: none; }
.farm-unsupported-icon { display: block; font-size: 44px; margin-bottom: 6px; }

/* Ring menu: crop out of stock (grey) + "Buy" pill under it */
.tool-chip.is-empty { background: #efe8dc; border-color: #c8b99a; box-shadow: 0 5px 0 0 #a8997e; }
.tool-chip.is-empty .gi { filter: grayscale(0.9) opacity(0.55); }
.tool-chip.is-empty .tool-badge { background: #8a7b66; }
.tool-buy {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(calc(var(--tx) - 50%), calc(var(--ty) - 50%));
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #047857;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 0 0 #064e3b;
  animation: toolBuyIn 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  z-index: 3;
}
.tool-buy:active { box-shadow: none; transform: translate(calc(var(--tx) - 50%), calc(var(--ty) - 50% + 3px)); }
@keyframes toolBuyIn { from { opacity: 0; } to { opacity: 1; } }
.tool-buy.is-free { background: #f59e0b; color: #451a03; box-shadow: 0 3px 0 0 #b45309; }

/* Out of water alert (js/tools.js) – same shape as the silo alert, in blue */
.water-alert { background: #eef8ff; border-color: #7cc4ef; box-shadow: 0 5px 0 0 #3b95cf, 0 16px 28px -12px rgba(69, 26, 3, 0.45); }
.silo-alert-btn.is-study { background: #38a3e0; color: #fff; box-shadow: 0 4px 0 0 #1b6fa8; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#modalConfirm { z-index: 70; }
#modalConfirm .hidden { display: none; }

/* ==================================================
   DAILY GOAL (js/goal.js) – ring in the top bar + panel
   ================================================== */
.hud-goal {
  --fill: 0%;
  --ring: #f0a030;
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: conic-gradient(var(--ring) var(--fill), #f0dcae 0);
  box-shadow: 0 3px 0 0 #c98a2e;
  transition: transform 0.35s var(--spring);
}
.hud-goal::before { content: ''; position: absolute; inset: 4px; border-radius: 999px; background: #fffaf0; }
.hud-goal > .gi { position: relative; }
.hud-goal:active { transform: translateY(2px) scale(0.94); transition-duration: 0.06s; }
.hud-goal.is-done { --ring: #4caf50; box-shadow: 0 3px 0 0 #2e7d32; }
.hud-goal.is-done::before { background: #effbea; }
.hud-goal-count {
  position: absolute;
  right: -6px;
  bottom: -5px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #7c2d12;
  color: #fff7e6;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.hud-goal.is-done .hud-goal-count { background: #2e7d32; }
.goal-panel { width: 230px; right: auto; left: -95px; transform-origin: top center; } /* centred under the 40px ring */
.goal-panel .seg-group > button { flex: 1; }
@media (max-width: 640px) {
  .hud-goal { width: 32px; height: 32px; }
  .hud-goal > .gi { width: 20px !important; height: 20px !important; }
  .hud-goal::before { inset: 3px; }
  .hud-goal-count { font-size: 10px; line-height: 15px; min-width: 17px; }
  .goal-panel { left: auto; right: -60px; transform-origin: top right; }
}
.goal-star { margin: -18px 0 -14px; }

/* ==================================================
   STREAK (js/streak.js) – flame in the top bar, calendar window
   ================================================== */
.hud-streak {
  position: relative;
  height: 40px;
  min-width: 40px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 4px;
  border-radius: 999px;
  border: 3px solid #f08a24;
  background: #fff3e0;
  box-shadow: 0 3px 0 0 #b4560f;
  transition: transform 0.35s var(--spring);
}
.hud-streak:active { transform: translateY(2px) scale(0.94); transition-duration: 0.06s; }
.hud-streak-count { font-weight: 700; font-size: 16px; color: #9a3412; line-height: 1; }
.hud-streak.is-pending .gi { filter: saturate(0.55) opacity(0.75); }
.hud-streak.is-cold { border-color: #c8b99a; background: #f5efe4; box-shadow: 0 3px 0 0 #a8997e; }
.hud-streak.is-cold .gi { filter: grayscale(1) opacity(0.55); }
.hud-streak.is-cold .hud-streak-count { color: #8a7b66; }
@media (max-width: 640px) {
  .hud-streak { height: 32px; min-width: 32px; padding: 0 6px 0 2px; border-width: 2px; }
  .hud-streak > .gi { width: 22px !important; height: 22px !important; }
  .hud-streak-count { font-size: 13px; }
}
@media (max-width: 400px) {
  .hud-streak { padding: 0 4px 0 1px; }
}
.streak-card { max-height: calc(100vh - 32px); overflow-y: auto; }
.streak-flame { position: relative; display: inline-flex; }
.streak-flame b {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding-top: 14px; font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 rgba(154, 52, 18, 0.8);
}
.streak-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.streak-wd { text-align: center; font-size: 10px; font-weight: 700; color: #b45309; text-transform: uppercase; }
.streak-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: #f5efe4;
  color: #a8997e;
  font-size: 11px;
}
.streak-day.is-done { background: #ffe2c2; border: 2px solid #f08a24; }
.streak-day.is-frozen { background: #e0f2fe; border: 2px solid #7cc4ef; }
.streak-day.is-today { outline: 3px solid #7c2d12; outline-offset: -1px; color: #7c2d12; }
.streak-milestone {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px;
  border-radius: 16px;
  background: #faf5ea;
  border: 2px solid #eadfc8;
  font-size: 13px; color: #451a03;
}
.streak-milestone.is-reached { background: #fff1d6; border-color: #f3c27a; }
.streak-ms-days {
  min-width: 32px; height: 32px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f08a24; color: #fff; font-weight: 700; font-size: 13px;
}
.streak-milestone:not(.is-reached) .streak-ms-days { background: #c8b99a; }
.streak-ms-state { font-size: 11px; font-weight: 700; color: #92400e; white-space: nowrap; }
.streak-milestone.is-reached .streak-ms-state { color: #15803d; font-size: 16px; }

/* Narrow phones: 7 items in the top bar – pills keep their content width, the XP bar collapses to the star + level */
@media (max-width: 400px) {
  #appHeader { padding-left: 8px; padding-right: 8px; }
  #appHeader > div { gap: 4px; }
  #hudPills { gap: 4px; }
  #hudPills .res-pill { flex-shrink: 0; }
  #hudPills .res-xp { padding-right: 3px; }
  #hudPills .res-xp-body { display: none; }
  .res-value { font-size: 13px; }
}
.seg-group.is-locked > button:not(.bg-amber-800) { opacity: 0.45; }

/* Rating streak badge in study ("Streak ×5" + next bonus) */
.study-combo {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 900; color: #9a3412;
  background: linear-gradient(#fff3c4, #ffd98a); border: 1.5px solid #f59e0b;
  padding: 1px 8px 1px 4px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 2px 0 #d97706;
}
.study-combo.hidden { display: none; }
.study-combo-bonus {
  display: inline-flex; align-items: center; gap: 1px;
  color: #1d4ed8; background: #dbeafe; border-radius: 999px; padding: 0 5px; font-size: 10px;
}
.study-combo.is-bump { animation: comboBump 0.35s ease-out; }
@keyframes comboBump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* Plot-type picker (buying a plot): big cards, row on phones, column from sm up */
.plot-type-card {
  display: flex; align-items: center; gap: 0.75rem; text-align: left;
  padding: 0.6rem 0.75rem; border-radius: 1.25rem;
  background: #fffbeb; border: 2px solid #fcd34d;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.plot-type-card:hover { border-color: #d97706; background: #fef3c7; }
.plot-type-card:active { transform: scale(0.97); }
.plot-type-text { display: flex; flex-direction: column; min-width: 0; }
.plot-type-text b { font-size: 1rem; color: #451a03; }
.plot-type-text small { font-size: 0.75rem; color: #92400e; line-height: 1.25; margin-top: 0.1rem; }
@media (min-width: 640px) {
  .plot-type-card { flex-direction: column; text-align: center; gap: 0.4rem; padding: 0.75rem 0.5rem; }
}

/* Plot menu ⋯ in the tool ring (change the plot type) */
.tool-more {
  position: absolute; left: -20px; top: -20px; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; background: #fffaf0; border: 3px solid #e0a94d; color: #78350f;
  font-size: 1.35rem; font-weight: 900; line-height: 1;
  box-shadow: 0 4px 0 0 #c98a2e, 0 8px 14px -8px rgba(69, 26, 3, 0.5);
  transform: translate(var(--tx), var(--ty));
  animation: toolChipIn 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.tool-more:active { box-shadow: 0 1px 0 0 #c98a2e; transform: translate(var(--tx), calc(var(--ty) + 3px)); }
.tool-menu.is-dragging .tool-more { opacity: 0; pointer-events: none; }
/* Type picker: the plot's current type (change mode) */
.plot-type-card.is-current { opacity: 0.6; cursor: default; background: #f5f5f4; border-color: #d6d3d1; }
.plot-type-name { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.plot-type-now { font-style: normal; font-size: 0.65rem; font-weight: 800; padding: 0.05rem 0.45rem; border-radius: 999px; background: #78716c; color: #fff; }
@media (min-width: 640px) { .plot-type-name { justify-content: center; } }

/* Orders in the Market (js/orders.js) */
.order-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 0.6rem;
  padding: 0.75rem; border-radius: 1.25rem; background: #fffbeb; border: 2px solid #fcd34d;
}
.order-card.is-ready { border-color: #10b981; background: #ecfdf5; }
.order-card.is-waiting {
  align-items: center; justify-content: center; text-align: center; gap: 0.15rem; min-height: 9rem;
  background: #fafaf9; border-style: dashed; border-color: #d6d3d1;
}
.order-wait-icon { font-size: 1.6rem; opacity: 0.7; }
.order-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.45rem; border-radius: 0.75rem; background: #fff; border: 1px solid #fde68a; }
.order-item-name { flex: 1; min-width: 0; font-size: 0.8rem; font-weight: 700; color: #451a03; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-item-count { font-size: 0.72rem; font-weight: 800; white-space: nowrap; }
.order-item.is-ok .order-item-count { color: #047857; }
.order-item.is-missing .order-item-count { color: #e11d48; }
.order-reward { display: flex; justify-content: center; gap: 0.9rem; font-weight: 900; color: #451a03; font-size: 0.95rem; }
.order-fulfil { padding: 0.5rem 0.75rem; border-radius: 0.75rem; background: #047857; color: #fff; font-weight: 800; font-size: 0.85rem; }
.order-fulfil.is-disabled { opacity: 0.45; }
.order-discard { padding: 0.5rem 0.7rem; border-radius: 0.75rem; color: #78716c; font-weight: 800; font-size: 0.8rem; }
.order-discard:hover { background: #f5f5f4; }
.order-discard.is-armed { background: #ffe4e6; color: #be123c; }

/* Order board window: wooden board with paper tickets (js/orders.js) */
.order-board {
  background: linear-gradient(180deg, #a86c3c, #8a5a2e);
  border: 4px solid #6b4423;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12), 0 20px 40px -12px rgba(0, 0, 0, 0.5);
}
.order-card.is-ticket {
  position: relative; padding: 0.85rem 0.55rem 0.55rem; gap: 0.45rem; border-radius: 0.4rem;
  background: #fffaf0; border: none; box-shadow: 0 4px 8px -3px rgba(0, 0, 0, 0.4);
  transform: rotate(-1.2deg); transition: transform 0.45s ease, opacity 0.45s ease;
}
.order-card.is-ticket:nth-child(even) { transform: rotate(1.3deg); }
.order-card.is-ticket::before {
  content: ''; position: absolute; top: 4px; left: 50%; width: 10px; height: 10px; margin-left: -5px;
  border-radius: 999px; background: #e0412f; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.order-card.is-ticket.is-ready { background: #f0fdf4; box-shadow: 0 0 0 2px #10b981, 0 4px 8px -3px rgba(0, 0, 0, 0.4); }
.order-card.is-ticket.is-waiting { background: rgba(255, 250, 240, 0.55); min-height: 8.5rem; box-shadow: none; border: 2px dashed rgba(255, 250, 240, 0.7); }
.order-card.is-ticket.is-leaving { transform: translateY(-40px) rotate(-8deg) scale(0.85); opacity: 0; }
.ticket-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; }
.ticket-item { display: flex; flex-direction: column; align-items: center; min-width: 2.6rem; }
.ticket-count { font-size: 0.75rem; font-weight: 900; line-height: 1; margin-top: 0.1rem; }
.ticket-item.is-ok .ticket-count { color: #047857; }
.ticket-item.is-missing .ticket-count { color: #e11d48; }
.order-card.is-ticket .order-reward { font-size: 0.8rem; gap: 0.5rem; }
.order-card.is-ticket .order-fulfil { padding: 0.4rem 0.4rem; font-size: 0.75rem; }
.order-card.is-ticket .order-discard { padding: 0.4rem 0.35rem; font-size: 0.7rem; }

/* Daily study order (js/orders.js): wide blue ticket with a progress bar */
.order-card.study-order { grid-column: 1 / -1; background: #f0f9ff; border-color: #7dd3fc; }
.order-card.study-order.is-ticket { background: #f0f9ff; transform: rotate(-0.6deg); }
.order-card.study-order.is-ready { background: #ecfdf5; border-color: #10b981; }
.order-card.study-order.is-claimed { opacity: 0.7; }
.study-order-bar { position: relative; height: 1.25rem; border-radius: 999px; background: #e0f2fe; border: 1px solid #bae6fd; overflow: hidden; }
.study-order-bar > div { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #38bdf8, #0ea5e9); border-radius: 999px; transition: width 0.4s ease; }
.order-card.study-order.is-ready .study-order-bar > div { background: linear-gradient(90deg, #34d399, #10b981); }
.study-order-bar > span { position: relative; display: block; text-align: center; font-size: 0.72rem; font-weight: 900; line-height: 1.15rem; color: #0c4a6e; }
.order-study-go { padding: 0.45rem 0.6rem; border-radius: 0.75rem; background: #0284c7; color: #fff; font-weight: 800; font-size: 0.8rem; }

/* Speed up (js/speedup.js) */
.speedup-choice {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.7rem 0.9rem; border-radius: 1rem; font-weight: 800; font-size: 0.9rem;
}
.speedup-choice.is-coins { background: #fbbf24; color: #451a03; box-shadow: 0 3px 0 0 #b45309; }
.speedup-choice.is-learn { background: #0284c7; color: #fff; box-shadow: 0 3px 0 0 #075985; }
.speedup-choice:active { transform: translateY(2px); box-shadow: none; }
.speedup-choice.is-poor { opacity: 0.5; }
.speedup-btn {
  flex-shrink: 0; padding: 0.3rem 0.55rem; border-radius: 0.75rem; background: #fde68a; color: #78350f;
  font-weight: 900; font-size: 0.8rem; border: 1px solid #f59e0b;
}
.speedup-btn.is-wide { margin-top: 0.35rem; }
.learn-skip-dots { display: flex; gap: 0.25rem; }
.learn-skip-dots span { flex: 1; height: 0.35rem; border-radius: 999px; background: #e0f2fe; }
.learn-skip-dots span.is-now { background: #7dd3fc; }
.learn-skip-dots span.is-done { background: #0ea5e9; }
.learn-skip-card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem;
  width: 100%; min-height: 11rem; padding: 1.6rem 1rem 1rem; border-radius: 1.25rem; text-align: center;
  background: #fffbeb; border: 2px solid #fcd34d; cursor: pointer;
}
.learn-skip-card.is-flipped { cursor: default; }
.learn-skip-kind { position: absolute; top: 0.5rem; left: 0.6rem; font-size: 0.62rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; color: #b45309; }
.learn-skip-kind.is-practice { color: #7c3aed; }
.learn-skip-front { white-space: pre-line; overflow-wrap: anywhere; font-family: inherit; font-weight: 900; font-size: 1.15rem; color: #451a03; }
.learn-skip-sep, .learn-skip-back { display: none; }
.learn-skip-card.is-flipped .learn-skip-sep { display: block; width: 60%; height: 2px; background: #fde68a; margin: 0.2rem 0; }
.learn-skip-card.is-flipped .learn-skip-back { display: block; white-space: pre-line; overflow-wrap: anywhere; font-weight: 600; font-size: 1rem; color: #78350f; }
.learn-skip-hint { font-size: 0.7rem; font-weight: 800; color: #b45309; opacity: 0.75; margin-top: 0.3rem; }
.learn-skip-rate { margin-top: 0.6rem; }
.learn-skip-wait { height: 0.25rem; border-radius: 999px; background: transparent; overflow: hidden; margin-bottom: 0.4rem; }
.learn-skip-rate.is-wait .learn-skip-wait { background: #e0f2fe; }
.learn-skip-rate.is-wait .learn-skip-wait > div { height: 100%; background: #0ea5e9; animation: learnSkipWait 1.5s linear forwards; }
@keyframes learnSkipWait { from { width: 0; } to { width: 100%; } }
.lsr { padding: 0.55rem 0.2rem; border-radius: 0.8rem; font-weight: 900; font-size: 0.75rem; border: 2px solid; transition: opacity 0.2s; }
.lsr.is-again { background: #fff1f2; border-color: #fecdd3; color: #881337; }
.lsr.is-hard { background: #fff7ed; border-color: #fed7aa; color: #7c2d12; }
.lsr.is-good { background: #ecfdf5; border-color: #a7f3d0; color: #064e3b; }
.lsr.is-easy { background: #f0f9ff; border-color: #bae6fd; color: #0c4a6e; }
.learn-skip-rate.is-wait .lsr { opacity: 0.4; }
.learn-skip-done { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 1.6rem 0.5rem 1rem; text-align: center; }
.learn-skip-done.hidden { display: none; }
.learn-skip-done-icon { font-size: 3.2rem; animation: learnSkipZoom 1.2s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes learnSkipZoom {
  0% { transform: scale(0.2) translateX(-60px); opacity: 0; }
  45% { transform: scale(1.25) translateX(0); opacity: 1; }
  70% { transform: scale(1) translateX(10px); }
  100% { transform: scale(1) translateX(0); }
}

/* Market tabs (js/shop.js setShopTab): one row, scrolls sideways on phones */
.shop-tabs {
  display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.25rem 0.1rem 0.4rem;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.shop-tabs::-webkit-scrollbar { display: none; }
.shop-tabs > button {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 0.4rem; scroll-snap-align: center;
  padding: 0.5rem 0.85rem; border-radius: 999px; white-space: nowrap;
  background: #fff; border: 2px solid #fcd34d; color: #78350f; font-weight: 800; font-size: 0.85rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.shop-tabs > button:hover { background: #fffbeb; }
.shop-tabs > button.is-active { background: #78350f; border-color: #78350f; color: #fffbeb; box-shadow: 0 3px 0 0 #451a03; }

/* Badges on the Market tabs + flash on an item opened by a link (js/shop.js) */
.shop-tabs > button { position: relative; }
.shop-tabs { padding-top: 0.6rem; }
.shop-tab-badge {
  position: absolute; top: -0.5rem; right: -0.2rem; min-width: 1.2rem; height: 1.2rem; padding: 0 0.35rem;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
  font-size: 0.65rem; font-weight: 900; line-height: 1; color: #fff; border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(69, 26, 3, 0.25); pointer-events: none;
}
.shop-tab-badge.is-count { background: #059669; }
.shop-tab-badge.is-alert { background: #e11d48; animation: shopBadgePulse 1.4s ease-in-out infinite; }
.shop-tab-badge.is-new { background: #f59e0b; color: #451a03; text-transform: uppercase; letter-spacing: 0.03em; }
@keyframes shopBadgePulse { 50% { transform: scale(1.18); } }
.shop-item-flash { animation: shopItemFlash 1.6s ease-out 0.3s 1; }
@keyframes shopItemFlash {
  0%, 60% { box-shadow: 0 0 0 4px #f59e0b, 0 0 18px 4px rgba(245, 158, 11, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Compact Market tiles (js/shop.js shopTile): 3 side by side on phones, 5 on a computer */
.shop-tile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
@media (min-width: 1024px) { .shop-tile-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.65rem; } }
.shop-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0;
  padding: 0.55rem 0.35rem 0.45rem; border-radius: 1rem; background: #fffbeb; border: 2px solid #fcd34d;
}
.shop-tile.is-locked { background: #fafaf9; border-color: #e7e5e4; }
.shop-tile.is-locked .shop-tile-icon { filter: grayscale(0.7); opacity: 0.6; }
.shop-tile.is-empty .shop-tile-icon { opacity: 0.5; }
.shop-tile.is-owned { background: #ecfdf5; border-color: #a7f3d0; }
.shop-tile-info {
  position: absolute; top: 0.2rem; right: 0.2rem; width: 1.5rem; height: 1.5rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 900; line-height: 1; color: #b45309; background: rgba(255, 255, 255, 0.7);
}
.shop-tile-info:hover { background: #fef3c7; }
.shop-tile-icon { display: flex; justify-content: center; margin-top: 0.15rem; }
.shop-tile-name { margin-top: 0.15rem; width: 100%; font-size: 0.75rem; font-weight: 900; color: #451a03; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-tile-short { width: 100%; font-size: 0.62rem; font-weight: 700; color: #92400e; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-tile-meta { font-size: 0.62rem; font-weight: 800; color: #78350f; line-height: 1.2; }
.shop-tile-action { margin-top: auto; padding-top: 0.35rem; width: 100%; display: flex; flex-direction: column; gap: 0.25rem; }
.shop-tile-btn {
  width: 100%; padding: 0.35rem 0.2rem; border-radius: 0.65rem; font-size: 0.68rem; font-weight: 800; line-height: 1.1;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.15rem; white-space: nowrap;
}
.shop-tile-btn.is-buy { background: #78350f; color: #fff; }
.shop-tile-btn.is-buy:hover { background: #451a03; }
.shop-tile-btn.is-sell { background: #fff; color: #451a03; border: 1px solid #fcd34d; }
.shop-tile-btn.is-free { background: #059669; color: #fff; }
.shop-tile-btn.is-disabled { opacity: 0.45; cursor: not-allowed; }
.shop-tile-lock, .shop-tile-owned { display: block; padding: 0.35rem 0.2rem; font-size: 0.65rem; font-weight: 800; border-radius: 0.65rem; }
.shop-tile-lock { color: #a8a29e; background: #f5f5f4; }
.shop-tile-owned { color: #047857; background: #d1fae5; }
.shop-tile-note { font-size: 0.58rem; font-weight: 700; color: #78716c; line-height: 1.15; }
.shop-info-list { margin-top: 0.6rem; text-align: left; display: flex; flex-direction: column; gap: 0.35rem; }
.shop-info-list li { font-size: 0.82rem; color: #78350f; padding: 0.4rem 0.6rem; border-radius: 0.75rem; background: #fffbeb; border: 1px solid #fde68a; }

/* Quantity window (js/shop.js QtyPicker) */
.qty-stepper { display: flex; align-items: center; justify-content: center; gap: 0.9rem; }
.qty-stepper button {
  width: 2.75rem; height: 2.75rem; border-radius: 999px; font-size: 1.5rem; font-weight: 900; line-height: 1;
  background: #fef3c7; color: #78350f; border: 2px solid #fcd34d; box-shadow: 0 3px 0 0 #d97706;
}
.qty-stepper button:active { transform: translateY(2px); box-shadow: none; }
.qty-stepper button:disabled { opacity: 0.4; box-shadow: none; }
.qty-stepper b { min-width: 3.5rem; font-size: 2rem; font-weight: 900; color: #451a03; font-variant-numeric: tabular-nums; }
.qty-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem; }
.qty-quick button { padding: 0.4rem 0; border-radius: 0.75rem; font-size: 0.8rem; font-weight: 800; background: #fffbeb; color: #78350f; border: 1px solid #fde68a; }
.qty-quick button.is-on { background: #78350f; color: #fff; border-color: #78350f; }
.qty-why { margin-top: 0.4rem; padding: 0.4rem 0.6rem; border-radius: 0.75rem; font-size: 0.75rem; font-weight: 800; color: #9f1239; background: #ffe4e6; }
.qty-why.hidden { display: none; }
.qty-ok {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem; padding: 0.6rem 0.75rem;
  border-radius: 0.9rem; background: #fbbf24; color: #451a03; font-weight: 900; font-size: 0.9rem; box-shadow: 0 3px 0 0 #b45309;
}
.qty-ok.is-sell { background: #059669; color: #fff; box-shadow: 0 3px 0 0 #065f46; }
.qty-ok.is-disabled { opacity: 0.45; box-shadow: none; cursor: not-allowed; }

/* Study order ring in the top bar (js/orders.js StudyOrder.renderHud) – blue twin of the daily-goal ring */
.hud-study-order { --ring: #38a3e0; box-shadow: 0 3px 0 0 #1b6fa8; }
.hud-study-order.hidden { display: none; }
.hud-study-order::before { background: #f0f9ff; }
.hud-study-order-icon { position: relative; font-size: 18px; line-height: 1; }
.hud-study-order .hud-goal-count { background: #075985; right: auto; left: 50%; bottom: -7px; transform: translateX(-50%); white-space: nowrap; }
.hud-study-order.is-done { animation: studyOrderPop 0.5s var(--spring); }
.hud-study-order.is-leaving { transform: scale(0); opacity: 0; transition: transform 0.45s ease, opacity 0.45s ease; }
@keyframes studyOrderPop { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@media (max-width: 640px) { .hud-study-order-icon { font-size: 15px; } }

/* Ambient sounds switch in the sound panel (js/weather.js) */
.ambient-toggle { background: #ecfdf5; color: #065f46; border-radius: 0.75rem; }
.ambient-toggle.is-off { background: #f5f5f4; color: #78716c; }

/* Card overview under the study card (js/study.js StudyOverview) */
.study-overview { display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem; border-radius: 1.5rem; background: #fff; border: 2px solid #fde68a; }
.study-overview.hidden { display: none; }
.ov-chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.35rem; }
.ov-chip { display: flex; flex-direction: column; align-items: center; gap: 0.05rem; padding: 0.35rem 0.2rem; border-radius: 0.9rem; border: 2px solid transparent; font-size: 0.68rem; font-weight: 800; line-height: 1.1; transition: transform 0.12s ease; }
.ov-chip b { font-size: 1rem; font-weight: 900; }
.ov-chip:active { transform: scale(0.95); }
.ov-chip.is-new, .ov-pill.is-new { background: #ede9fe; color: #5b21b6; }
.ov-chip.is-again, .ov-pill.is-again { background: #ffe4e6; color: #9f1239; }
.ov-chip.is-hard, .ov-pill.is-hard { background: #ffedd5; color: #9a3412; }
.ov-chip.is-good, .ov-pill.is-good { background: #d1fae5; color: #065f46; }
.ov-chip.is-easy, .ov-pill.is-easy { background: #e0f2fe; color: #075985; }
.ov-chip.is-on { border-color: currentColor; box-shadow: 0 2px 0 0 currentColor; }
.ov-search { flex: 1; min-width: 0; padding: 0.45rem 0.7rem; border-radius: 0.8rem; border: 2px solid #fde68a; font-size: 0.8rem; background: #fffbeb; }
.ov-sort { padding: 0.45rem 0.5rem; border-radius: 0.8rem; border: 2px solid #fde68a; font-size: 0.75rem; font-weight: 700; color: #78350f; background: #fffbeb; }
.ov-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 26rem; overflow-y: auto; }
.ov-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; padding: 0.45rem 0.6rem; border-radius: 0.8rem; background: #fffbeb; border: 1px solid #fef3c7; font-size: 0.75rem; }
.ov-row.is-current { background: #fef3c7; border: 2px solid #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18); }
.ov-front { font-weight: 800; color: #451a03; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-back { color: #78716c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; }
.ov-pill { padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.62rem; font-weight: 900; white-space: nowrap; }
.ov-due { font-size: 0.6rem; font-weight: 700; color: #a16207; white-space: nowrap; }
.ov-empty { padding: 0.8rem; text-align: center; font-size: 0.75rem; color: #a8a29e; font-weight: 700; }

/* Card overview: edit / delete per row, inline editor, add button (js/study.js StudyOverview) */
.ov-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
.ov-actions { display: flex; gap: 0.15rem; }
.ov-btn { padding: 0.25rem 0.35rem; border-radius: 0.6rem; font-size: 0.8rem; line-height: 1; background: transparent; }
.ov-btn:hover { background: #fde68a; }
.ov-row.is-editing { grid-template-columns: 1fr; gap: 0.35rem; background: #fff; border: 2px solid #f59e0b; }
.ov-row.is-editing textarea { width: 100%; resize: vertical; padding: 0.4rem 0.55rem; border-radius: 0.6rem; border: 2px solid #fde68a; font-size: 0.8rem; background: #fffbeb; }
.ov-row.is-editing .ov-edit-front { font-weight: 800; color: #451a03; }
.ov-edit-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.ov-edit-actions .ov-btn { padding: 0.4rem 0.8rem; font-size: 0.75rem; font-weight: 800; color: #78350f; background: #fef3c7; }
.ov-edit-actions .ov-btn.is-save { background: #059669; color: #fff; }
.ov-add { align-self: flex-start; padding: 0.45rem 0.9rem; border-radius: 0.8rem; font-size: 0.8rem; font-weight: 800; background: #78350f; color: #fffbeb; }
@media (max-width: 420px) {
  .ov-row:not(.is-editing) { grid-template-columns: minmax(0, 1fr) auto auto; }
  .ov-row .ov-front { grid-column: 1; grid-row: 1; }
  .ov-row .ov-back { grid-column: 1; grid-row: 2; }
  .ov-row .ov-meta { grid-row: 1 / span 2; grid-column: 2; }
  .ov-row .ov-actions { grid-row: 1 / span 2; grid-column: 3; flex-direction: column; }
}

/* ==================================================
   FOCUS MODE in Study (js/study.js Focus, body.study-focus)
   ================================================== */
.focus-btn { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.4rem 0.8rem; border-radius: 0.9rem; font-size: 0.75rem; font-weight: 900; color: #78350f; background: #fef3c7; border: 2px solid #fcd34d; }
.focus-btn:hover { background: #fde68a; }
.focus-bar, .focus-exit { display: none; }
body.study-focus { background: linear-gradient(180deg, #fbf6ec 0%, #f3ead8 100%); padding-bottom: 0 !important; } /* no room for the hidden tab bar */
body.study-focus #appHeader,
body.study-focus #tabBar,
body.study-focus #toastContainer,
body.study-focus #studyHeaderBar,
body.study-focus #studyModeRow,
body.study-focus #studyCardMetaRow,
body.study-focus #studyOverview { display: none !important; }
body.study-focus main { padding-top: 0; padding-bottom: 0; }
body.study-focus #viewStudy {
  max-width: 44rem; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center; gap: 1rem; padding: 2.5rem 0 1.5rem;
}
body.study-focus #studyCardStage { height: min(62vh, 34rem); }
body.study-focus .focus-bar {
  display: block; position: fixed; top: 0; left: 0; right: 0; height: 4px; background: rgba(120, 53, 15, 0.12); z-index: 60;
}
body.study-focus .focus-bar > div { height: 100%; width: 0; background: #d97706; border-radius: 0 4px 4px 0; transition: width 0.35s ease; }
body.study-focus .focus-exit {
  display: flex; align-items: center; justify-content: center; position: fixed; top: 14px; right: 14px; z-index: 60;
  width: 2.5rem; height: 2.5rem; border-radius: 999px; font-size: 1.1rem; font-weight: 900; color: #78350f;
  background: rgba(255, 251, 235, 0.92); border: 2px solid #fcd34d; box-shadow: 0 4px 12px -6px rgba(69, 26, 3, 0.4);
}

/* Keyboard hints (js/study.js studyKeyAction): only on computers with a mouse / trackpad */
.key-hint, .keys-hint { display: none; }
@media (hover: hover) and (pointer: fine) {
  .key-hint {
    display: inline-flex; align-items: center; justify-content: center; position: absolute; top: 4px; right: 6px;
    min-width: 1.05rem; height: 1.05rem; padding: 0 0.2rem; border-radius: 0.3rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.6rem; font-weight: 800; line-height: 1;
    color: rgba(69, 26, 3, 0.55); background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(120, 53, 15, 0.2);
  }
  .keys-hint { display: block; margin-top: 0.4rem; text-align: center; font-size: 0.68rem; font-weight: 700; color: rgba(146, 64, 14, 0.7); }
}

/* "While you were away" window (js/welcome.js) */
.welcome-list { display: flex; flex-direction: column; gap: 0.45rem; }
.welcome-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border-radius: 1rem; background: #fffbeb; border: 1px solid #fde68a; }
.welcome-row b { display: block; font-size: 0.85rem; font-weight: 800; color: #451a03; }
.welcome-row small { display: block; font-size: 0.72rem; font-weight: 600; color: #92400e; line-height: 1.3; }
/* "Welcome back" gift: Elise + the gift items (js/welcome.js) */
.welcome-gift { padding: 0.7rem; border-radius: 1.1rem; background: #ecfdf5; border: 2px solid #6ee7b7; }
.welcome-gift-elise { display: flex; align-items: flex-start; gap: 0.6rem; }
.welcome-gift-avatar { flex-shrink: 0; width: 56px; height: 56px; border-radius: 999px; overflow: hidden; background: #fff; border: 2px solid #6ee7b7; display: flex; align-items: center; justify-content: center; }
.welcome-gift-name { font-size: 0.72rem; font-weight: 800; color: #047857; }
.welcome-gift-text { font-size: 0.82rem; font-weight: 700; color: #064e3b; line-height: 1.35; }
.welcome-gift-label { margin-top: 0.55rem; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: #047857; text-align: center; }
.welcome-gift-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin-top: 0.3rem; }
/* Beginner wind (js/wind.js) */
.hud-wind { --ring: #2dd4bf; box-shadow: 0 3px 0 0 #0f766e; }
.hud-wind::before { background: #f0fdfa; }
/* ≤ 400 px: the top bar has no room for one more ring – the silo ring steps aside while the wind blows */
@media (max-width: 400px) { body.wind-on #hudSilo { display: none; } }
.hud-wind .hud-goal-count { background: #0f766e; right: auto; left: 50%; bottom: -7px; transform: translateX(-50%); white-space: nowrap; }
.wind-elise { background: #f0f9ff; border-color: #7dd3fc; }
.wind-elise .welcome-gift-avatar { border-color: #7dd3fc; }
.wind-elise .welcome-gift-name { color: #0369a1; }
.wind-elise .welcome-gift-text { color: #0c4a6e; }
.wind-perks { display: flex; flex-direction: column; gap: 0.35rem; }
.wind-perk { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.6rem; border-radius: 0.9rem; background: #fffbeb; border: 1px solid #fde68a; font-size: 0.85rem; font-weight: 800; color: #451a03; }
.welcome-gift-item { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.2rem 0.55rem 0.2rem 0.3rem; border-radius: 999px; background: #fff; border: 1px solid #a7f3d0; font-size: 0.8rem; font-weight: 800; color: #064e3b; }

/* Settings in the header panel: reminders switch + time (js/reminders.js) */
.reminders-box { padding-top: 0.6rem; border-top: 1px dashed #fcd34d; }
.switch { position: relative; width: 2.6rem; height: 1.5rem; border-radius: 999px; background: #d6d3d1; transition: background 0.2s ease; flex-shrink: 0; }
.switch > span { position: absolute; top: 0.15rem; left: 0.15rem; width: 1.2rem; height: 1.2rem; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s ease; }
.switch.is-on { background: #059669; }
.switch.is-on > span { transform: translateX(1.1rem); }
.reminders-time { padding: 0.25rem 0.4rem; border-radius: 0.6rem; border: 2px solid #fde68a; background: #fffbeb; font-size: 0.8rem; font-weight: 800; color: #78350f; }
.reminders-time:disabled { opacity: 0.5; }
.tut-settings-btn { padding: 0.25rem 0.6rem; border-radius: 0.6rem; border: 2px solid #fde68a; background: #fffbeb; font-size: 0.75rem; font-weight: 800; color: #78350f; white-space: nowrap; }
.tut-settings-btn:active { transform: scale(0.96); }

/* Tutorial (js/tutorial.js): dim blockers around one highlighted spot + Elise's speech bubble */
#tutorialOverlay { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
#tutorialOverlay.is-hidden { display: none; }
.tut-dim { position: fixed; inset: 0; pointer-events: none; }
.tut-dim path { fill: rgba(28, 18, 6, 0.62); pointer-events: visiblePainted; } /* the dark part blocks clicks, the holes don't */
.tut-guard { position: fixed; pointer-events: auto; background: transparent; } /* Elise is visible, not clickable */
.tut-ring {
  position: fixed; pointer-events: none; border: 3px solid #fbbf24; box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.35), 0 0 22px 6px rgba(251, 191, 36, 0.45);
  animation: tutPulse 1.4s ease-in-out infinite; transition: all 0.25s ease;
}
@keyframes tutPulse { 50% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0.2), 0 0 30px 10px rgba(251, 191, 36, 0.35); } }
.tut-bubble {
  position: fixed; pointer-events: auto; display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.85rem 0.9rem;
  border-radius: 1.25rem; background: #fffbeb; border: 3px solid #fbbf24; box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.55);
  transition: top 0.25s ease, left 0.25s ease; animation: tutIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes tutIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.tut-avatar { flex-shrink: 0; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 999px; background: #fde68a; }
.tut-body { min-width: 0; flex: 1; }
.tut-name { font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: #b45309; }
.tut-text { font-size: 0.88rem; font-weight: 700; color: #451a03; line-height: 1.35; margin-top: 0.1rem; }
.tut-actions { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.tut-skip { font-size: 0.7rem; font-weight: 700; color: #a8a29e; text-decoration: underline; }
.tut-next { padding: 0.45rem 0.9rem; border-radius: 0.8rem; background: #059669; color: #fff; font-size: 0.82rem; font-weight: 900; }
.tut-step { position: absolute; top: 0.45rem; right: 0.7rem; font-size: 0.62rem; font-weight: 900; color: #d97706; }

/* Elise's speech bubble on the farm (js/tutorial.js): no portrait, a tail pointing at her */
.tut-bubble.is-speech { padding: 0.75rem 0.9rem; }
.tut-tail { display: none; }
.tut-bubble.is-speech .tut-tail {
  display: block; position: absolute; bottom: -12px; width: 20px; height: 20px; background: #fffbeb;
  border-right: 3px solid #fbbf24; border-bottom: 3px solid #fbbf24; transform: rotate(45deg);
}
.tut-bubble.is-speech.tail-up .tut-tail { bottom: auto; top: -12px; transform: rotate(225deg); }
.tut-text { min-height: 2.4em; }

/* Homestead window: what the next level brings */
.hs-benefits { list-style: none; margin: 0.5rem auto 0; padding: 0; max-width: 20rem; text-align: left; display: grid; gap: 0.3rem; }
.hs-benefits li { display: flex; align-items: center; gap: 0.5rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 0.75rem; padding: 0.3rem 0.6rem; font-size: 0.75rem; font-weight: 700; color: #78350f; line-height: 1.25; }
.hs-benefits li > :first-child { flex-shrink: 0; }

/* Fishing window (js/fishing.js): result after one card */
.fishing-result { text-align: center; padding: 0.75rem 0 0.25rem; }
.fishing-result-icon { display: flex; justify-content: center; min-height: 96px; align-items: center; font-size: 3.5rem; }
.fishing-result-icon.is-caught { animation: fishPop 0.5s cubic-bezier(.2,1.6,.4,1); }
.fishing-rarity { display: inline-block; margin-top: 0.25rem; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.7rem; font-weight: 800; }
.fishing-rarity.is-common { background: #e7e5e4; color: #44403c; }
.fishing-rarity.is-uncommon { background: #d1fae5; color: #065f46; }
.fishing-rarity.is-rare { background: #dbeafe; color: #1e40af; }
.fishing-rarity.is-legendary { background: #fef3c7; color: #92400e; box-shadow: 0 0 0 2px #f59e0b inset; }
@keyframes fishPop { 0% { transform: translateY(18px) scale(0.4) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Catch book (js/fishing.js FishBook) */
.fishbook-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
@media (min-width: 480px) { .fishbook-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.fishbook-card { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.55rem 0.4rem; border-radius: 1rem; background: #f0f9ff; border: 2px solid #bae6fd; text-align: center; }
.fishbook-card.is-legendary.is-caught { background: #fffbeb; border-color: #fcd34d; }
.fishbook-card.is-unknown { background: #f5f5f4; border-color: #e7e5e4; }
.fishbook-icon { height: 64px; display: flex; align-items: center; justify-content: center; }
.fishbook-card.is-unknown .fishbook-icon { filter: brightness(0) opacity(0.28); } /* not caught yet: a silhouette */
.fishbook-name { font-weight: 900; font-size: 0.85rem; color: #451a03; }
.fishbook-card.is-unknown .fishbook-name { color: #a8a29e; letter-spacing: 0.1em; }
.fishbook-stat { font-size: 0.7rem; font-weight: 700; color: #075985; line-height: 1.2; }
.fishbook-stat.is-muted { color: #a8a29e; }
.fishbook-btn { width: 2.1rem; height: 2.1rem; border-radius: 999px; background: #e0f2fe; display: inline-flex; align-items: center; justify-content: center; }
.fishing-badge { display: inline-block; margin-top: 0.25rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: #f59e0b; color: #fff; font-size: 0.7rem; font-weight: 900; }
.pond-book-label { pointer-events: auto !important; cursor: pointer; }

/* Pen window (js/animals.js) */
.pen-list { display: grid; gap: 0.35rem; }
.pen-row { display: flex; align-items: center; gap: 0.5rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: 0.9rem; padding: 0.3rem 0.6rem; }
.pen-name { flex: 1; font-weight: 800; font-size: 0.8rem; color: #451a03; }
.pen-st { font-size: 0.72rem; font-weight: 800; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.2rem; }
.pen-st.is-ready { color: #047857; }
.pen-st.is-busy { color: #92400e; font-variant-numeric: tabular-nums; }
.pen-st.is-hungry { color: #be123c; }

/* Pets (js/animals.js): bonus chip in timers / pen rows, bonus box in the pet window */
.pet-bonus { display: inline-block; margin-top: 0.15rem; padding: 0.05rem 0.45rem; border-radius: 999px; background: #dcfce7; color: #166534; font-size: 0.65rem; font-weight: 800; }
.pen-name .pet-bonus { display: block; width: max-content; }
.pet-bonus-box { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; border-radius: 0.9rem; padding: 0.45rem 0.6rem; font-size: 0.8rem; font-weight: 800; }
.pet-label { pointer-events: auto !important; cursor: pointer; }

/* Decor lot window (js/decor.js): 3×3 spots + catalogue */
.decor-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; max-width: 15rem; margin-left: auto; margin-right: auto; padding: 0.4rem; background: #b8945f; border-radius: 1rem; }
.decor-cell { aspect-ratio: 1; border-radius: 0.7rem; background: #d9bd8a; border: 2px dashed #a07d4c; display: flex; align-items: center; justify-content: center; }
.decor-cell.is-filled { background: #e9cf96; border-style: solid; border-color: #c49a5a; }
.decor-cell.is-picked { border: 3px solid #f59e0b; background: #fef3c7; box-shadow: 0 0 0 3px rgba(245,158,11,0.3); }
.decor-plus { font-size: 1.6rem; font-weight: 900; color: #78350f; opacity: 0.55; }
.decor-catalogue { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.decor-item { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; padding: 0.35rem 0.2rem; border-radius: 0.8rem; background: #fffbeb; border: 1px solid #fde68a; }
.decor-item.is-locked { opacity: 0.5; filter: grayscale(0.6); }
.decor-item.is-poor .decor-item-price { color: #e11d48; }
.decor-item-name { font-size: 0.65rem; font-weight: 800; color: #451a03; line-height: 1.1; text-align: center; }
.decor-item-price { font-size: 0.68rem; font-weight: 800; color: #92400e; display: inline-flex; align-items: center; gap: 0.15rem; }
.decor-note { grid-column: 1 / -1; text-align: center; font-size: 0.75rem; font-weight: 700; color: #92400e; }


/* Building decorations by dragging (js/decor.js startPaint): bar at the top of the farm */
.decor-paint-bar { position: fixed; left: 50%; top: calc(var(--farm-top, 70px) + 8px); transform: translateX(-50%); z-index: 45; width: min(92vw, 26rem); display: flex; align-items: center; gap: 0.5rem; background: #fffbeb; border: 2px solid #f59e0b; border-radius: 1.1rem; padding: 0.35rem 0.5rem 0.35rem 0.4rem; box-shadow: 0 6px 18px rgba(120, 53, 15, 0.25); }
.decor-paint-bar .dp-text { flex: 1; min-width: 0; line-height: 1.2; }
.decor-paint-bar .dp-name { font-weight: 900; font-size: 0.85rem; color: #451a03; }
.decor-paint-bar .dp-info { font-weight: 700; font-size: 0.72rem; color: #92400e; display: flex; align-items: center; gap: 0.2rem; flex-wrap: wrap; }
.decor-paint-bar .dp-draw-only { display: none; }
.decor-paint-bar.is-draw .dp-draw-only { display: inline-flex; }
.decor-paint-bar.is-draw button { padding: 0.45rem 0.55rem; }
.decor-paint-bar .dp-erase.is-on { background: #fee2e2; color: #b91c1c; box-shadow: inset 0 0 0 2px #ef4444; }
.decor-paint-bar .dp-done { background: #16a34a; color: #fff; }
.decor-paint-bar .dp-done.is-off { opacity: 0.45; }
.decor-paint-bar button { flex-shrink: 0; background: #f5f5f4; color: #57534e; font-weight: 900; font-size: 0.8rem; border-radius: 0.8rem; padding: 0.45rem 0.8rem; }

/* EDIT MODE (js/editmode.js): the game HUD hides, an edit bar on top and a category panel at the bottom */
#editTopBar, #editPanel { display: none; }
body.edit-mode #appHeader, body.edit-mode #tabBar, body.edit-mode #farmToolbar, body.edit-mode #questsCard,
body.edit-mode #moveModeHelperNotice, body.edit-mode [data-i18n="farm3dHint"] { display: none !important; }
body.edit-mode #farm3dWrap { top: 0 !important; bottom: 0 !important; }
body.edit-mode #editTopBar { display: flex; position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 50%; transform: translateX(-50%); z-index: 46; width: min(calc(100% - 16px), 34rem); align-items: center; gap: 0.5rem; background: rgba(255, 251, 235, 0.95); border: 2px solid #fcd34d; border-radius: 1.1rem; padding: 0.35rem 0.45rem; box-shadow: 0 4px 14px rgba(120, 53, 15, 0.2); }
.edit-coins { flex: 1; display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 900; color: #78350f; font-size: 1rem; }
.edit-btn { font-weight: 900; font-size: 0.82rem; border-radius: 0.8rem; padding: 0.45rem 0.8rem; }
.edit-btn.is-undo { background: #f5f5f4; color: #44403c; }
.edit-btn.is-undo.is-off { opacity: 0.4; }
.edit-btn.is-done { background: #059669; color: #fff; }
.edit-btn.is-cancel { background: #f5f5f4; color: #44403c; }
.edit-btn.is-destroy { background: #f5f5f4; padding-left: 0.6rem; padding-right: 0.6rem; }
.edit-btn.is-destroy.is-on { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.35); }
body.edit-destroy #farm3dWrap canvas { cursor: crosshair; }
body.edit-mode #editPanel { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; background: rgba(255, 251, 235, 0.97); border-top: 3px solid #fcd34d; border-radius: 1.2rem 1.2rem 0 0; padding: 0.45rem 0.5rem calc(env(safe-area-inset-bottom, 0px) + 0.5rem); box-shadow: 0 -4px 14px rgba(120, 53, 15, 0.18); }
.edit-cats { display: flex; gap: 0.3rem; overflow-x: auto; scrollbar-width: none; }
.edit-cats::-webkit-scrollbar { display: none; }
.edit-cat { flex-shrink: 0; font-weight: 900; font-size: 0.78rem; color: #92400e; background: #fef3c7; border-radius: 999px; padding: 0.3rem 0.75rem; }
.edit-cat.is-on { background: #b45309; color: #fff; }
.edit-items { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.45rem 0.1rem 0.1rem; min-height: 6.4rem; scrollbar-width: thin; }
.edit-card { flex-shrink: 0; width: 5.6rem; display: flex; flex-direction: column; align-items: center; gap: 0.1rem; background: #fff; border: 2px solid #fde68a; border-radius: 0.9rem; padding: 0.35rem 0.25rem; }
.edit-card.is-off { opacity: 0.5; filter: grayscale(0.5); }
.edit-card.is-owned { border-color: #6ee7b7; background: #ecfdf5; }
.edit-card-name { font-size: 0.66rem; font-weight: 800; color: #451a03; text-align: center; line-height: 1.1; }
.edit-card-sub { font-size: 0.66rem; font-weight: 800; color: #92400e; display: inline-flex; align-items: center; gap: 0.15rem; }
.edit-empty { font-size: 0.78rem; font-weight: 700; color: #92400e; padding: 1rem 0.5rem; text-align: center; width: 100%; }
body.edit-mode .decor-paint-bar { top: calc(env(safe-area-inset-top, 0px) + 66px); }
body.edit-mode #buildModeNotice { bottom: 9.5rem !important; z-index: 47; }

/* Edit mode: toasts below the edit bar */
body.edit-mode #toastContainer { top: calc(env(safe-area-inset-top, 0px) + 66px) !important; }

/* Edit mode: the selected object's bar (Otočit, Do skladu, Prodat) above the category panel */
body.edit-mode #editSelBar:not(.hidden) { display: flex; }
#editSelBar { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 9.9rem); z-index: 47; width: min(calc(100% - 16px), 30rem); align-items: center; gap: 0.35rem; background: #fffbeb; border: 2px solid #fbbf24; border-radius: 1rem; padding: 0.3rem 0.4rem; box-shadow: 0 4px 14px rgba(120, 53, 15, 0.25); }
.edit-sel-name { flex: 1; min-width: 0; font-weight: 900; font-size: 0.8rem; color: #451a03; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-sel-btn { flex-shrink: 0; font-weight: 800; font-size: 0.72rem; color: #78350f; background: #fde68a; border-radius: 0.7rem; padding: 0.35rem 0.55rem; }
.edit-sel-btn.is-off { opacity: 0.4; }
.edit-sel-x { flex-shrink: 0; width: 1.8rem; height: 1.8rem; border-radius: 999px; background: #f5f5f4; color: #57534e; font-weight: 900; }
/* Vzhled panel (js/editmode.js renderLook): replaces the bottom panel + selection bar while open */
body.edit-look-open #editPanel, body.edit-look-open #editSelBar { display: none !important; }
#editLookPanel { display: none; }
body.edit-mode #editLookPanel:not(.hidden) { display: block; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); z-index: 47; width: min(calc(100% - 16px), 34rem); background: #fffbeb; border: 2px solid #fbbf24; border-radius: 1.2rem; padding: 0.55rem 0.6rem 0.6rem; box-shadow: 0 6px 18px rgba(120, 53, 15, 0.25); }
.el-head { display: flex; align-items: center; gap: 0.45rem; }
.el-head b { flex: 1; min-width: 0; font-weight: 900; font-size: 0.9rem; color: #451a03; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.el-free { flex-shrink: 0; font-size: 0.65rem; font-weight: 800; color: #047857; background: #d1fae5; border-radius: 999px; padding: 0.15rem 0.5rem; }
.el-label { margin-top: 0.4rem; font-size: 0.68rem; font-weight: 900; color: #92400e; text-transform: uppercase; letter-spacing: 0.04em; }
.el-pals { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0.25rem 0.1rem 0.3rem; scrollbar-width: none; }
.el-pal { flex-shrink: 0; width: 4.1rem; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; border-radius: 0.8rem; padding: 0.3rem 0.15rem; background: #fff; border: 2px solid #fde68a; }
.el-pal.is-on { border-color: #059669; box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.25); }
.el-pal small { font-size: 0.6rem; font-weight: 800; color: #78350f; line-height: 1.1; text-align: center; }
.el-sw { width: 2.3rem; height: 2.3rem; border-radius: 0.6rem; overflow: hidden; display: flex; flex-direction: column; border: 1px solid rgba(0, 0, 0, 0.12); }
.el-sw i { flex: 1; }
.el-sw i:first-child { flex: 1.3; }
.el-sw-default { align-items: center; justify-content: center; background: #fef3c7; }
.el-styles { display: flex; flex-wrap: wrap; gap: 0.35rem; padding-top: 0.25rem; }
.el-style { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 800; color: #78350f; background: #fff; border: 2px solid #fde68a; border-radius: 0.8rem; padding: 0.3rem 0.6rem; }
.el-style i { width: 0.8rem; height: 0.8rem; border-radius: 0.25rem; border: 1px solid rgba(0, 0, 0, 0.15); }
.el-style em { font-style: normal; font-size: 0.65rem; color: #a8a29e; }
.el-style.is-on { border-color: #059669; box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.25); }
.el-style.is-locked { opacity: 0.55; }
.el-actions { display: flex; gap: 0.4rem; margin-top: 0.55rem; }
.el-btn { flex: 1; font-weight: 900; font-size: 0.78rem; border-radius: 0.8rem; padding: 0.55rem 0.4rem; background: #f5f5f4; color: #44403c; }
.el-btn.is-all { background: #fde68a; color: #78350f; flex: 1.4; }
.el-btn.is-ok { background: #059669; color: #fff; }

/* narrow phone: icon + name + ✕ on the first row, the buttons on a second row (4 buttons + the name don't fit) */
@media (max-width: 420px) {
  #editSelBar { flex-wrap: wrap; row-gap: 0.3rem; }
  .edit-sel-name { flex-basis: calc(100% - 5rem); }
  .edit-sel-x { order: 1; }
  .edit-sel-btn { order: 2; flex: 1 1 auto; }
}

/* Edit panel: how many pieces wait in storage */
.edit-card { position: relative; touch-action: pan-x; }
.edit-card-stock { position: absolute; top: -0.35rem; right: -0.2rem; background: #0ea5e9; color: #fff; font-size: 0.6rem; font-weight: 900; border-radius: 999px; padding: 0.05rem 0.35rem; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
