:root {
  --duck-orient: none;
  --bg: #efe6cf;
  --bg-mid: #d8e4c1;
  --bg-gradient: linear-gradient(175deg, #efe6cf, #d8e4c1 58%, #d0ddbc);
  --bg-radial-1: rgba(237, 150, 36, 0.16);
  --bg-radial-2: rgba(82, 143, 95, 0.14);
  --bg-radial-3: rgba(76, 128, 162, 0.12);
  --panel: rgba(255, 248, 232, 0.88);
  --panel-border: rgba(117, 96, 52, 0.24);
  --panel-shadow: rgba(74, 60, 30, 0.14);
  --panel-inset: rgba(255, 255, 255, 0.6);
  --ink: #2f2a1b;
  --ink-dim: #6f6652;

  --accent: #d17616;
  --accent-bright: #ee9628;
  --accent-glow: rgba(209, 118, 22, 0.2);
  --teal: #4a8d63;
  --danger: #b34036;
  --success: #2f8d46;

  --hud-bg: rgba(255, 255, 255, 0.55);
  --hud-border: rgba(117, 96, 52, 0.15);
  --hud-border-top: rgba(255, 255, 255, 0.5);
  --hud-shadow: rgba(74, 60, 30, 0.08);
  --hud-label: #6f6652;
  --hud-value: #2f2a1b;
  --hud-value-shadow: none;

  --btn-primary-from: #ecaa44;
  --btn-primary-to: #cb7f18;
  --btn-primary-text: #2d1b06;
  --btn-primary-shadow: #97580f;
  --btn-green-from: #7fa072;
  --btn-green-to: #628156;
  --btn-green-text: #11210f;
  --btn-green-shadow: #46603c;

  --board-bg: #a7bb86;
  --board-border: rgba(95, 83, 45, 0.25);

  --modal-bg: #fff6e2;
  --modal-border: rgba(110, 91, 51, 0.16);
  --modal-input-bg: rgba(255, 255, 255, 0.62);
  --modal-surface: rgba(255, 255, 255, 0.72);
  --modal-surface-border: rgba(110, 91, 51, 0.18);
  --modal-hover-bg: rgba(99, 84, 45, 0.1);
  --toggle-track-bg: rgba(110, 91, 51, 0.2);
  --toggle-knob: #6f6652;
  --kbd-bg: rgba(255, 255, 255, 0.06);
  --kbd-border: rgba(255, 255, 255, 0.1);

  --card-bg: rgba(255, 255, 255, 0.46);
  --card-border: rgba(69, 58, 31, 0.12);
  --card-hover: rgba(243, 184, 78, 0.2);
  --editor-card-tint: rgba(143, 165, 106, 0.16);
  --editor-card-gloss-top: rgba(255, 255, 255, 0.36);
  --editor-card-gloss-bottom: rgba(255, 255, 255, 0.14);
  --editor-control-bg-from: #b9cb9a;
  --editor-control-bg-to: #9fb283;
  --editor-control-hover-from: #c8d9a8;
  --editor-control-hover-to: #afc091;
  --editor-control-border: rgba(97, 83, 42, 0.2);
  --editor-control-shadow: rgba(83, 72, 40, 0.28);
  --editor-grid-bg: rgba(100, 120, 72, 0.28);

  --scrollbar-thumb: rgba(232, 160, 32, 0.15);
  --scrollbar-hover: rgba(232, 160, 32, 0.25);

  --title-fill: #ffe3a8;
  --title-stroke: #6b3a0f;
  --title-shadow-strong: #4d2708;
  --title-shadow-deep: #351a04;
  --title-glow-a: rgba(255, 187, 66, 0.78);
  --title-glow-b: rgba(255, 139, 33, 0.34);
  --title-glow-c: rgba(255, 187, 66, 0.32);
  --title-glow-d: rgba(255, 187, 66, 0.56);
  --title-glow-e: rgba(255, 139, 33, 0.26);

  --floor-1: #c9ad7a;
  --floor-2: #b89a68;
  --wall-1: #3c4560;
  --wall-2: #252d40;
  --water-1: #2988c4;
  --water-2: #1c6896;
  --water-hi: rgba(255, 255, 255, 0.12);
  --exit-1: #2ecc71;
  --exit-2: #25a35c;
  --exit-glow: rgba(46, 204, 113, 0.35);
  --spike-1: #8e9196;
  --spike-2: #5d636a;

  --cell-size: min(8.7vw, 54px);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-mid: #16213e;
  --bg-gradient: linear-gradient(175deg, #1a1a2e, #16213e 58%, #0f1626);
  --bg-radial-1: rgba(56, 189, 248, 0.06);
  --bg-radial-2: rgba(46, 204, 113, 0.05);
  --bg-radial-3: rgba(209, 118, 22, 0.04);
  --panel: rgba(30, 32, 48, 0.92);
  --panel-border: rgba(100, 120, 180, 0.15);
  --panel-shadow: rgba(0, 0, 0, 0.35);
  --panel-inset: rgba(255, 255, 255, 0.04);
  --ink: #e2e0dc;
  --ink-dim: #9a9690;

  --accent: #e89a38;
  --accent-bright: #f5b556;
  --accent-glow: rgba(232, 154, 56, 0.15);

  --hud-bg: rgba(30, 35, 55, 0.85);
  --hud-border: rgba(80, 110, 170, 0.18);
  --hud-border-top: rgba(255, 255, 255, 0.06);
  --hud-shadow: rgba(0, 0, 0, 0.3);
  --hud-label: rgba(186, 230, 253, 0.55);
  --hud-value: #e2e8f0;
  --hud-value-shadow: 0 0 8px rgba(56, 189, 248, 0.25);

  --btn-primary-from: #c48520;
  --btn-primary-to: #9e6414;
  --btn-primary-text: #fff0d6;
  --btn-primary-shadow: #6b4510;
  --btn-green-from: #4a7040;
  --btn-green-to: #3a5a32;
  --btn-green-text: #d4eacc;
  --btn-green-shadow: #2a4024;

  --board-bg: #2a3828;
  --board-border: rgba(60, 80, 50, 0.4);

  --modal-bg: #242438;
  --modal-border: rgba(100, 120, 180, 0.12);
  --modal-input-bg: rgba(255, 255, 255, 0.08);
  --modal-surface: rgba(33, 40, 63, 0.9);
  --modal-surface-border: rgba(100, 120, 180, 0.2);
  --modal-hover-bg: rgba(100, 120, 180, 0.12);
  --toggle-track-bg: rgba(100, 120, 180, 0.2);
  --toggle-knob: #6e7a8e;
  --kbd-bg: rgba(255, 255, 255, 0.06);
  --kbd-border: rgba(255, 255, 255, 0.1);

  --card-bg: rgba(30, 35, 55, 0.6);
  --card-border: rgba(100, 120, 180, 0.12);
  --card-hover: rgba(232, 154, 56, 0.12);
  --editor-card-tint: rgba(39, 52, 82, 0.68);
  --editor-card-gloss-top: rgba(255, 255, 255, 0.06);
  --editor-card-gloss-bottom: rgba(255, 255, 255, 0.02);
  --editor-control-bg-from: #3f537d;
  --editor-control-bg-to: #324464;
  --editor-control-hover-from: #4b618f;
  --editor-control-hover-to: #3a4d72;
  --editor-control-border: rgba(100, 120, 180, 0.28);
  --editor-control-shadow: rgba(8, 12, 22, 0.45);
  --editor-grid-bg: rgba(24, 31, 48, 0.65);

  --scrollbar-thumb: rgba(100, 120, 180, 0.2);
  --scrollbar-hover: rgba(100, 120, 180, 0.35);

  --title-fill: #bae6fd;
  --title-stroke: #0a3d5c;
  --title-shadow-strong: #072a3f;
  --title-shadow-deep: #051e2e;
  --title-glow-a: rgba(56, 189, 248, 0.7);
  --title-glow-b: rgba(14, 165, 233, 0.3);
  --title-glow-c: rgba(56, 189, 248, 0.25);
  --title-glow-d: rgba(56, 189, 248, 0.5);
  --title-glow-e: rgba(14, 165, 233, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", sans-serif;
  font-weight: 500;
  color: var(--ink);
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 14% 8%, var(--bg-radial-1) 0%, transparent 46%),
    radial-gradient(ellipse at 84% 20%, var(--bg-radial-2) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 88%, var(--bg-radial-3) 0%, transparent 45%),
    var(--bg-gradient);
}

/* ── Layout ── */

.app {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

.site-footer {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 0 1.25rem 1.25rem;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* ── Panels ── */

.topbar,
.controls,
.legend,
.board-wrap,
.editor {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow:
    0 8px 24px var(--panel-shadow),
    inset 0 1px 0 var(--panel-inset);
}

/* ── Header ── */

.topbar {
  padding: 1.2rem 1.4rem;
  display: grid;
  gap: 1rem;
}

.title-wrap {
  display: grid;
  align-content: start;
  gap: 0.55rem;
  padding-top: 0.35rem;
}

.title-wrap h1 {
  margin: 0;
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 1px;
  color: var(--title-fill);
  line-height: 1.1;
  -webkit-text-stroke: 2px var(--title-stroke);
  paint-order: stroke fill;
  text-shadow:
    1px 1px 0 var(--title-stroke),
    -1px -1px 0 var(--title-stroke),
    0 2px 0 var(--title-shadow-strong),
    0 0 10px var(--title-glow-d),
    0 0 24px var(--title-glow-e);
}

.subtitle {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.release-badge {
  display: inline-flex;
  align-items: center;
  align-self: center;
  justify-self: center;
  width: max-content;
  max-width: 100%;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(232, 154, 56, 0.22), rgba(232, 154, 56, 0.1));
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 16%, transparent);
}

.release-badge-inline {
  margin-top: 0.15rem;
}

.release-note {
  margin: 0.6rem 0 0;
  max-width: 34rem;
  color: var(--ink-dim);
  font-size: 0.84rem;
  line-height: 1.45;
}

/* ── HUD ── */

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.4rem;
}

.hud-item {
  background: var(--hud-bg);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  display: grid;
  line-height: 1.2;
  border: 1px solid var(--hud-border);
  border-top-color: var(--hud-border-top);
  box-shadow:
    inset 0 1px 0 var(--panel-inset),
    0 2px 4px var(--hud-shadow);
  position: relative;
}

.hud-item .label {
  font-family: "Outfit", sans-serif;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--hud-label);
  font-weight: 700;
}

.hud-item span:last-child {
  font-family: "Luckiest Guy", cursive;
  font-size: 1.15rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--hud-value);
  text-shadow: var(--hud-value-shadow);
}

/* ── Menu ── */

.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 70vh;
  padding: 2rem 1.5rem;
}

.menu-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.menu-duck {
  width: 4.5rem;
  height: 4.5rem;
  filter: drop-shadow(0 0 24px rgba(240, 190, 50, 0.4));
  animation: duckBob 1.5s ease-in-out infinite;
  margin-bottom: 0.5rem;
}

.slot-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

.menu-brand h1 {
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(2.5rem, 8vw, 4.2rem);
  color: var(--title-fill);
  margin: 0;
  line-height: 1.1;
  letter-spacing: 3px;
  -webkit-text-stroke: 2.5px var(--title-stroke);
  paint-order: stroke fill;
  text-shadow:
    1px 1px 0 var(--title-stroke),
    -1px -1px 0 var(--title-stroke),
    1px -1px 0 var(--title-stroke),
    -1px 1px 0 var(--title-stroke),
    0 3px 0 var(--title-shadow-strong),
    0 4px 0 var(--title-shadow-deep),
    0 0 14px var(--title-glow-a),
    0 0 40px var(--title-glow-b);
  animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
  0%, 100% {
    filter: drop-shadow(0 0 6px var(--title-glow-c));
  }
  50% {
    filter: drop-shadow(0 0 20px var(--title-glow-d))
           drop-shadow(0 0 40px var(--title-glow-e));
  }
}

.menu-tagline {
  color: var(--ink-dim);
  font-size: 0.95rem;
  max-width: 340px;
  line-height: 1.6;
  margin: 0.5rem 0 0;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 2.5rem;
  width: min(260px, 100%);
}

.menu-actions::before {
  content: "\25C6  \25C7  \25C6";
  display: block;
  text-align: center;
  color: rgba(232, 160, 32, 0.2);
  font-size: 0.5rem;
  letter-spacing: 0.4em;
  margin-bottom: 0.5rem;
}

.menu-btn {
  padding: 0.85rem 2rem;
  font-size: 0.95rem;
  border-radius: var(--radius);
  letter-spacing: 0.06em;
  width: 100%;
}

.menu-btn.primary {
  font-size: 1.1rem;
  padding: 1rem 2rem;
}

.menu-btn:not(.primary) {
  background: linear-gradient(180deg, var(--btn-green-from), var(--btn-green-to));
  color: var(--btn-green-text);
  box-shadow: 0 2px 0 var(--btn-green-shadow), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.menu-btn:not(.primary):hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 var(--btn-green-shadow), 0 6px 12px rgba(0, 0, 0, 0.25);
}

/* ── Level Select ── */

.select-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow:
    0 8px 24px var(--panel-shadow),
    inset 0 1px 0 var(--panel-inset);
  padding: 1.2rem 1.4rem;
  display: grid;
  gap: 1rem;
}

.select-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.select-header h2 {
  margin: 0;
  font-family: "Luckiest Guy", cursive;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  color: var(--accent);
  letter-spacing: 1px;
}

#select-back-btn,
#editor-back-btn {
  background: linear-gradient(180deg, var(--btn-green-from), var(--btn-green-to));
  color: var(--btn-green-text);
  box-shadow: 0 2px 0 var(--btn-green-shadow), 0 4px 8px rgba(0, 0, 0, 0.2);
}

#select-back-btn:hover,
#editor-back-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 var(--btn-green-shadow), 0 6px 12px rgba(0, 0, 0, 0.24);
}

.level-list {
  display: grid;
  gap: 0.6rem;
}

.level-card {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  gap: 0.8rem;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: all 0.15s ease;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.9rem;
}

.level-card:hover:not(:disabled) {
  background: var(--card-hover);
  border-color: var(--accent-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(72, 57, 26, 0.22);
}

.level-card:active:not(:disabled) {
  transform: translateY(0);
}

.level-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-card.completed {
  border-left: 3px solid var(--success);
}

.level-num {
  font-family: "Luckiest Guy", cursive;
  font-size: 1.5rem;
  color: var(--accent);
  text-align: center;
  line-height: 1;
}

.level-card.locked .level-num {
  color: var(--ink-dim);
}

.level-info {
  display: grid;
  gap: 0.15rem;
}

.level-name {
  font-weight: 800;
  font-size: 0.95rem;
}

.level-hint {
  font-size: 0.8rem;
  color: var(--ink-dim);
  font-weight: 500;
}

.level-best,
.level-status {
  font-size: 0.8rem;
  color: var(--ink-dim);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.view-panel {
  display: none !important;
  gap: 1rem;
}

.view-panel.active {
  display: grid !important;
}

/* ── Board ── */

.board-wrap {
  padding: 0.8rem;
  overflow: auto;
  max-height: 72vh;
  position: relative;
  background: var(--board-bg);
  border-color: var(--board-border);
  box-shadow:
    inset 0 0 24px rgba(48, 66, 38, 0.24),
    0 8px 24px rgba(67, 57, 35, 0.24);
}

.board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(232, 160, 32, 0.025) 0%,
    transparent 65%
  );
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
}

.board {
  display: grid;
  gap: 0;
  justify-content: start;
  touch-action: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

/* ── Cells ── */

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--cell-size) * 0.55);
  user-select: none;
  transition: filter 100ms ease;
  position: relative;
  image-rendering: pixelated;
}

.cell.floor {
  background: url("assets/tiles/floor.png") center / cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 2px rgba(0, 0, 0, 0.1);
}

.cell.wall {
  background: url("assets/tiles/wall.png") center / cover no-repeat;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.06),
    inset 0 -3px 0 rgba(0, 0, 0, 0.4),
    0 3px 6px rgba(0, 0, 0, 0.5);
}

.cell.water {
  background: url("assets/tiles/water.png") center / cover no-repeat;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.15);
}

.cell.exit {
  background: url("assets/tiles/exit-open.png") center / cover no-repeat;
  box-shadow: 0 0 12px var(--exit-glow);
  animation: exitPulse 2s ease-in-out infinite;
}

.cell.exit.locked {
  background-image: url("assets/tiles/exit-locked.png");
  filter: none;
  animation: none;
  box-shadow: none;
}

.cell.spikes {
  background: url("assets/tiles/spikes.png") center / cover no-repeat;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.25);
}

.cell.ice,
.editor-cell.ice {
  background: url("assets/tiles/ice.png") center / cover no-repeat;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.35);
}

.cell.cracked,
.editor-cell.cracked {
  background: url("assets/tiles/cracked.png") center / cover no-repeat;
}

.cell.hole,
.editor-cell.hole {
  background: url("assets/tiles/hole.svg") center / cover no-repeat;
  box-shadow:
    inset 0 2px 3px rgba(255, 220, 160, 0.08),
    inset 0 -8px 14px rgba(0, 0, 0, 0.72);
}

.cell.button,
.editor-cell.button {
  background: url("assets/tiles/button.png") center / cover no-repeat;
}

.cell.arrow,
.editor-cell.arrow {
  background: url("assets/tiles/arrow-right.png") center / cover no-repeat;
}

.cell.arrow[data-arrow="down"],
.editor-cell.arrow[data-arrow="down"] {
  background-image: url("assets/tiles/arrow-down.png");
}

.cell.arrow[data-arrow="left"],
.editor-cell.arrow[data-arrow="left"] {
  background-image: url("assets/tiles/arrow-left.png");
}

.cell.arrow[data-arrow="up"],
.editor-cell.arrow[data-arrow="up"] {
  background-image: url("assets/tiles/arrow-up.png");
}

.cell.open-switch-door .object {
  opacity: 0.42;
  filter: grayscale(0.4);
}

.cell.player-cell {
  outline: none;
}

/* ── Overlays ── */

.cell .overlay {
  grid-area: 1 / 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  line-height: 1;
  display: block;
}

.cell .overlay.sprite {
  width: calc(var(--cell-size) * 0.9);
  height: calc(var(--cell-size) * 0.9);
  object-fit: contain;
  image-rendering: pixelated;
}

.cell .object.sprite {
  width: calc(var(--cell-size) * 0.88);
  height: calc(var(--cell-size) * 0.88);
}

.cell .object.switch-door {
  width: var(--cell-size);
  height: var(--cell-size);
  filter: none;
}

.cell .object {
  z-index: 2;
}

.cell .enemy {
  z-index: 2;
  width: calc(var(--cell-size) * 0.94);
  height: calc(var(--cell-size) * 0.94);
}

.cell .enemy.fox {
  filter:
    drop-shadow(0 0 5px rgba(230, 130, 40, 0.45))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.cell .enemy.hawk {
  filter:
    drop-shadow(0 0 5px rgba(120, 100, 220, 0.45))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  animation: hawkSwoop 1.2s ease-in-out infinite;
}

.cell .enemy.gator {
  filter:
    drop-shadow(0 0 5px rgba(40, 180, 100, 0.45))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.cell .enemy.wolf {
  filter:
    drop-shadow(0 0 7px rgba(220, 40, 40, 0.55))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  animation: wolfPulse 0.8s ease-in-out infinite;
}

.cell .enemy.dir-left,
.editor-sprite.dir-left {
  transform: scaleX(-1);
}

.cell .enemy.dir-up,
.editor-sprite.dir-up {
  transform: rotate(-90deg);
}

.cell .enemy.dir-down,
.editor-sprite.dir-down {
  transform: rotate(90deg);
}

.cell .enemy.moving {
  animation: entitySlideTween 140ms ease-out;
}

.cell .overlay.duck {
  --duck-orient: none;
  z-index: 3;
  width: calc(var(--cell-size) * 1.02);
  height: calc(var(--cell-size) * 1.02);
  filter: none;
  animation: duckBob 1.5s ease-in-out infinite;
}

.cell .player-wrap {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  z-index: 3;
  pointer-events: none;
}

.cell .player-wrap.moving {
  animation: entitySlideTween 150ms ease-out;
}

.cell .overlay.duck.dir-right {
  --duck-orient: none;
}

.cell .overlay.duck.dir-left {
  --duck-orient: none;
}

.cell .overlay.duck.dir-up {
  --duck-orient: none;
}

.cell .overlay.duck.dir-down {
  --duck-orient: none;
}

/* ── Controls ── */

.controls {
  padding: 1rem 1.2rem 1.2rem;
  display: grid;
  gap: 0.7rem;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Buttons ── */

button {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--btn-primary-from), var(--btn-primary-to));
  color: var(--btn-primary-text);
  box-shadow:
    0 2px 0 var(--btn-primary-shadow),
    0 4px 8px rgba(0, 0, 0, 0.22);
  transition: all 80ms ease;
}

button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow:
    0 3px 0 var(--btn-primary-shadow),
    0 6px 12px rgba(0, 0, 0, 0.24);
}

button:active {
  transform: translateY(2px);
  box-shadow:
    0 0 0 var(--btn-primary-shadow),
    0 1px 3px rgba(0, 0, 0, 0.25);
  filter: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
}

#undo-btn,
#levels-btn {
  background: linear-gradient(180deg, var(--btn-green-from), var(--btn-green-to));
  color: var(--btn-green-text);
  box-shadow: 0 2px 0 var(--btn-green-shadow), 0 4px 8px rgba(0, 0, 0, 0.22);
}

#undo-btn:hover,
#levels-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 var(--btn-green-shadow), 0 6px 12px rgba(0, 0, 0, 0.24);
}

/* ── Status ── */

.status {
  margin: 0;
  min-height: 1.3em;
  font-weight: 700;
  font-size: 0.95rem;
}

.status.fresh {
  animation: statusFade 0.25s ease-out;
}

.status.warn {
  color: #ffc85c;
  text-shadow: 0 0 10px rgba(255, 200, 92, 0.12);
}

.status.danger {
  color: #ff6b7a;
  text-shadow: 0 0 10px rgba(255, 107, 122, 0.12);
}

.status.success {
  color: #5ce89a;
  text-shadow: 0 0 10px rgba(92, 232, 154, 0.12);
}

/* ── Touch Controls ── */

.touchpad {
  display: grid;
  grid-template-columns: repeat(3, 3.2rem);
  grid-template-rows: repeat(2, 3.2rem);
  gap: 4px;
  justify-content: center;
  touch-action: manipulation;
}

.touch-btn {
  border-radius: var(--radius-sm);
  padding: 0;
  font-size: 1.1rem;
  background: linear-gradient(180deg, #8da67c, #728f62);
  color: var(--ink);
  border: 1px solid rgba(76, 67, 43, 0.22);
  box-shadow: 0 2px 0 rgba(59, 65, 37, 0.36);
  text-transform: none;
  letter-spacing: 0;
}

.touch-btn:hover {
  background: linear-gradient(180deg, #9bb48a, #7e9c6d);
}

.touch-btn:active {
  background: linear-gradient(180deg, #9bb48a, #7e9c6d);
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.3);
}

.touch-up {
  grid-column: 2;
  grid-row: 1;
}

.touch-left {
  grid-column: 1;
  grid-row: 2;
}

.touch-down {
  grid-column: 2;
  grid-row: 2;
}

.touch-right {
  grid-column: 3;
  grid-row: 2;
}

/* ── Legend ── */

.legend {
  padding: 1rem 1.2rem;
}

.legend summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  transition: color 0.15s ease;
}

.legend summary:hover {
  color: var(--ink);
}

.legend summary::-webkit-details-marker {
  display: none;
}

.legend summary::after {
  content: "\25B8";
  font-size: 0.8em;
  transition: transform 0.2s ease;
}

.legend[open] summary::after {
  transform: rotate(90deg);
}

.legend[open] summary {
  margin-bottom: 0.7rem;
  color: var(--ink);
}

.legend ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.3rem 1rem;
  font-size: 0.9rem;
  color: var(--ink-dim);
}

.legend .icon {
  width: 1.6rem;
  height: 1.6rem;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  border-radius: 6px;
  background: color-mix(in srgb, var(--card-bg) 88%, transparent);
  border: 1px solid var(--card-border);
  box-shadow: inset 0 1px 0 var(--panel-inset);
  --legend-icon-scale: 0.86;
}

.legend .icon .slot-sprite {
  width: calc(1.6rem * var(--legend-icon-scale));
  height: calc(1.6rem * var(--legend-icon-scale));
  object-fit: contain;
  image-rendering: pixelated;
}

.legend .icon[data-sprite-key^="tile-"] {
  --legend-icon-scale: 1;
}

.legend .icon[data-sprite-key="duck"] {
  --legend-icon-scale: 0.8;
}

.legend .icon[data-sprite-key="fox"],
.legend .icon[data-sprite-key="hawk"],
.legend .icon[data-sprite-key="gator"],
.legend .icon[data-sprite-key="wolf"] {
  --legend-icon-scale: 0.84;
}

.legend .icon[data-sprite-key="gate"],
.legend .icon[data-sprite-key="crate"] {
  --legend-icon-scale: 0.82;
}

.legend .icon[data-sprite-key="key"],
.legend .icon[data-sprite-key="pea"],
.legend .icon[data-sprite-key="egg"] {
  --legend-icon-scale: 0.72;
}

/* ── Editor ── */

.editor {
  padding: 1rem 1.2rem;
  display: grid;
  gap: 0.6rem;
}

.editor-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.editor h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.editor-help {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.88rem;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1.35fr) minmax(220px, 0.9fr) minmax(220px, 0.85fr);
  gap: 0.7rem;
  align-items: stretch;
}

.editor-tool-card,
.palette-group {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, var(--editor-card-gloss-top), var(--editor-card-gloss-bottom)),
    var(--editor-card-tint);
  padding: 0.65rem;
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  align-content: start;
}

.editor-tool-card h3,
.palette-group h3 {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.editor-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.editor-buttons button,
.editor-size button {
  padding: 0.48rem 0.62rem;
  font-size: 0.72rem;
}

.editor-buttons .editor-primary-action {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #6fcf95, #419c65);
  color: #0f2a18;
  box-shadow: 0 2px 0 #2a6944, 0 4px 8px rgba(0, 0, 0, 0.2);
}

.editor-meta {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.25fr) minmax(4.5rem, 0.35fr);
  gap: 0.55rem;
  min-width: 0;
  align-items: start;
}

.editor-saves {
  display: grid;
  gap: 0.45rem;
}

.editor-meta label,
.editor-saves label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 0;
}

.editor-meta input,
.editor-saves select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--editor-control-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  background: var(--modal-input-bg);
  color: var(--ink);
  font: inherit;
  text-transform: none;
}

.editor-palette {
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) minmax(240px, 1fr) minmax(180px, 0.75fr);
  gap: 0.7rem;
  align-items: start;
}

.palette-group {
  grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr));
}

.palette-group h3 {
  grid-column: 1 / -1;
}

.direction-picker {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.2rem 0;
}

.direction-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dir-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1.8rem);
  grid-template-rows: repeat(2, 1.8rem);
  gap: 3px;
}

.dir-btn {
  border-radius: 6px;
  padding: 0;
  font-size: 0.85rem;
  background: linear-gradient(180deg, var(--editor-control-bg-from), var(--editor-control-bg-to));
  color: var(--ink);
  border: 1px solid var(--editor-control-border);
  box-shadow: 0 1px 0 var(--editor-control-shadow);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
}

.dir-btn:hover {
  background: linear-gradient(180deg, var(--editor-control-hover-from), var(--editor-control-hover-to));
}

.dir-btn.active {
  outline: 2px solid var(--accent);
  background: linear-gradient(180deg, rgba(232, 160, 32, 0.15), rgba(232, 160, 32, 0.08));
  color: var(--accent-bright);
}

.dir-btn[data-dir="up"] { grid-column: 2; grid-row: 1; }
.dir-btn[data-dir="left"] { grid-column: 1; grid-row: 2; }
.dir-btn[data-dir="down"] { grid-column: 2; grid-row: 2; }
.dir-btn[data-dir="right"] { grid-column: 3; grid-row: 2; }

.tile-btn {
  border-radius: var(--radius-sm);
  min-width: 0;
  min-height: 4.35rem;
  padding: 0.42rem 0.35rem;
  background: linear-gradient(180deg, var(--editor-control-bg-from), var(--editor-control-bg-to));
  color: var(--ink);
  font-size: 0.68rem;
  box-shadow: 0 1px 0 var(--editor-control-shadow);
  border: 1px solid var(--editor-control-border);
  display: inline-grid;
  align-items: center;
  justify-items: center;
  align-content: center;
  gap: 0.24rem;
  text-align: center;
  line-height: 1.05;
}

.tile-btn-icon {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  image-rendering: pixelated;
  flex: 0 0 auto;
}

.tile-btn-label {
  line-height: 1;
  max-width: 100%;
}

.tile-btn:hover {
  background: linear-gradient(180deg, var(--editor-control-hover-from), var(--editor-control-hover-to));
  border-color: var(--editor-control-border);
}

.tile-btn.active {
  outline: 2px solid var(--accent);
  background: linear-gradient(
    180deg,
    rgba(232, 160, 32, 0.15),
    rgba(232, 160, 32, 0.08)
  );
  color: var(--accent-bright);
}

.editor-size {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: stretch;
}

.editor-size-label {
  grid-column: 1 / -1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.editor-grid-wrap {
  overflow: auto;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--editor-control-border);
  background: var(--editor-grid-bg);
}

.editor-board {
  display: grid;
  gap: 0;
  justify-content: start;
  touch-action: none;
}

.editor-cell {
  width: min(9.4vw, 38px);
  height: min(9.4vw, 38px);
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  font-size: 1rem;
  padding: 0;
  background: #0f1e30;
  color: var(--ink);
  cursor: pointer;
  transition: filter 80ms ease;
  position: relative;
  overflow: hidden;
  image-rendering: pixelated;
}

.editor-cell:hover {
  filter: brightness(1.15);
}

.editor-cell.floor {
  background: url("assets/tiles/floor.png") center / cover no-repeat;
  color: #20313f;
}

.editor-cell.wall {
  background: url("assets/tiles/wall.png") center / cover no-repeat;
}

.editor-cell.water {
  background: url("assets/tiles/water.png") center / cover no-repeat;
}

.editor-cell.spikes {
  background: url("assets/tiles/spikes.png") center / cover no-repeat;
}

.editor-cell.exit {
  background: url("assets/tiles/exit-open.png") center / cover no-repeat;
}

.editor-cell.player {
  background: url("assets/tiles/floor.png") center / cover no-repeat;
  color: #2f3947;
}

.editor-cell.enemy {
  background: url("assets/tiles/floor.png") center / cover no-repeat;
}

.editor-cell.enemy.water {
  background: url("assets/tiles/water.png") center / cover no-repeat;
}

.editor-cell.pickup {
  background: url("assets/tiles/floor.png") center / cover no-repeat;
}

.editor-cell.blocker {
  background: url("assets/tiles/floor.png") center / cover no-repeat;
  color: #172434;
}

.editor-sprite {
  width: 88%;
  height: 88%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.editor-sprite.dir-left {
  transform: scaleX(-1);
}

.editor-sprite.dir-up {
  transform: rotate(-90deg);
}

.editor-sprite.dir-down {
  transform: rotate(90deg);
}

.editor-status {
  margin: 0;
  min-height: 1.2em;
  font-weight: 700;
}

.editor-status.warn {
  color: #ffc85c;
}

.editor-status.success {
  color: #5ce89a;
}

/* ── Animations ── */

@keyframes duckBob {
  0%,
  100% {
    transform: var(--duck-orient) translateY(1px);
  }
  50% {
    transform: var(--duck-orient) translateY(-3px);
  }
}

@keyframes entitySlideTween {
  from {
    transform: translate(
      calc(var(--from-x, 0) * -100%),
      calc(var(--from-y, 0) * -100%)
    );
  }
  to {
    transform: translate(0, 0);
  }
}

@keyframes enemyJitter {
  0% {
    transform: translateX(-1px);
  }
  50% {
    transform: translateX(1px);
  }
  100% {
    transform: translateX(-1px);
  }
}

@keyframes hawkSwoop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes wolfPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes exitPulse {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.2);
  }
  50% {
    box-shadow:
      0 0 18px rgba(46, 204, 113, 0.45),
      0 0 36px rgba(46, 204, 113, 0.15);
  }
}

@keyframes statusFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Effects ── */

@keyframes boardShake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  10% {
    transform: translate(-4px, 2px);
  }
  20% {
    transform: translate(4px, -2px);
  }
  30% {
    transform: translate(-3px, -1px);
  }
  40% {
    transform: translate(3px, 1px);
  }
  50% {
    transform: translate(-2px, 2px);
  }
  60% {
    transform: translate(2px, -1px);
  }
  70% {
    transform: translate(-1px, 1px);
  }
  80% {
    transform: translate(1px, -1px);
  }
}

.board-wrap.shake {
  animation: boardShake 0.4s ease-out;
}

.board-wrap.death-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(220, 50, 70, 0.12);
  border-radius: inherit;
  pointer-events: none;
  z-index: 10;
  animation: flashFade 0.5s ease-out forwards;
}

@keyframes flashFade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.celebrate-particle {
  position: fixed;
  width: 1.6rem;
  height: 1.6rem;
  pointer-events: none;
  z-index: 100;
  animation: celebrateRise 1.4s ease-out forwards;
  object-fit: contain;
  image-rendering: pixelated;
}

@keyframes celebrateRise {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--drift, 0px), -150px) scale(0.3) rotate(30deg);
    opacity: 0;
  }
}

/* ── Settings Modal ── */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  padding: 1rem;
}

.settings-overlay.open {
  opacity: 1;
  visibility: visible;
}

.settings-modal {
  background: var(--modal-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: 0 16px 42px rgba(72, 56, 27, 0.28);
  width: min(360px, 100%);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.settings-overlay.open .settings-modal {
  transform: scale(1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--modal-border);
}

.settings-header h2 {
  margin: 0;
  font-family: "Luckiest Guy", cursive;
  font-size: 1.3rem;
  color: var(--accent);
  letter-spacing: 1px;
}

.settings-close {
  background: transparent;
  color: var(--ink-dim);
  font-size: 1.2rem;
  padding: 0.3rem 0.5rem;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
}

.settings-close:hover {
  color: var(--ink);
  background: var(--modal-hover-bg);
  box-shadow: none;
  transform: none;
}

.settings-body {
  padding: 1rem 1.2rem 1.2rem;
  display: grid;
  gap: 0.9rem;
}

.win-modal {
  width: min(440px, 100%);
  background:
    radial-gradient(circle at top, rgba(255, 222, 138, 0.2), transparent 55%),
    var(--modal-bg);
}

.death-modal {
  width: min(420px, 100%);
  background:
    radial-gradient(circle at top, rgba(179, 64, 54, 0.18), transparent 55%),
    var(--modal-bg);
}

.win-body {
  gap: 1rem;
}

.death-body {
  gap: 1rem;
}

.win-kicker {
  margin: 0;
  color: var(--ink-dim);
  line-height: 1.5;
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.win-stat {
  padding: 0.9rem 1rem;
  border: 1px solid var(--modal-surface-border);
  border-radius: 16px;
  background: var(--modal-surface);
  display: grid;
  gap: 0.3rem;
}

.win-stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
}

.win-stat-value {
  font-family: "Luckiest Guy", cursive;
  font-size: 1.7rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.win-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.win-badge {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.win-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.win-primary {
  background: linear-gradient(180deg, #f3bc66, #d8892a);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-row-slider {
  align-items: flex-start;
}

.settings-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.settings-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 180px;
}

.settings-range {
  width: 150px;
  accent-color: var(--accent);
}

.settings-range:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-value {
  min-width: 2.6rem;
  text-align: right;
  font-size: 0.78rem;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.toggle-switch input:disabled + .toggle-track {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--modal-border);
  margin: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--toggle-track-bg);
  border-radius: 13px;
  transition: background 0.2s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--toggle-knob);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(22px);
  background: #fff;
}

.import-modal {
  width: min(440px, 100%);
}

.import-help {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.import-textarea {
  width: 100%;
  min-height: 160px;
  background: var(--modal-input-bg);
  border: 1px solid var(--modal-surface-border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  padding: 0.7rem;
  resize: vertical;
  line-height: 1.4;
  tab-size: 1;
}

.import-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.import-textarea::placeholder {
  color: var(--ink-dim);
  opacity: 0.4;
}

.settings-danger {
  background: linear-gradient(180deg, #8a4040, #6a2a2a);
  color: #ffcccc;
  box-shadow: 0 2px 0 #4a1a1a, 0 4px 8px rgba(0, 0, 0, 0.25);
  font-size: 0.78rem;
  padding: 0.45rem 1rem;
}

.settings-danger:hover {
  background: linear-gradient(180deg, #9a4a4a, #7a3434);
  box-shadow: 0 3px 0 #4a1a1a, 0 6px 12px rgba(0, 0, 0, 0.3);
}

.settings-danger.confirming {
  background: linear-gradient(180deg, #cc4444, #aa2222);
  color: #fff;
}

.settings-gear {
  background: linear-gradient(180deg, var(--btn-green-from), var(--btn-green-to));
  color: var(--btn-green-text);
  font-size: 1.1rem;
  padding: 0.45rem 0.7rem;
  box-shadow: 0 2px 0 var(--btn-green-shadow), 0 4px 8px rgba(0, 0, 0, 0.2);
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
}

.settings-gear:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 var(--btn-green-shadow), 0 6px 12px rgba(0, 0, 0, 0.24);
}

.menu-settings {
  background: linear-gradient(180deg, var(--btn-green-from), var(--btn-green-to));
  color: var(--btn-green-text);
  font-size: 0.85rem;
  padding: 0.6rem 1.4rem;
  box-shadow: 0 2px 0 var(--btn-green-shadow), 0 4px 8px rgba(0, 0, 0, 0.2);
  margin-top: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: var(--radius);
}

.menu-settings:hover {
  filter: brightness(1.1);
  box-shadow: 0 3px 0 var(--btn-green-shadow), 0 6px 12px rgba(0, 0, 0, 0.24);
}

.settings-section {
  display: grid;
  gap: 0.5rem;
}

.settings-controls {
  display: grid;
  gap: 0.35rem;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--ink-dim);
}

.control-row kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 0.15em 0.5em;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 700;
  color: var(--ink);
}

/* ── Media Queries ── */

@media (min-width: 900px) {
  .topbar {
    grid-template-columns: 1.5fr 1fr;
    align-items: start;
  }

  .app {
    padding: 1.5rem 2rem;
  }
}

@media (min-width: 760px) {
  .touchpad {
    display: none;
  }
}

@media (max-width: 980px) {
  .editor-toolbar,
  .editor-palette {
    grid-template-columns: 1fr;
  }

  .editor-meta {
    grid-template-columns: 1fr;
  }

  .palette-group {
    grid-template-columns: repeat(auto-fill, minmax(4.1rem, 1fr));
  }
}

@media (max-width: 520px) {
  .editor-buttons {
    grid-template-columns: 1fr;
  }

  .win-actions {
    grid-template-columns: 1fr;
  }

  .tile-btn {
    min-height: 3.85rem;
    font-size: 0.64rem;
  }

  .tile-btn-icon {
    width: 1.7rem;
    height: 1.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .menu-duck,
  .sprite.moving,
  .player-wrap.moving,
  .celebrate-particle {
    animation: none !important;
  }
}
