html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

#activity-root { width: 100%; height: 100dvh; }

.lm-board {
  container-type: size;
  font-family: Fredoka, system-ui, sans-serif;
  color: #fff8df;
}

.lm-activity {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 1120px);
  height: 100%;
  min-height: 0;
  margin: auto;
  padding: 8px 14px 2px;
  box-sizing: border-box;
  gap: 8px;
}

.lm-feedback {
  margin: 0;
  min-height: 1.35em;
  text-align: center;
  font-size: clamp(16px, 2.3vmin, 22px);
  line-height: 1.25;
  text-shadow: 0 2px 3px #092a28;
}

.lm-pool {
  position: relative;
  min-height: 0;
  isolation: isolate;
  border-block: 2px solid #d9b85b8c;
  background: #073d3aab;
  border-radius: 36% 36% 27% 27% / 9% 9% 7% 7%;
  box-shadow: inset 0 0 22px #08272499, 0 8px 18px #04242142;
}

.lm-row {
  position: absolute;
  inset-inline: 0;
  top: calc((var(--row) + 0.5) / var(--rows) * 100%);
  height: min(148px, 94cqh / var(--rows));
  transform: translateY(-50%);
}

.lm-rows {
  position: absolute;
  inset: 6px 0 18px;
  container-type: size;
}

.lm-board .lm-lantern {
  position: absolute;
  top: 50%;
  width: auto;
  height: min(148px, 92cqh / var(--rows));
  max-width: min(110px, 18cqw);
  max-height: none;
  transform: translate(-50%, -50%);
  object-fit: contain;
  filter: hue-rotate(calc(var(--tone) * 32deg)) drop-shadow(0 6px 4px #041f25a8);
  pointer-events: none;
}

.lm-board .lm-real {
  filter: hue-rotate(calc(var(--tone) * 32deg)) brightness(0.75) saturate(0.7) drop-shadow(0 6px 4px #041f25a8);
}

.lm-board .lm-real[data-matched="true"] {
  filter: hue-rotate(calc(var(--tone) * 32deg)) brightness(1.18) drop-shadow(0 5px 8px #fff0a88c);
}

.lm-board .lm-ghost {
  opacity: 0.46;
  filter: brightness(1.4) saturate(0.2) drop-shadow(0 0 2px #fff7d5);
  outline: 2px dashed #fff2bf;
  outline-offset: -6px;
  border-radius: 36%;
}

.lm-board .lm-ghost[data-matched="true"] { opacity: 0; }

.lm-mirror {
  position: absolute;
  z-index: 3;
  top: -4px;
  bottom: -7px;
  left: var(--mirror-x);
  width: 58px;
  transform: translateX(-50%);
  touch-action: none;
  cursor: ew-resize;
}

.lm-mirror-glass {
  position: absolute;
  inset: 0 23px 23px;
  border: 2px solid #d3a84f;
  border-radius: 14px;
  background: #d6f7f1d9;
  box-shadow: 2px 0 7px #102c2a66;
}

.lm-mirror-handle {
  position: absolute;
  left: 6px;
  bottom: 0;
  width: 44px;
  height: 44px;
  border: 3px solid #a87730;
  border-radius: 50%;
  background: #ecd18b;
  box-shadow: inset 0 0 0 3px #f9e8ae, 0 4px 5px #08272485;
}

.lm-mirror-handle::before,
.lm-mirror-handle::after {
  content: '';
  position: absolute;
  top: 17px;
  width: 8px;
  height: 8px;
  border-top: 3px solid #704d25;
  border-left: 3px solid #704d25;
}

.lm-mirror-handle::before { left: 8px; transform: rotate(-45deg); }
.lm-mirror-handle::after { right: 8px; transform: rotate(135deg); }

.lm-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 82px;
}

.lm-marks {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-block: 18px 7px;
  align-self: center;
}

.lm-marks button {
  display: grid;
  place-items: center;
  width: 64px;
  height: 58px;
  padding: 0;
  border: 3px solid #b88a41;
  border-radius: 22px 22px 12px 12px;
  background: #dac589;
  box-shadow: inset 0 0 0 3px #f7e7ae, 0 5px 7px #062e2c73;
  cursor: pointer;
  touch-action: manipulation;
}

.lm-marks button[aria-pressed="true"] {
  background: #f6df98;
  border-color: #fff2b6;
  box-shadow: inset 0 0 0 3px #a4762e, 0 5px 7px #062e2c73;
}

.lm-mark-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 24px;
}

.lm-mark-glyph i {
  width: 5px;
  height: 24px;
  border-radius: 5px;
  background: #71542e;
}

.lm-marks button:active:not(:disabled) { transform: translateY(2px); }
.lm-marks button:disabled { cursor: default; }
.lm-marks button:focus-visible,
.lm-mirror:focus-visible { outline: 3px solid #fff6ce; outline-offset: 4px; }

.lm-board .lm-hand {
  position: fixed;
  z-index: 80;
  width: 48px;
  height: 62px;
  max-width: none;
  max-height: none;
  pointer-events: none;
  object-fit: contain;
}

.lm-hand[hidden] { display: none; }

@media (orientation: portrait) {
  .lm-activity { padding: 2px 3px; gap: 5px; }
  .lm-pool { border-radius: 20% 20% 16% 16% / 8% 8% 6% 6%; }
  .lm-footer { min-height: 78px; }
  .lm-marks { gap: 8px; }
  .lm-marks button { width: clamp(48px, 15cqw, 60px); height: 58px; }
  .lm-board .lm-lantern { max-width: min(96px, 22cqw); height: min(124px, 92cqh / var(--rows)); }
}

@media (orientation: portrait) and (max-height: 670px) {
  body .wm-shell-scene.wm-shell-actions-outside.wm-shell-character-paired .wm-guide-image {
    width: 72px;
    height: 66px;
    max-height: 66px;
    object-fit: contain;
  }

  .lm-feedback { font-size: 15px; }
  .lm-footer { min-height: 66px; }
  .lm-marks { padding-block: 12px 2px; }
  .lm-marks { gap: 6px; }
  .lm-marks button { width: 50px; height: 52px; }
}

@media (orientation: landscape) and (max-height: 650px) {
  .lm-activity { grid-template-columns: minmax(0, 1fr) 206px; grid-template-rows: auto minmax(0, 1fr); padding: 0 8px; column-gap: 14px; }
  .lm-feedback { grid-column: 1 / -1; font-size: 15px; }
  .lm-pool { height: 100%; }
  .lm-footer { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 0; }
  .lm-marks { display: grid; grid-template-columns: repeat(3, 54px); padding-block: 2px; gap: 6px; }
  .lm-marks button { width: 54px; height: 50px; }
  .lm-board .lm-lantern { max-width: min(72px, 12cqw); height: min(82px, 92cqh / var(--rows)); }
  .lm-board .lm-ghost { outline-offset: -1px; }
  .lm-rows { inset-block: 0; }
}
