
:root {
  --cat-move-ms: 380ms;
  --cat-facing-angle: 0deg;
  --bg-base: #0d1423;
  --bg-surface: rgb(18 26 43 / 82%);
  --bg-surface-soft: rgb(26 36 58 / 70%);
  --border: #334765;
  --border-strong: #4f6992;
  --text-main: #eef4ff;
  --text-muted: #a6b9d8;
  --accent: #66b6ff;
  --accent-strong: #3f8eff;
  --success: #57ddc1;
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Roboto, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text-main);
  background:
    radial-gradient(circle at 12% 8%, #2e4978 0%, transparent 38%),
    radial-gradient(circle at 85% 12%, #20304e 0%, transparent 30%),
    linear-gradient(180deg, #121d30 0%, var(--bg-base) 66%);
}

h1,
h2,
p {
  margin: 0;
}

.app {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 12px;
  min-height: 100dvh;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-surface);
  backdrop-filter: blur(6px);
  box-shadow:
    0 14px 32px rgb(4 7 14 / 26%),
    inset 0 1px 0 rgb(255 255 255 / 4%);
}

.hero {
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background:
    linear-gradient(140deg, rgb(43 66 107 / 70%), rgb(25 34 56 / 75)),
    var(--bg-surface);
  box-shadow: 0 16px 38px rgb(5 9 18 / 34%);
}

.eyebrow {
  color: #8dc4ff;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

h1 {
  font-size: clamp(1.7rem, 2.4vw, 2.15rem);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-muted);
  max-width: 62ch;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.side-panel {
  display: grid;
  gap: 8px;
}

.below-game-panels {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.toolbar,
.tool-panel,
.hud,
.flow-info,
.result,
.board-stage {
  padding: 7px;
}

.tool-panel-inline {
  margin-top: 2px;
}

.toolbar,
.tool-panel {
  display: grid;
  gap: 8px;
}

.toolbar h2,
.tool-panel h2,
.board-heading h2 {
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

button,
select,
input {
  width: 100%;
  background: #1c2942;
  color: var(--text-main);
  border: 1px solid #4a5f82;
  border-radius: 10px;
  min-height: 34px;
  padding: 6px 8px;
  font: inherit;
  transition: border-color 150ms ease, transform 120ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent-strong);
}

button:hover,
select:hover,
input:hover {
  border-color: #79a8ea;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: none;
  border-color: #93bdff;
  box-shadow: 0 0 0 3px rgb(122 168 255 / 28%);
}

.toolbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#start-btn {
  border-color: #6ea8ff;
  background: linear-gradient(180deg, #4180e2, #2f67be);
  box-shadow: 0 6px 16px rgb(32 94 191 / 32%);
}

#start-btn:hover {
  border-color: #8bc0ff;
  background: linear-gradient(180deg, #4a89ec, #366fc8);
}

#speed-value {
  justify-self: end;
  color: #9cc7ff;
  font-size: 0.82rem;
}

.tools {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.tool-btn {
  min-height: 56px;
  background: #1a2841;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
}

.tool-btn-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.tool-btn-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tool-btn-icon-erase {
  font-size: 1rem;
  font-weight: 700;
}

.tool-btn-label {
  font-size: 0.62rem;
  line-height: 1.1;
  color: #d6e6ff;
  text-align: center;
}

.tool-btn.active {
  border-color: #87b6ff;
  background: linear-gradient(180deg, #35598c, #2a476f);
  box-shadow: 0 8px 16px rgb(36 77 141 / 33%);
}

.tool-inline-hint {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  color: #c4dcff;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid #5479aa;
  background: rgb(69 104 155 / 24%);
}

#build-note {
  color: var(--text-muted);
  line-height: 1.25;
  font-size: 0.66rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 4px;
}

.hud-title {
  grid-column: 1 / -1;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text-main);
}

.hud-turn-progress-wrap {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: #1c2942;
  border: 1px solid #324662;
  overflow: hidden;
}

.hud-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width 180ms ease;
}

.hud-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid #324662;
  border-radius: 8px;
  background: var(--bg-surface-soft);
}

.hud-card strong {
  font-size: 0.88rem;
  line-height: 1;
}

.hud-label {
  color: var(--text-muted);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}


.flow-info {
  display: grid;
  gap: 6px;
}

.flow-info h2 {
  font-size: 0.9rem;
}

.flow-info p {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.result:empty {
  display: none;
}

.result h3 {
  margin-bottom: 6px;
}

.result p {
  color: var(--text-muted);
  margin-top: 4px;
}

.board-stage {
  display: grid;
  gap: 6px;
}

.board-heading p {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 0.78rem;
}

.board-wrap {
  position: relative;
  width: min(100%, 720px);
  margin-inline: auto;
  border-radius: 16px;
  padding: 8px;
  border: 1px solid #4b6388;
  background: linear-gradient(180deg, #334d77, #263a5e);
  box-shadow: 0 16px 36px rgb(5 11 22 / 36%);
}

.cat-layer {
  position: absolute;
  inset: 4px;
  pointer-events: none;
}

.board {
  position: relative;
  display: grid;
  gap: 3px;
  background: #415375;
  padding: 3px;
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  width: 100%;
}

.tile {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 0;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  border: 1px solid #566a90;
  background:
    linear-gradient(180deg, rgb(37 50 73 / 90%), rgb(30 41 61 / 90%));
  transition: transform 120ms ease, border-color 150ms ease, background-color 150ms ease;
}

.tile:hover {
  transform: translateY(-1px);
  border-color: #83a3d6;
  background:
    linear-gradient(180deg, rgb(45 60 88 / 95%), rgb(36 49 72 / 95%));
}

.tile.has-facility {
  border-color: #9ab5df;
  box-shadow: inset 0 0 0 1px rgb(145 180 236 / 24%);
}

.tile.has-obstacle {
  border-color: #7f8aa0;
  background: linear-gradient(180deg, rgb(53 59 72 / 95%), rgb(44 49 61 / 95%));
}


.laser-target-dot {
  position: absolute;
  z-index: 3;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff4b4b;
  box-shadow: 0 0 0 2px rgb(255 85 85 / 22%), 0 0 9px rgb(255 82 82 / 75%);
}

.facility-icon {
  position: relative;
  z-index: 2;
  width: 72%;
  height: 72%;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / 30%));
}

.obstacle-icon {
  width: 68%;
  height: 68%;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 45%));
}

.facility-icon-fish-bowl,
.tool-btn-icon.facility-icon-fish-bowl {
  display: block;
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-position: 0 0;
  mix-blend-mode: lighten;
}

.tool-btn-icon.facility-icon-fish-bowl {
  width: 100%;
  height: 100%;
  background-size: 200% 200%;
}

.facility-tunnel-horizontal {
  width: 82%;
  height: 58%;
}

.facility-tunnel-vertical {
  width: 58%;
  height: 82%;
  transform: rotate(90deg);
}

.laser-arrow {
  position: absolute;
  z-index: 4;
  right: 5px;
  bottom: 5px;
  width: 14px;
  height: 14px;
  opacity: 0.96;
}

.edge-marker {
  position: absolute;
  z-index: 5;
  top: 5px;
  left: 5px;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  border: 1px solid rgb(255 255 255 / 25%);
  text-shadow: 0 1px 0 rgb(0 0 0 / 35%);
}

.edge-marker-entry {
  background: linear-gradient(180deg, #22ba86, #1b8964);
  box-shadow: 0 0 8px rgb(38 203 146 / 45%);
}

.edge-marker-exit {
  background: linear-gradient(180deg, #ff7b7b, #d65050);
  box-shadow: 0 0 8px rgb(255 113 113 / 45%);
}


.cat-footprint {
  position: absolute;
  width: calc(100% / 5 - 6px);
  height: calc(100% / 5 - 6px);
  display: grid;
  place-items: center;
  font-size: 1.18rem;
  color: rgb(255 255 255 / 46%);
  text-shadow: 0 1px 2px rgb(0 0 0 / 45%);
  transform: scale(1.05);
  pointer-events: none;
  z-index: 1;
}

.cat-wrapper {
  z-index: 3;
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / 5 - 6px);
  height: calc(100% / 5 - 6px);
  pointer-events: none;
  transition:
    left var(--cat-move-ms) ease-in-out,
    top var(--cat-move-ms) ease-in-out;
}

.cat-wrapper .cat {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(var(--cat-facing-angle));
  transform-origin: 50% 50%;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 35%));
  transition: transform calc(var(--cat-move-ms) * 0.75) ease;
}

.cat-satisfied-emoji {
  position: absolute;
  left: 50%;
  top: -0.35em;
  transform: translateX(-50%);
  font-size: 1.1em;
  line-height: 1;
  opacity: 0;
  transition: opacity 180ms ease;
}

.cat-satisfied-emoji.visible {
  opacity: 1;
}

.cat-score-popup {
  position: absolute;
  transform: translate(-50%, -30%);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 0 6px rgb(255 255 255 / 40%), 0 2px 4px rgb(0 0 0 / 45%);
  animation: score-popup-float 900ms ease-out forwards;
  will-change: transform, opacity;
}

.cat-score-popup[data-tier="low"] {
  color: #8de7ff;
}

.cat-score-popup[data-tier="mid"] {
  color: #7dff9e;
  text-shadow: 0 0 10px rgb(85 255 161 / 55%), 0 2px 4px rgb(0 0 0 / 45%);
}

.cat-score-popup[data-tier="high"] {
  color: #ffd86f;
  text-shadow: 0 0 12px rgb(255 216 111 / 75%), 0 0 22px rgb(255 200 85 / 55%), 0 2px 4px rgb(0 0 0 / 45%);
}

.cat-score-popup[data-tier="epic"] {
  color: #ff8df8;
  text-shadow: 0 0 12px rgb(255 141 248 / 90%), 0 0 26px rgb(255 123 231 / 72%), 0 2px 4px rgb(0 0 0 / 45%);
}

@keyframes score-popup-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -15%) scale(0.75);
  }

  22% {
    opacity: 1;
    transform: translate(-50%, -48%) scale(1.1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -110%) scale(0.92);
  }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .below-game-panels {
    grid-template-columns: 1fr;
  }

  .board-wrap {
    width: min(100%, 620px);
  }
}

@media (max-width: 640px) {
  .app {
    padding: 8px;
  }

  .hero {
    padding: 10px 12px;
  }

  .eyebrow {
    font-size: 0.68rem;
    margin-bottom: 4px;
  }

  h1 {
    font-size: 1.34rem;
    margin-bottom: 2px;
  }

  .subtitle {
    font-size: 0.78rem;
  }

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

  .tools {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .tool-btn {
    min-height: 48px;
    gap: 2px;
    padding: 3px 1px;
  }

  .tool-btn-icon-wrap {
    width: 18px;
    height: 18px;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-btn-label {
    font-size: 0.52rem;
  }

  .below-game-panels {
    grid-template-columns: 1fr;
    margin-top: 6px;
  }

  .board-wrap {
    width: 100%;
  }
}
