:root {
  --panel: rgba(249, 247, 240, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.78);
  --text-main: #173126;
  --text-soft: #4f665c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text-main);
}

body {
  position: relative;
  background: #0f201b;
}

canvas {
  display: block;
}

#gameCanvas {
  width: 100vw;
  height: 100vh;
}

.minimap-shell {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: 196px;
  height: 196px;
  padding: 8px;
  border-radius: 22px;
  border: 1px solid rgba(238, 251, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(18, 37, 49, 0.84), rgba(12, 24, 33, 0.72)),
    rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}

#minimapCanvas {
  width: 180px;
  height: 180px;
  border-radius: 16px;
  background: rgba(230, 241, 242, 0.78);
}

.hud-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 3;
  display: grid;
  grid-template-columns: auto repeat(7, minmax(110px, 1fr));
  gap: 10px;
  align-items: center;
}

.home-link,
.hud-pill {
  min-height: 58px;
  border-radius: 20px;
  border: 1px solid rgba(238, 251, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(18, 37, 49, 0.84), rgba(12, 24, 33, 0.72)),
    rgba(255, 255, 255, 0.16);
  color: #f8f7f2;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.hud-pill {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 14px;
}

.hud-pill span {
  font-size: 0.76rem;
  color: rgba(225, 240, 247, 0.78);
}

.hud-pill strong {
  font-size: 1.15rem;
  color: #ffffff;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 10, 12, 0.5);
  backdrop-filter: blur(10px);
}

.menu-overlay.hidden {
  display: none;
}

.menu-card {
  width: min(960px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 30px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)), var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.eyebrow {
  margin: 0;
  color: #167f68;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

.menu-card h1 {
  margin: 8px 0 10px;
  font-size: clamp(2.3rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.subtitle {
  margin: 0 0 18px;
  color: var(--text-soft);
  line-height: 1.5;
  max-width: 760px;
}

.menu-card label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 800;
}

.menu-card input,
.menu-card button {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 16px;
}

.menu-card input[type="text"],
.menu-card input[type="color"] {
  background: var(--panel-strong);
}

.menu-card input[type="color"] {
  height: 52px;
  padding: 5px;
}

.editor-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--text-main);
  font-weight: 800;
}

.editor-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #19584a;
}

.level-deck {
  margin-top: 16px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(26, 72, 59, 0.1);
}

.level-deck-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  color: var(--text-soft);
}

.level-deck-head strong {
  color: var(--text-main);
}

.level-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.level-card {
  position: relative;
  overflow: hidden;
  min-height: 110px;
  padding: 16px;
  border-radius: 20px;
  color: #f8f7f2;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.level-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 28%),
    var(--card-bg, linear-gradient(160deg, #2d554a, #12231d));
}

.level-card > * {
  position: relative;
  z-index: 1;
}

.level-card.editor-ready {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.level-card.editor-ready:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
}

.level-card.selected {
  border-color: rgba(255, 255, 255, 0.76);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.26), 0 18px 38px rgba(0, 0, 0, 0.24);
}

.level-card strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.level-card small,
.level-card span {
  display: block;
  line-height: 1.45;
}

.level-card small {
  opacity: 0.85;
}

.instructions {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(236, 243, 238, 0.92);
}

.instructions summary {
  cursor: pointer;
  font-weight: 800;
}

.instructions-body {
  margin-top: 10px;
  color: var(--text-soft);
  line-height: 1.45;
}

.instructions-body p {
  margin: 0 0 8px;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 12px;
  margin-top: 18px;
}

.menu-card button,
.secondary-link {
  min-height: 48px;
  border-radius: 16px;
  font-weight: 900;
  text-decoration: none;
  transition: transform 120ms ease, opacity 120ms ease;
}

.menu-card button {
  background: linear-gradient(180deg, #16362d, #0f241e);
  color: #fff;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text-main);
}

.menu-card button:hover,
.secondary-link:hover,
.home-link:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 4;
  transform: translateX(-50%);
  min-width: min(460px, calc(100vw - 40px));
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-main);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.toast.hidden {
  display: none;
}

@media (max-width: 960px) {
  .hud-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-preview,
  .menu-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .menu-card {
    padding: 22px;
  }

  .hud-bar {
    left: 10px;
    right: 10px;
    top: 10px;
    gap: 8px;
  }

  .home-link,
  .hud-pill {
    min-height: 52px;
  }

  .minimap-shell {
    right: 10px;
    bottom: 10px;
    width: 156px;
    height: 156px;
  }

  #minimapCanvas {
    width: 140px;
    height: 140px;
  }
}
