/* The interface's look: paper cards with an ink line, flat pastel marks, nothing
   quite straight. Small and quiet on a desktop; 44 px targets on a phone.
   Owner: Interface. Colours come from src/style/palette.ts (installTheme()
   in src/ui/dom.ts sets the variables; the values here are the fallbacks). */

:root {
  --lc-ink: #3a2f2a;
  --lc-paper: #f2ede3;
  --lc-card: #fdfaf3;
  --lc-pick: #ffd96e;
  --lc-refuse: #e56b58;
  --lc-soft: rgba(58, 47, 42, 0.07);
  --lc-shadow: rgba(58, 47, 42, 0.17);
  --lc-font: ui-rounded, 'SF Pro Rounded', 'Hiragino Maru Gothic ProN', 'Nunito', 'Varela Round', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --lc-item: 54px;
}
/* Chinese: the rounded Japanese face lacks many simplified characters, and a line that mixes two faces looks
   broken; a Chinese face first (src/i18n sets <html lang>). */
:root:lang(zh) {
  --lc-font: ui-rounded, 'SF Pro Rounded', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
}

.lc-ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  font: 600 12px/1.2 var(--lc-font);
  color: var(--lc-ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.lc-ui > * {
  pointer-events: auto;
}
.lc-ui [hidden] {
  display: none !important;
}

/* ── the paper card everything sits on ─────────────────────────────────── */

.lc-card {
  background: var(--lc-card);
  border: 1.6px solid var(--lc-ink);
  border-radius: 15px 13px 16px 12px / 13px 16px 12px 15px;
  box-shadow: 1.5px 2.5px 0 var(--lc-shadow);
}

/* ── buttons ───────────────────────────────────────────────────────────── */

.lc-btn {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 1.6px solid transparent;
  border-radius: 12px 10px 13px 9px / 10px 13px 9px 12px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  touch-action: manipulation;
  transition: transform 90ms ease-out, background-color 90ms ease-out;
}
.lc-btn-icon {
  display: block;
  width: 32px;
  height: 32px;
  flex: none;
}
.lc-icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.lc-btn-label {
  font-size: 10.5px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0.82;
}
@media (hover: hover) {
  .lc-btn:hover:not(:disabled) {
    background: var(--lc-soft);
  }
}
/* The press dips the button and shrinks what is drawn in it, never the button itself: a scaled
   button measured 43 × 43 px after a tap (44 × 0.97), under the 44 px a finger needs. */
.lc-btn > * {
  transition: transform 90ms ease-out;
}
.lc-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.lc-btn:active:not(:disabled) > * {
  transform: scale(0.97);
}
.lc-btn:focus-visible,
.lc-tab:focus-visible,
.lc-swatch:focus-visible,
.lc-text-btn:focus-visible {
  outline: 2px dashed var(--lc-ink);
  outline-offset: 2px;
}
.lc-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.lc-text-btn {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 13px;
  color: var(--lc-ink);
  background: var(--lc-card);
  border: 1.6px solid var(--lc-ink);
  border-radius: 11px 9px 12px 8px / 9px 12px 8px 11px;
  padding: 7px 14px;
  min-height: 36px;
  cursor: pointer;
  touch-action: manipulation;
}
.lc-text-btn.lc-primary {
  background: color-mix(in srgb, var(--lc-pick) 62%, white);
  box-shadow: 1px 2px 0 var(--lc-shadow);
}
.lc-text-btn:active {
  transform: translateY(1px);
}

/* ── top corners ───────────────────────────────────────────────────────── */

.lc-corner {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  display: flex;
  gap: 1px;
  padding: 3px;
}
.lc-corner-left {
  left: calc(10px + env(safe-area-inset-left));
}
.lc-corner-right {
  right: calc(10px + env(safe-area-inset-right));
}
.lc-round {
  width: 38px;
  height: 38px;
}
.lc-round .lc-btn-icon {
  width: 25px;
  height: 25px;
}

/* ── the tray ──────────────────────────────────────────────────────────── */

.lc-tray {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: calc(100vw - 20px);
}

/* Drawers: folder tabs standing on the card; the open one is part of it. */
.lc-tabs {
  display: flex;
  gap: 3px;
  padding-left: 14px;
  margin-bottom: -1.6px;
  position: relative;
  z-index: 1;
  align-items: flex-end;
}
.lc-tab {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  box-sizing: border-box;
  margin: 0;
  font: inherit;
  font-size: var(--lc-tab-font, 12px);
  white-space: nowrap;
  color: var(--lc-ink);
  background: color-mix(in srgb, var(--lc-paper) 93%, var(--lc-ink));
  border: 1.6px solid var(--lc-ink);
  border-bottom-color: var(--lc-ink);
  border-radius: 10px 8px 0 0 / 9px 10px 0 0;
  padding: 4px 13px 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.lc-tab[aria-selected='true'] {
  background: var(--lc-card);
  border-bottom-color: var(--lc-card);
  padding-top: 6px;
  padding-bottom: 5px;
}
.lc-tab:not([aria-selected='true']) {
  color: color-mix(in srgb, var(--lc-ink) 72%, transparent);
}
/* The drawer that holds the selected piece keeps a small mark while another is open. */
.lc-tab-holds::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lc-pick);
  border: 1.4px solid var(--lc-ink);
}

.lc-tray-card {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 6px 7px 5px;
  max-width: 100%;
  box-sizing: border-box;
}
.lc-row {
  display: flex;
  gap: 2px;
  /* Every drawer is as wide as the fullest one, so the tray does not jump about. */
  width: calc(var(--lc-slots, 10) * (var(--lc-item) + 2px) - 2px);
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 3px 1px 1px;
}
.lc-row::-webkit-scrollbar {
  display: none;
}
.lc-item {
  width: var(--lc-item);
  height: 56px;
  flex: none;
}
.lc-item.lc-group-after {
  /* The Land group (Raise, Dig, Level) is set off from the Nature pieces by a pencilled gap. */
  margin-left: 9px;
  position: relative;
  overflow: visible;
}
.lc-item.lc-group-after::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 8px;
  bottom: 8px;
  border-left: 1.5px dashed color-mix(in srgb, var(--lc-ink) 35%, transparent);
}
.lc-item[aria-pressed='true'] {
  background: color-mix(in srgb, var(--lc-pick) 58%, white);
  border-color: var(--lc-ink);
  box-shadow: 1px 2px 0 var(--lc-shadow);
  transform: translateY(-2px) rotate(-1.6deg);
}
.lc-item[aria-pressed='true'] .lc-btn-label {
  opacity: 1;
}
.lc-tray-side {
  display: flex;
  align-items: center;
  flex: none;
  padding-left: 6px;
  border-left: 1.5px dashed color-mix(in srgb, var(--lc-ink) 35%, transparent);
}
.lc-swatch-btn {
  width: var(--lc-item);
  height: 56px;
}
.lc-dot {
  display: block;
  width: 24px;
  height: 24px;
  margin: 3px;
  border-radius: 50% 46% 52% 48% / 48% 52% 46% 50%;
  border: 1.8px solid var(--lc-ink);
  box-sizing: border-box;
}

/* Held length: a small − n + standing on the tray's right shoulder, like a tab. */
.lc-stepper {
  position: absolute;
  right: 12px;
  top: -6px;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 1px 2px;
  border-radius: 11px 9px 12px 8px / 9px 12px 8px 11px;
  transform: rotate(0.6deg);
}
.lc-step {
  width: 28px;
  height: 28px;
}
/* The first-use note over the stepper: what scrolling (or − and +) does. */
.lc-step-hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 9px);
  padding: 5px 11px;
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  transform: rotate(-0.6deg);
}
.lc-step-hint::after {
  content: '';
  position: absolute;
  right: 26px;
  bottom: -6px;
  width: 9px;
  height: 9px;
  background: var(--lc-card);
  border-right: 1.6px solid var(--lc-ink);
  border-bottom: 1.6px solid var(--lc-ink);
  transform: rotate(45deg);
}
.lc-step .lc-btn-icon {
  width: 18px;
  height: 18px;
}
.lc-length-value {
  min-width: 22px;
  text-align: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* House styles: a card of tiles above the House button (design section 7, "House style"). */
.lc-styles {
  position: absolute;
  z-index: 4;
  display: flex;
  gap: 2px;
  padding: 5px 6px;
}
.lc-style {
  width: 54px;
  height: 60px;
}
.lc-style .lc-btn-icon {
  width: 38px;
  height: 38px;
}
.lc-style[aria-checked='true'] {
  background: color-mix(in srgb, var(--lc-pick) 58%, white);
  border-color: var(--lc-ink);
  box-shadow: 1px 2px 0 var(--lc-shadow);
}
.lc-style[aria-checked='true'] .lc-btn-label {
  opacity: 1;
}
.lc-style:focus-visible {
  outline: 2px dashed var(--lc-ink);
  outline-offset: 1px;
}

/* How many pieces the held run will place, beside the mouse. */
.lc-count {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none !important;
  padding: 1px 7px 2px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--lc-pick) 58%, white);
  border: 1.5px solid var(--lc-ink);
  border-radius: 9px 8px 10px 7px / 8px 10px 7px 9px;
  box-shadow: 1px 2px 0 var(--lc-shadow);
  white-space: nowrap;
}

/* ── pop-ups: colours, the menu ────────────────────────────────────────── */

.lc-pop {
  background: var(--lc-card);
  border: 1.6px solid var(--lc-ink);
  border-radius: 14px 12px 15px 11px / 12px 15px 11px 14px;
  box-shadow: 2px 3px 0 var(--lc-shadow);
}
.lc-swatches {
  position: absolute;
  right: 0;
  bottom: calc(100% - 24px);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 9px 10px;
  z-index: 3;
}
.lc-swatch {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1.7px solid var(--lc-ink);
  border-radius: 50% 46% 52% 48% / 48% 52% 46% 50%;
  background: var(--c, none);
  cursor: pointer;
  touch-action: manipulation;
}
.lc-swatch-auto {
  border: none;
  border-radius: 50%;
}
.lc-swatch[aria-pressed='true'] {
  box-shadow: 0 0 0 2.5px var(--lc-card), 0 0 0 4.3px var(--lc-ink);
}

.lc-menu {
  position: absolute;
  top: calc(60px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  min-width: 218px;
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 4;
}
.lc-menu-item {
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 5px 14px 5px 8px;
  font-size: 13.5px;
  text-align: left;
}
.lc-menu-item .lc-btn-icon {
  width: 25px;
  height: 25px;
}
.lc-menu-item .lc-btn-label {
  font-size: inherit;
  opacity: 1;
}
.lc-menu-volume {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 3px 14px 3px 8px;
  font-size: 13.5px;
}
.lc-menu-volume .lc-btn-icon {
  width: 25px;
  height: 25px;
  flex: none;
}
.lc-menu-volume-label {
  flex: none;
  /* Room for "Sounds"; a longer name in another language (German "Geräusche") takes what it needs. */
  min-width: 52px;
  white-space: nowrap;
}
.lc-menu-volume input[type='range'] {
  flex: 1;
  min-width: 84px;
  height: 22px;
  margin: 0;
  accent-color: var(--lc-ink);
  cursor: pointer;
}
.lc-menu-volume-off {
  opacity: 0.5;
}
.lc-menu-rule {
  height: 0;
  margin: 4px 8px;
  border-top: 1.5px dashed color-mix(in srgb, var(--lc-ink) 30%, transparent);
}
.lc-confirm {
  padding: 8px 10px 6px;
  max-width: 250px;
}
.lc-confirm p {
  margin: 0 0 4px;
  font-size: 14px;
}
.lc-confirm small {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
}
.lc-choice .lc-menu-item {
  margin-left: -6px;
  width: calc(100% + 12px);
}
.lc-choice .lc-confirm-buttons {
  margin-top: 8px;
}
.lc-confirm-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* The kind screens (what kind of island, what kind of town): rows a finger can hit; nine town
   kinds in two columns, Surprise me across both, so the list fits a phone. */
.lc-kinds-wide {
  max-width: none;
}
.lc-kinds .lc-menu-item {
  min-height: 44px;
}
.lc-kinds small {
  margin-bottom: 6px;
}
.lc-kind-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2px;
  margin: 0 -6px;
}
.lc-kind-grid .lc-menu-item {
  margin-left: 0;
  width: 100%;
  padding-right: 8px;
}
.lc-kind-grid .lc-kind-any {
  grid-column: 1 / -1;
}
/* A kind this island cannot grow: greyed; hovering or pressing it says why. One still being asked about waits the same way. */
.lc-kinds .lc-menu-item:disabled,
.lc-kinds .lc-menu-item[aria-disabled='true'] {
  opacity: 0.32;
}
.lc-kinds .lc-menu-item[aria-disabled='true'] {
  cursor: help;
}
.lc-kinds small.lc-kind-why {
  margin: 6px 2px 0;
  max-width: 300px;
}
/* A search under way: its row's icon bobs; the other rows wait. */
.lc-working .lc-menu-item:not(.lc-busy) {
  pointer-events: none;
  opacity: 0.45;
}
.lc-busy .lc-btn-icon {
  animation: lc-busy 0.7s ease-in-out infinite alternate;
}
@keyframes lc-busy {
  from { transform: translateY(1px) rotate(-6deg); }
  to { transform: translateY(-2px) rotate(6deg); }
}

/* ── My towns ──────────────────────────────────────────────────────────── */

.lc-towns-back {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  box-sizing: border-box;
  background: color-mix(in srgb, var(--lc-ink) 26%, transparent);
  pointer-events: auto;
}
.lc-towns-back[hidden] {
  display: none;
}
.lc-towns {
  width: min(820px, 100%);
  max-height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 16px;
}
.lc-towns-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 4px 12px;
}
.lc-towns-head h2 {
  margin: 0;
  font-size: 20px;
}
.lc-towns-head small {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0.75;
}
.lc-towns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 4px;
  margin: -4px;
  overscroll-behavior: contain;
}
.lc-towns-wait {
  grid-column: 1 / -1;
  margin: 24px 0;
  text-align: center;
  opacity: 0.7;
}
.lc-town-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px;
  border: 1.6px solid var(--lc-ink);
  border-radius: 13px 11px 14px 10px / 11px 14px 10px 13px;
  background: var(--lc-paper);
  box-shadow: 1px 2px 0 var(--lc-shadow);
  min-width: 0;
}
.lc-town-here {
  box-shadow: 0 0 0 3px var(--lc-pick), 1px 2px 0 var(--lc-shadow);
}
.lc-town-pic {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 8 / 5;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 1.4px solid var(--lc-ink);
  border-radius: 9px 8px 10px 7px / 8px 10px 7px 9px;
  background: color-mix(in srgb, var(--lc-card) 60%, #bfe0ea);
  cursor: pointer;
  touch-action: manipulation;
}
.lc-town-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lc-town-pic svg {
  width: 46%;
  height: auto;
}
.lc-town-pic:hover img,
.lc-town-pic:focus-visible img {
  transform: scale(1.04);
}
.lc-town-pic img {
  transition: transform 140ms ease-out;
}
.lc-town-name {
  width: 100%;
  box-sizing: border-box;
  margin: 2px 0 0;
  padding: 3px 5px;
  border: 1.4px solid transparent;
  border-radius: 7px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  user-select: text;
  -webkit-user-select: text;
}
.lc-town-name:hover {
  border-color: color-mix(in srgb, var(--lc-ink) 25%, transparent);
}
.lc-town-name:focus {
  outline: none;
  border-color: var(--lc-ink);
  background: var(--lc-card);
}
.lc-town-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 2px 0 5px;
  font-size: 12px;
  font-weight: 500;
  min-height: 30px;
}
.lc-town-meta > span {
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lc-town-meta > .lc-town-tag {
  opacity: 1;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--lc-pick);
}
.lc-town-tools {
  display: flex;
  gap: 2px;
}
.lc-town-tool {
  width: 30px;
  height: 30px;
}
.lc-town-tool .lc-btn-icon {
  width: 21px;
  height: 21px;
}
.lc-town-new {
  appearance: none;
  -webkit-appearance: none;
  align-items: center;
  justify-content: flex-start;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-style: dashed;
  background: var(--lc-card);
}
.lc-town-new .lc-town-pic {
  border-style: dashed;
  pointer-events: none;
}
.lc-town-new-label {
  padding: 5px 0;
  font-size: 14px;
  font-weight: 700;
}
.lc-town-ask {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--lc-card) 94%, transparent);
}
.lc-town-ask p {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.lc-town-ask small {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
}
@media (max-width: 520px) {
  .lc-towns-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .lc-town-name {
    font-size: 13px;
  }
}

/* ── messages ──────────────────────────────────────────────────────────── */

.lc-toasts {
  position: absolute;
  /* Above My towns (z-index 8): a town that cannot be opened says so over the sheet. */
  z-index: 9;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: max-content;
  max-width: min(calc(100vw - 130px), 440px);
}
.lc-toast {
  padding: 7px 14px;
  font-size: 13px;
  text-align: center;
  animation: lc-toast 3.2s ease-in-out forwards;
}
.lc-banner {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 8px 12px;
  font-size: 13px;
}
.lc-link-box {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.lc-link-box input {
  font: 500 12px/1.3 ui-monospace, monospace;
  width: min(70vw, 340px);
  padding: 6px 8px;
  border: 1.5px solid var(--lc-ink);
  border-radius: 8px;
  background: #fff;
  color: var(--lc-ink);
  user-select: text;
  -webkit-user-select: text;
}

/* A refusal, said quietly where it happened. */
.lc-puff {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none !important;
  padding: 3px 9px 4px;
  font-size: 11.5px;
  white-space: nowrap;
  background: var(--lc-card);
  border: 1.5px solid var(--lc-refuse);
  color: color-mix(in srgb, var(--lc-refuse) 60%, var(--lc-ink));
  border-radius: 10px 8px 11px 7px / 8px 11px 7px 10px;
  animation: lc-puff 1.25s ease-out forwards;
}

/* The ✨ over Auto blocks while the Change tool is selected. */
.lc-markers {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none !important;
}
.lc-marker {
  position: absolute;
  left: -11px;
  top: -11px;
  width: 22px;
  height: 22px;
  will-change: transform;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.9));
}
.lc-marker .lc-icon {
  animation: lc-twinkle 1.7s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}

/* ── the tuning panel (dev) and its sliders ────────────────────────────── */

.lc-tuning {
  position: absolute;
  top: calc(60px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  bottom: 150px;
  width: min(300px, calc(100vw - 20px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 8px 4px 8px 10px;
  z-index: 3;
}
.lc-tuning-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 6px 0;
  font-size: 13.5px;
}
.lc-tuning-head span {
  flex: 1;
}
.lc-sliders {
  overflow-y: auto;
  padding-right: 6px;
  font-weight: 500;
  font-size: 12px;
  user-select: text;
  -webkit-user-select: text;
}
.lc-sliders details {
  border-top: 1.5px dashed color-mix(in srgb, var(--lc-ink) 28%, transparent);
  padding: 5px 0;
}
.lc-sliders summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 12.5px;
  padding: 2px 0;
}
.lc-slider {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) 46px;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}
.lc-slider > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lc-slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}
.lc-slider.lc-changed > span:first-child {
  text-decoration: underline wavy color-mix(in srgb, var(--lc-refuse) 80%, transparent);
  text-underline-offset: 2px;
}
.lc-slider input[type='range'] {
  width: 100%;
  margin: 0;
  accent-color: var(--lc-ink);
}
.lc-slider input[type='number'],
.lc-slider input[type='text'] {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 2px 5px;
  border: 1.4px solid color-mix(in srgb, var(--lc-ink) 55%, transparent);
  border-radius: 6px;
  background: #fff;
  color: var(--lc-ink);
}
.lc-slider input[type='color'] {
  width: 26px;
  height: 22px;
  padding: 0;
  border: 1.4px solid var(--lc-ink);
  border-radius: 6px;
  background: none;
}
.lc-slider .lc-colors {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

/* ── phones ────────────────────────────────────────────────────────────── */

@media (pointer: coarse), (max-width: 640px) {
  :root {
    --lc-item: 58px;
  }
  .lc-round {
    width: 44px;
    height: 44px;
  }
  .lc-round .lc-btn-icon {
    width: 27px;
    height: 27px;
  }
  .lc-tray {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    transform: none;
    max-width: none;
    align-items: stretch;
  }
  .lc-tabs {
    padding-left: 12px;
    padding-right: 12px;
    gap: 4px;
  }
  .lc-tab {
    /* Shares the row by the length of each name (languages differ), and tray.ts shrinks them all when they do not fit. */
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 0 6px;
    font-size: var(--lc-tab-font, 13.5px);
  }
  .lc-tab[aria-selected='true'] {
    min-height: 47px;
    padding: 0 6px;
  }
  .lc-tray-card {
    padding: 6px 6px 6px 7px;
  }
  /* One row that scrolls sideways; it fades at the right to say there is more. */
  .lc-row {
    flex: 1;
    width: auto;
    padding-right: 20px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }
  .lc-item {
    height: 62px;
    scroll-snap-align: start;
  }
  .lc-item .lc-btn-icon {
    width: 33px;
    height: 33px;
  }
  .lc-swatch-btn {
    height: 62px;
    width: 52px;
  }
  .lc-btn-label {
    font-size: 11px;
  }
  .lc-swatches {
    display: grid;
    grid-template-columns: repeat(5, 44px);
    gap: 6px;
    padding: 9px;
    bottom: calc(100% + 6px);
  }
  .lc-swatch {
    width: 44px;
    height: 44px;
  }
  .lc-styles {
    display: grid;
    grid-template-columns: repeat(4, 58px);
    gap: 4px;
    padding: 7px;
  }
  .lc-style {
    width: 58px;
    height: 62px;
  }
  .lc-stepper {
    right: 12px;
    top: auto;
    bottom: calc(100% + 6px);
    transform: none;
    padding: 2px 3px;
  }
  .lc-step {
    /* Never let the flex row shave a fraction of a pixel off a touch target. */
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .lc-step .lc-btn-icon {
    width: 24px;
    height: 24px;
  }
  .lc-length-value {
    min-width: 28px;
    font-size: 16px;
  }
  .lc-menu-item {
    min-height: 46px;
    font-size: 15px;
  }
  .lc-text-btn {
    min-height: 44px;
    font-size: 14.5px;
  }
  .lc-tuning {
    bottom: 140px;
  }
  .lc-toasts {
    top: calc(108px + env(safe-area-inset-top));
    max-width: calc(100vw - 24px);
  }
}

/* ── motion ────────────────────────────────────────────────────────────── */

.lc-shake {
  animation: lc-shake 0.34s ease-in-out;
}
@keyframes lc-shake {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  20% { translate: -4px 0; rotate: -4deg; }
  40% { translate: 4px 0; rotate: 4deg; }
  60% { translate: -3px 0; rotate: -2deg; }
  80% { translate: 2px 0; rotate: 1deg; }
}
@keyframes lc-toast {
  0% { opacity: 0; translate: 0 -6px; }
  7%, 86% { opacity: 1; translate: 0 0; }
  100% { opacity: 0; translate: 0 -4px; }
}
@keyframes lc-puff {
  0% { opacity: 0; translate: 0 4px; }
  12%, 70% { opacity: 1; translate: 0 0; }
  100% { opacity: 0; translate: 0 -10px; }
}
@keyframes lc-twinkle {
  0%, 100% { scale: 1; rotate: 0deg; }
  50% { scale: 0.72; rotate: 14deg; }
}
/* ── fly mode (src/ui/fly.ts) ──────────────────────────────────────────── */
/* Look only: everything for building goes; toasts stay, banners wait until the eye lands. */
.lc-ui.lc-flying > *:not(.lc-fly):not(.lc-toasts),
.lc-ui.lc-flying .lc-banner {
  display: none !important;
}
.lc-fly {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}
/* The way out, small and out of the way in the bottom corner. */
.lc-fly-hint {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 11px;
  border-radius: 10px;
  font-weight: 500;
  opacity: 0.88;
  pointer-events: none;
  white-space: nowrap;
}
.lc-fly-hint b {
  font-weight: 700;
}
/* Touch: the way out, top left; a stick at the bottom left (it comes to the thumb). */
.lc-fly-land {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  min-width: 72px;
  min-height: 46px;
  font-size: 15px;
}
.lc-fly-stick {
  position: absolute;
  left: calc(30px + env(safe-area-inset-left));
  bottom: calc(34px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  width: 104px; /* twice STICK.radius (src/fly/thumbs.ts) */
  height: 104px;
  border: 1.8px solid var(--lc-ink);
  border-radius: 50%;
  background: color-mix(in srgb, var(--lc-card) 40%, transparent);
  opacity: 0.55;
  pointer-events: none;
}
.lc-fly-knob {
  position: absolute;
  inset: 25px;
  border: 1.8px solid var(--lc-ink);
  border-radius: 50%;
  background: var(--lc-card);
  box-shadow: 1px 2px 0 var(--lc-shadow);
}
.lc-fly-held {
  opacity: 0.9;
}
.lc-fly-look {
  position: absolute;
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(70px + env(safe-area-inset-bottom));
  padding: 6px 12px;
  font-size: 13.5px;
  opacity: 0.85;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .lc-marker .lc-icon, .lc-shake, .lc-busy .lc-btn-icon { animation: none; }
  .lc-btn { transition: none; }
}

/* ── the keys, very small in the bottom corner (keyboards only) ─────────── */

.lc-keys {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(9px + env(safe-area-inset-bottom));
  display: flex;
  gap: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--lc-ink);
  opacity: 0.5;
  pointer-events: none;
  white-space: nowrap;
}
.lc-key {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.lc-key kbd {
  font: inherit;
  font-weight: 700;
  padding: 0 4px;
  border: 1.2px solid var(--lc-ink);
  border-radius: 5px 4px 5px 4px;
  background: var(--lc-card);
}
/* No keyboard, or no room beside the tray: none. */
@media (pointer: coarse), (max-width: 980px) {
  .lc-keys { display: none; }
}

/* ── the tip jar: a small cup and "Buy me a coffee" (src/ui/interface.ts) ── */

.lc-coffee {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(9px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--lc-ink);
  text-decoration: none;
  text-underline-offset: 2px;
  white-space: nowrap;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}
.lc-coffee .lc-icon {
  width: 20px;
  height: 20px;
}
.lc-coffee:hover,
.lc-coffee:focus-visible {
  opacity: 1;
  text-decoration: underline;
}
.lc-coffee:active {
  transform: translateY(1px);
}
/* Where the tray reaches the corners: under the left buttons instead (the menu, then the guide). */
@media (max-width: 940px) {
  .lc-coffee {
    right: auto;
    bottom: auto;
    left: calc(10px + env(safe-area-inset-left));
    top: calc(118px + env(safe-area-inset-top));
  }
  /* The first-visit note sits beside the buttons there: the cup waits until it is closed. */
  .lc-ui:has(.lc-welcome:not(.lc-welcome-mini)) .lc-coffee { display: none; }
}
/* A phone: in the menu instead (its last row, menu.ts). */
.lc-phone .lc-coffee { display: none; }

/* ── first-visit welcome note: a closable card beside the menu button ──── */

.lc-welcome {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + 38px + 6px + 3.2px + 10px + env(safe-area-inset-left));
  box-sizing: border-box;
  width: 264px;
  padding: 10px 34px 11px 13px;
  pointer-events: auto;
}
.lc-welcome strong {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 3px;
}
.lc-welcome p {
  margin: 0 0 9px;
  font-size: 13px;
  line-height: 1.35;
}
.lc-welcome .lc-text-btn {
  font-size: 13.5px;
}
.lc-welcome-close {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 30px;
  height: 30px;
  opacity: 0.7;
}
.lc-welcome-close .lc-btn-icon {
  width: 16px;
  height: 16px;
}
@media (max-width: 640px), (pointer: coarse) {
  /* Phones: under the top row, beside the guide button, clear of the buttons at top right. */
  .lc-welcome {
    top: calc(10px + 44px + 6px + 3.2px + 7px + env(safe-area-inset-top));
    left: calc(10px + 44px + 6px + 3.2px + 10px + env(safe-area-inset-left));
    right: calc(10px + env(safe-area-inset-right));
    width: auto;
    max-width: 300px;
  }
  .lc-welcome .lc-text-btn {
    min-height: 44px;
  }
  .lc-welcome-close {
    width: 44px;
    height: 44px;
  }
}

/* ── a phone starts with the least (src/ui/interface.ts sets .lc-phone) ─── */

.lc-sky { display: none; }
.lc-phone .lc-sky { display: flex; }
.lc-phone .lc-corner-right:not(.lc-sky-open) > :is([data-ui='time'], [data-ui='season'], [data-ui='weather']) { display: none; }
/* Nothing to undo or redo: nothing there. */
.lc-phone .lc-corner-right > :is([data-ui='undo'], [data-ui='redo']):disabled { display: none; }
/* Open, the three take the room. */
.lc-phone .lc-sky-open > :is([data-ui='undo'], [data-ui='redo'], [data-ui='fly']) { display: none; }
.lc-phone .lc-sky-open > .lc-sky .lc-btn-icon { width: 18px; height: 18px; opacity: 0.7; }
/* The guide is in the menu. */
.lc-phone .lc-corner-guide { display: none; }
.lc-phone .lc-toasts { top: calc(72px + env(safe-area-inset-top)); }

.lc-phone .lc-welcome-mini {
  position: absolute;
  top: auto;
  right: auto;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  padding: 6px 7px 6px 14px;
}
.lc-welcome-said {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.lc-phone .lc-welcome-mini .lc-text-btn {
  flex: none;
  white-space: nowrap;
}
.lc-phone .lc-welcome-mini .lc-text-btn {
  padding-left: 12px;
  padding-right: 12px;
}
/* The length stepper sits in the same place: the card goes above it. */
.lc-phone .lc-tray:has(.lc-stepper:not([hidden])) .lc-welcome-mini { bottom: calc(100% + 68px); }
.lc-phone .lc-tray:has(.lc-welcome-mini) .lc-step-hint { display: none; }
/* A phone on its side: over the sky, between the corners, not over the town. */
@media (max-height: 500px) {
  .lc-phone .lc-tray .lc-welcome-mini,
  .lc-phone .lc-tray:has(.lc-stepper:not([hidden])) .lc-welcome-mini { position: fixed; top: calc(10px + env(safe-area-inset-top)); bottom: auto; }
}
/* A menu taller than the window scrolls (X's own browser on an iPhone is 570 px high: the sound could not be reached). */
.lc-menu {
  max-height: calc(100dvh - 76px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
