/* Base layout, HUD chips, tray, panels, dev panel, toasts, coach overlay */
/* Layout: full-bleed isometric canvas; carved-wood HUD top, stone tray bottom, info slab right. Single committed look (sunlit savanna). */
:root {
  --wood: #6b4423;
  --wood-hi: #8a5a2f;
  --wood-lo: #4a2d16;
  --stone: #e9e1d1;
  --stone-lo: #cfc3ac;
  --ink: #2b1d10;
  --muted: #7b6650;
  --leaf: #4f8a2b;
  --ember: #e0672b;
  --sky: #7fa64a;
  --bad: #c2412d;
  --display: 'Rubik Dirt', 'Rubik', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Rubik', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
html,
body {
  height: 100%;
}
body {
  background: var(--sky);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#app {
  position: fixed;
  inset: 0;
}
canvas#c {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-bottom: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.logo {
  font-family: var(--display);
  font-size: 24px;
  color: #fff6e0;
  letter-spacing: 0.5px;
  text-shadow:
    0 2px 0 var(--wood-lo),
    0 4px 10px rgba(0, 0, 0, 0.3);
  margin-right: auto;
}
.chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--wood);
  color: #fff1d6;
  border: 2px solid var(--wood-lo);
  border-radius: 10px 14px 9px 13px;
  padding: 5px 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow:
    inset 0 2px 0 var(--wood-hi),
    0 3px 0 var(--wood-lo);
}
.chip small {
  font-weight: 600;
  opacity: 0.75;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.coin {
  width: 16px;
  height: 16px;
  background: url("../assets/ui/icons/shell.webp")
    center/contain no-repeat;
  display: inline-block;
  vertical-align: -3px;
  transform: scale(1.3);
}
.stars {
  color: #ffd35a;
  letter-spacing: 1px;
}
.chip button,
.btn {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--wood-lo);
  background: var(--wood-hi);
  color: #fff1d6;
  border-radius: 8px;
  padding: 3px 9px;
  box-shadow: 0 2px 0 var(--wood-lo);
}
.chip button[aria-pressed='true'] {
  background: var(--ember);
  border-color: #8f3a12;
}
button:focus-visible {
  outline: 3px solid #ffd35a;
  outline-offset: 2px;
}
.btn.alt {
  background: var(--stone);
  color: var(--ink);
  border-color: var(--stone-lo);
}
.btn.danger {
  background: var(--bad);
  border-color: #7d2416;
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.tray {
  pointer-events: auto;
  max-width: 980px;
  margin: 0 auto;
  background: var(--stone);
  border: 2px solid var(--stone-lo);
  border-radius: 16px 20px 14px 18px;
  box-shadow:
    0 6px 0 var(--stone-lo),
    0 12px 30px rgba(40, 25, 10, 0.25);
  overflow: hidden;
}
.tabs {
  display: flex;
  gap: 2px;
  background: var(--stone-lo);
  padding: 4px 4px 0;
  overflow-x: auto;
}
.tab {
  font: inherit;
  font-weight: 700;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected='true'] {
  background: var(--stone);
  color: var(--ink);
}
.items {
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.item {
  flex: 0 0 auto;
  width: 104px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  background: #fffaf0;
  border: 2px solid var(--stone-lo);
  border-radius: 12px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--ink);
}
.item img,
.tool-ico {
  width: 100%;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: #dfeccf;
}
.tool-ico {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 26px;
  color: var(--wood);
  background: #efe4cc;
}
.item b {
  font-size: 12.5px;
  line-height: 1.1;
}
.item span {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.item[aria-pressed='true'] {
  border-color: var(--ember);
  box-shadow: 0 0 0 2px var(--ember);
}
.item.locked {
  opacity: 0.5;
}
.item.locked span {
  color: var(--bad);
}
.panel {
  position: absolute;
  left: 50%;
  top: calc(var(--hudB, 64px) + 6px);
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 290px);
  overflow: auto;
  z-index: 6;
  pointer-events: auto;
}
.panel .row {
  padding: 5px 0;
  border-bottom: 1px solid var(--stone-lo);
}
.slot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--stone-lo);
}
.slot small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.slot .acts {
  margin: 0;
}
.ach {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  border-bottom: 1px solid var(--stone-lo);
}
.ach i {
  font-style: normal;
  font-size: 20px;
  line-height: 1;
}
.ach.lock {
  opacity: 0.45;
}
.ach small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.event {
  border-color: var(--ember);
  box-shadow: 0 4px 0 #b4501f;
}
.event .acts .btn {
  flex: 1 1 auto;
}
.event .bar {
  height: 10px;
}
textarea.code {
  width: 100%;
  min-height: 60px;
  font:
    12px ui-monospace,
    monospace;
  border: 1px solid var(--stone-lo);
  border-radius: 8px;
  padding: 6px;
  background: #fffaf0;
  color: var(--ink);
}
.plotTip {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  background: rgba(74, 45, 22, 0.92);
  color: #fff1d6;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 10px;
  white-space: nowrap;
  z-index: 4;
}
.plotTip.bad {
  background: rgba(150, 40, 30, 0.92);
}
.dev {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  top: var(--hudB, 64px);
  max-height: calc(100% - var(--hudB, 64px) - 200px - env(safe-area-inset-bottom, 0px));
  width: 290px;
  overflow: auto;
  pointer-events: auto;
  background: #1f2a1a;
  color: #e8f3d8;
  border: 2px solid #4f8a2b;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 5;
}
.dev h3 {
  margin: 0 0 6px;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a8e07a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dev .g {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0 8px;
}
.dev button {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #2f4a22;
  color: #e8f3d8;
  border: 1px solid #4f8a2b;
  border-radius: 6px;
  padding: 3px 7px;
}
.dev button[aria-pressed='true'] {
  background: #e0672b;
  border-color: #8f3a12;
}
.dev input,
.dev select {
  font: inherit;
  font-size: 12px;
  background: #122010;
  color: #e8f3d8;
  border: 1px solid #4f8a2b;
  border-radius: 6px;
  padding: 3px 6px;
  width: 90px;
}
.dev label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dev .st {
  font-variant-numeric: tabular-nums;
  color: #b9d3a0;
  font-size: 12px;
  line-height: 1.5;
}
.devbadge {
  pointer-events: auto;
  background: #e0672b;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 6px;
}
.side {
  position: absolute;
  right: max(16px, env(safe-area-inset-right, 0px));
  top: var(--hudB, calc(64px + env(safe-area-inset-top, 0px)));
  width: 270px;
  max-width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.card {
  pointer-events: auto;
  background: var(--stone);
  border: 2px solid var(--stone-lo);
  border-radius: 14px 18px 12px 16px;
  padding: 10px 12px;
  box-shadow: 0 4px 0 var(--stone-lo);
}
.card h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 19px;
  margin: 0 0 4px;
  text-wrap: balance;
}
.card p {
  margin: 2px 0;
  font-size: 13.5px;
}
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  padding: 1px 0;
}
.row span:first-child {
  color: var(--muted);
}
.bar {
  height: 8px;
  background: #d8ccb4;
  border-radius: 6px;
  overflow: hidden;
  margin: 4px 0;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--leaf);
}
.bar.w i {
  background: var(--ember);
}
.acts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #d8ccb4;
  color: var(--ink);
}
.pill.run {
  background: #cfe7b9;
  color: #2c5c13;
}
.pill.broken {
  background: #f3c7bd;
  color: #7d2416;
}
.goal small {
  color: var(--muted);
  font-size: 12px;
}
#toast {
  position: absolute;
  left: 50%;
  top: calc(var(--hudB, 64px) + 6px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  max-width: calc(100% - 32px);
}
.t {
  background: var(--wood);
  color: #fff1d6;
  padding: 7px 14px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 3px 0 var(--wood-lo);
  animation: tin 0.25s ease-out;
}
.t.bad {
  background: var(--bad);
}
@keyframes tin {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}
.hint {
  position: absolute;
  left: max(16px, env(safe-area-inset-left, 0px));
  top: calc(var(--hudB, 64px) + 4px);
  max-width: 260px;
  font-size: 12.5px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}
#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--sky);
  font-family: var(--display);
  font-size: 28px;
  color: #fff6e0;
  text-shadow: 0 2px 0 var(--wood-lo);
}
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ffd35a;
  color: var(--ink);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.badge[hidden] {
  display: none;
}
body.photo .hud,
body.photo .dock,
body.photo .side,
body.photo .dev,
body.photo #toast,
body.photo .panel,
body.photo .hint,
body.photo .alerts,
body.photo .layerCard,
body.photo .plotTip {
  display: none !important;
}
.photoBar {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 9;
}
.photoBar[hidden] {
  display: none;
}
.tut {
  border-color: #4f8a2b;
  box-shadow: 0 4px 0 #2f5a1a;
}
.side,
.dock,
.panel,
#toast,
.alerts,
#coach .cbub,
.plotTip {
  zoom: var(--ui, 1);
}
/* the top bar is as wide as a small phone at 100%: it grows only while it still fits (applyUI sets --uiHud) */
.hud {
  zoom: var(--uiHud, var(--ui, 1));
}
#btnCamp.alert {
  animation: cpulse 1.1s ease-in-out infinite;
  background: #c84a2a;
  color: #fff;
}
.slot.cev {
  border-color: #c84a2a;
}
.tab.undo {
  margin-left: auto;
  min-width: 40px;
  font-size: 18px;
}
.tab.undo:disabled {
  opacity: 0.35;
}
kbd {
  font: 600 12px var(--body);
  background: #fffaf0;
  border: 1px solid var(--stone-lo);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
}
#coach {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}
#coach[hidden] {
  display: none;
}
#coach .cz {
  position: fixed;
  background: rgba(20, 11, 3, 0.6);
  pointer-events: auto;
  touch-action: none;
}
#coach .cring {
  position: fixed;
  border: 3px solid #ffd27a;
  border-radius: 12px;
  pointer-events: none;
  animation: cpulse 1.1s ease-in-out infinite;
}
#coach .chand {
  position: fixed;
  font-size: 30px;
  pointer-events: none;
  animation: cbob 0.8s ease-in-out infinite;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}
#coach .cbub {
  position: fixed;
  /* lessons.js places it by its full width (padding and border included), so it never runs off the screen */
  box-sizing: border-box;
  pointer-events: auto;
  border-color: #4f8a2b;
  box-shadow:
    0 4px 0 #2f5a1a,
    0 10px 30px rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, #e8f2d2, #d6e6b6);
}
#coach .cbub p {
  margin: 6px 0;
}
#coach .cbub .cgift {
  font-weight: 800;
  color: #3d6b1f;
}
#coach .cbub .acts {
  flex-wrap: wrap;
}
@keyframes cpulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(255, 210, 122, 0.35),
      0 0 18px rgba(255, 190, 90, 0.7);
  }
  50% {
    box-shadow:
      0 0 0 9px rgba(255, 210, 122, 0.12),
      0 0 30px rgba(255, 190, 90, 1);
  }
}
@keyframes cbob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
body.coaching #tut {
  display: none;
}
.story {
  border-color: #8a5a30;
  box-shadow: 0 4px 0 #5a3a22;
}

/* v36: the lesson pointer is the painted arrow */
#coach .chand img {
  width: 48px;
  height: 48px;
  display: block;
  filter: drop-shadow(0 3px 2px rgba(40, 20, 5, 0.4));
}
#coach .chand.up img {
  transform: rotate(180deg);
}
