:root {
  --paper: #e6d7b6;
  --paper-deep: #d7c39b;
  --ink: #30251a;
  --ink-soft: #675640;
  --panel: rgba(245, 237, 216, 0.92);
  --panel-border: rgba(76, 55, 30, 0.18);
  --accent: #8f6b35;
  --accent-soft: #b88b47;
  --water: #92a8ad;
  --water-deep: #6e8691;
  --shadow: rgba(37, 25, 12, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Baskerville, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(circle at top, rgba(255, 245, 220, 0.9), transparent 36%),
    linear-gradient(160deg, #7b674b, #4d3f2d 48%, #2f2419 100%);
}

html[data-route="play"] #editor-shell {
  display: none;
}

html[data-route="editor"] #play-view {
  display: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 18px;
}

.control-panel,
.map-frame {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: 0 24px 60px var(--shadow);
  overflow: hidden;
}

.control-panel {
  padding: 24px 22px;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.6), transparent 28%),
    linear-gradient(180deg, rgba(247, 241, 226, 0.97), rgba(232, 220, 192, 0.94));
  backdrop-filter: blur(8px);
}

.mode-row {
  display: flex;
  justify-content: flex-start;
}

.map-panel {
  display: flex;
  min-width: 0;
}

.map-frame {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(circle at top left, rgba(250, 244, 226, 0.65), transparent 25%),
    linear-gradient(180deg, rgba(244, 235, 210, 0.96), rgba(224, 208, 176, 0.98));
}

.panel-header h1,
.info-card h2,
.world-title {
  margin: 0;
  font-family: "Book Antiqua", Baskerville, Georgia, serif;
  letter-spacing: 0.03em;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--accent);
}

.intro {
  margin: 10px 0 0;
  line-height: 1.25;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.controls {
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field-header,
.seed-row,
.button-row,
.map-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.map-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.zoom-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(111, 86, 47, 0.12);
  border: 1px solid rgba(79, 56, 27, 0.12);
  color: var(--ink-soft);
  font-weight: 600;
}

.field-label {
  font-size: 1rem;
  font-weight: 600;
}

.field-value {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(66, 48, 23, 0.18);
  border-radius: 12px;
  background: rgba(255, 250, 239, 0.8);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-soft);
}

.seed-row {
  align-items: stretch;
}

.seed-row input {
  flex: 1;
}

.button-row {
  margin-top: 18px;
}

.form-section-heading {
  margin: 18px 0 12px;
  color: var(--accent);
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mode-button {
  min-width: 92px;
}

.primary-button,
.ghost-button {
  border-radius: 999px;
  border: 1px solid rgba(79, 56, 27, 0.2);
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-button {
  color: #f9f4e8;
  background: linear-gradient(180deg, #9b7643, #72532a);
  box-shadow: 0 8px 18px rgba(65, 45, 19, 0.18);
}

.ghost-button {
  background: rgba(255, 250, 238, 0.6);
  color: var(--ink);
}

.ghost-button:disabled {
  opacity: 0.48;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.toggle-button[data-active="true"] {
  background: linear-gradient(180deg, rgba(164, 127, 66, 0.92), rgba(117, 84, 35, 0.96));
  color: #f9f4e8;
  border-color: rgba(79, 56, 27, 0.34);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(65, 45, 19, 0.16);
}

.info-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 249, 234, 0.55);
  border: 1px solid rgba(90, 68, 36, 0.12);
}

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin: 0;
}

.stats dt {
  color: var(--ink-soft);
}

.stats dd {
  margin: 0;
  font-weight: 600;
}

.map-toolbar {
  padding: 18px 20px 12px;
}

.world-title {
  font-size: 1.4rem;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0 20px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}

canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 10 / 7;
  max-height: 100%;
  display: block;
  border-radius: 18px;
  border: 0;
  background: transparent;
  cursor: grab;
  margin-right: auto;
  margin-bottom: auto;
}

canvas[data-dragging="true"] {
  cursor: grabbing;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 2;
  min-width: 160px;
  max-width: 240px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(42, 31, 19, 0.92);
  color: #f1e9d7;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  transform: translate(14px, 14px);
}

.tooltip strong {
  display: block;
  font-size: 1rem;
}

.tooltip span {
  display: block;
  font-size: 0.92rem;
  color: rgba(241, 233, 215, 0.78);
}

.play-view {
  position: fixed;
  inset: 0;
  padding: 0;
  background: #111;
}

.play-frame {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  background: #111;
}

.play-loading {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.78);
  border: 1px solid rgba(239, 227, 198, 0.16);
  color: rgba(248, 242, 229, 0.94);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.editor-loading {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(242, 233, 214, 0.62), rgba(233, 220, 193, 0.72)),
    rgba(231, 218, 191, 0.76);
  pointer-events: none;
}

.editor-loading-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 24px;
  border-radius: 18px;
  background: rgba(248, 242, 229, 0.7);
  border: 1px solid rgba(101, 80, 51, 0.16);
  box-shadow: 0 12px 30px rgba(70, 50, 28, 0.1);
}

.editor-loading-title {
  color: rgba(74, 53, 29, 0.96);
  font-size: 0.94rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-loading-subtitle {
  color: rgba(96, 73, 44, 0.78);
  font-size: 0.84rem;
}

.play-map-legend {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(28, 22, 16, 0.62);
  border: 1px solid rgba(242, 230, 202, 0.14);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(6px);
}

.play-map-legend-title {
  color: rgba(247, 239, 221, 0.9);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.play-map-legend-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.play-map-legend .ghost-button {
  padding: 8px 12px;
  background: rgba(251, 246, 234, 0.16);
  border-color: rgba(247, 236, 210, 0.16);
  color: rgba(248, 240, 225, 0.94);
  box-shadow: none;
}

.play-map-legend .ghost-button:hover {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.play-map-legend .toggle-button[data-active="true"] {
  background: linear-gradient(180deg, rgba(164, 127, 66, 0.92), rgba(117, 84, 35, 0.96));
  color: #f9f4e8;
  border-color: rgba(247, 236, 210, 0.24);
}

#play-canvas {
  width: min(100vw, calc(100vh * 10 / 7));
  height: min(100vh, calc(100vw * 7 / 10));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 10 / 7;
  display: block;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: default;
  margin: auto;
}

.play-journey-panel {
  position: relative;
  width: min(100vw, calc(100vh * 10 / 7));
  height: min(100vh, calc(100vw * 7 / 10));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 10 / 7;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 86px 32px 32px;
  overflow: hidden;
  background: var(--journey-sky, #94c6e6);
  margin: auto;
}

.play-journey-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.play-layer {
  position: absolute;
  left: 0;
  right: 0;
}

.play-layer-sky {
  top: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 50% 14%, rgba(255, 255, 255, 0.2), transparent 24%),
    linear-gradient(180deg, var(--journey-sky-top, #a7d4ee), var(--journey-sky, #94c6e6));
}

.play-layer-sea {
  top: 42%;
  bottom: 0;
  background: var(--journey-sea-fill, #5b8397);
  overflow: hidden;
}

.play-sea-track {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.play-ground-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 64%;
  bottom: 0;
  overflow: hidden;
}

.play-ground-strip,
.play-sea-ripple,
.play-ground-stone,
.play-ground-tuft,
.play-ground-blade,
.play-ground-shrub,
.play-ground-scrub,
.play-ground-dune {
  position: absolute;
  display: block;
}

.play-ground-strip {
  left: 0;
  top: 0;
  bottom: 0;
  overflow: visible;
  will-change: transform;
  background:
    linear-gradient(
      180deg,
      var(--strip-light, #cbb991) 0%,
      var(--strip-base, #b8a278) 18%,
      var(--strip-deep, #907955) 100%
    );
}

.play-ground-strip--sea {
  background: transparent;
}

.play-poi-marker {
  position: absolute;
  left: 0;
  bottom: 26%;
  width: 0;
  height: 0;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
}

.play-poi-marker-pin {
  position: absolute;
  left: -11px;
  bottom: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(253, 246, 234, 0.96);
  border: 3px solid #3a2c1d;
  box-shadow:
    0 2px 0 rgba(34, 24, 16, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.play-poi-marker-pin::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 4px;
  height: 12px;
  border-radius: 999px;
  background: #3a2c1d;
  transform: translateX(-50%);
}

.play-poi-marker-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #3a2c1d;
  transform: translate(-50%, -50%);
}

.play-player {
  position: absolute;
  left: 15%;
  bottom: 10%;
  width: 62px;
  height: 96px;
  z-index: 1;
  pointer-events: none;
}

.play-player-shadow {
  position: absolute;
  left: 10px;
  right: 8px;
  bottom: 2px;
  height: 10px;
  border-radius: 999px;
  background: rgba(34, 24, 16, 0.18);
  filter: blur(1px);
}

.play-player-bob {
  position: absolute;
  inset: 0;
  transform-origin: 50% 100%;
}

.play-player[data-moving="true"] .play-player-bob {
  animation: player-bob 220ms steps(2, end) infinite;
}

.play-player-figure {
  position: absolute;
  left: 18px;
  bottom: 10px;
  width: 30px;
  height: 72px;
}

.play-player-torso,
.play-player-head,
.play-player-pack,
.play-player-arm,
.play-player-leg {
  position: absolute;
  display: block;
  background: #16110b;
}

.play-player-torso {
  left: 10px;
  bottom: 24px;
  width: 7px;
  height: 24px;
  border-radius: 999px;
}

.play-player-head {
  left: 12px;
  bottom: 47px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.play-player-pack {
  left: 4px;
  bottom: 29px;
  width: 9px;
  height: 16px;
  border-radius: 5px 4px 4px 6px;
}

.play-player-arm {
  width: 16px;
  height: 4px;
  border-radius: 999px;
  bottom: 39px;
  transform-origin: 2px 2px;
}

.play-player-arm--back {
  left: 4px;
  transform: rotate(162deg);
  opacity: 0.82;
}

.play-player-arm--front {
  left: 12px;
  transform: rotate(-28deg);
}

.play-player-leg {
  width: 18px;
  height: 4px;
  border-radius: 999px;
  bottom: 22px;
  transform-origin: 2px 2px;
}

.play-player-leg--back {
  left: 6px;
  transform: rotate(132deg);
  opacity: 0.84;
}

.play-player-leg--front {
  left: 11px;
  transform: rotate(38deg);
}

.play-player[data-moving="true"] .play-player-arm--back {
  animation: player-limb-back 220ms steps(2, end) infinite;
}

.play-player[data-moving="true"] .play-player-arm--front {
  animation: player-limb-front 220ms steps(2, end) infinite;
}

.play-player[data-moving="true"] .play-player-leg--back {
  animation: player-limb-front 220ms steps(2, end) infinite;
}

.play-player[data-moving="true"] .play-player-leg--front {
  animation: player-limb-back 220ms steps(2, end) infinite;
}

.play-player[data-sea="true"] {
  opacity: 0.68;
}

.play-player[data-sea="true"] .play-player-shadow {
  opacity: 0.38;
}

.play-ground-stone {
  position: absolute;
  border-radius: 999px;
  background: var(--strip-stone, rgba(92, 76, 52, 0.54));
  border: 1px solid rgba(78, 58, 36, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(246, 238, 222, 0.24),
    0 1px 0 rgba(67, 49, 28, 0.12);
  transform: rotate(-8deg);
}

.play-ground-stone::before {
  content: "";
  position: absolute;
  left: 18%;
  top: 18%;
  width: 34%;
  height: 30%;
  border-radius: 999px;
  background: rgba(248, 241, 227, 0.2);
}

.play-ground-tuft {
  position: absolute;
  transform-origin: 50% 100%;
  overflow: visible;
}

.play-ground-blade {
  bottom: 0;
  width: 3.4px;
  border-radius: 999px 999px 0 0;
  background: var(--strip-tuft, rgba(104, 93, 58, 0.62));
  box-shadow:
    inset 0 1px 0 rgba(239, 232, 210, 0.18),
    0 0 0 0.7px rgba(82, 72, 43, 0.16);
  transform-origin: 50% 100%;
}

.play-ground-shrub,
.play-ground-scrub {
  border-radius: 999px 999px 28% 28%;
  background: var(--strip-tuft, rgba(104, 93, 58, 0.62));
  box-shadow:
    inset 0 1px 0 rgba(239, 232, 210, 0.16),
    0 0 0 0.7px rgba(82, 72, 43, 0.14);
}

.play-ground-shrub::before,
.play-ground-shrub::after,
.play-ground-scrub::before,
.play-ground-scrub::after {
  content: "";
  position: absolute;
  bottom: 20%;
  width: 42%;
  height: 76%;
  border-radius: 999px;
  background: inherit;
}

.play-ground-shrub::before,
.play-ground-scrub::before {
  left: -6%;
}

.play-ground-shrub::after,
.play-ground-scrub::after {
  right: -6%;
}

.play-ground-scrub {
  transform: scale(0.84);
  opacity: 0.9;
}

.play-ground-dune {
  border-radius: 999px 999px 0 0 / 100% 100% 0 0;
  background: rgba(237, 220, 176, 0.34);
  border-top: 1px solid rgba(189, 153, 96, 0.24);
}

.play-sea-ripple {
  height: 8px;
  border-top: 1.6px solid rgba(228, 241, 246, 0.42);
  border-radius: 999px;
  opacity: 0.7;
  will-change: transform;
}

.play-sea-ripple::after {
  content: "";
  position: absolute;
  left: 24%;
  right: 24%;
  top: 2px;
  height: 4px;
  border-top: 1.2px solid rgba(237, 246, 249, 0.28);
  border-radius: 999px;
}

@keyframes player-bob {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(-6px);
  }
}

@keyframes player-limb-front {
  0% {
    transform: rotate(26deg);
  }

  100% {
    transform: rotate(52deg);
  }
}

@keyframes player-limb-back {
  0% {
    transform: rotate(148deg);
  }

  100% {
    transform: rotate(124deg);
  }
}

.play-journey-copy {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 760px;
  padding: 18px 28px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(246, 239, 221, 0.54), rgba(246, 239, 221, 0.22));
  backdrop-filter: blur(2px);
}

.play-journey-subtitle {
  font-size: 1.14rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 10px;
  margin-bottom: 16px;
}

.play-journey-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.06;
}

.play-mode-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 2;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 20, 15, 0.38);
  border: 1px solid rgba(255, 245, 225, 0.1);
  color: rgba(244, 236, 219, 0.72);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  canvas {
    width: min(100%, calc((70vh) * 1.428571));
    max-height: 70vh;
  }
}
