:root {
  --bg-deep: #07090f;
  --bg-mid: #111827;
  --bg-panel: rgba(12, 18, 30, 0.84);
  --text: #e7ebf5;
  --text-dim: #9ca6be;
  --accent: #ff7a18;
  --accent-2: #ffd04f;
  --danger: #ff4d5f;
  --ok: #3bcf7b;
  --line: rgba(142, 165, 208, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 82% -180px, rgba(255, 145, 33, 0.25), transparent 70%),
    radial-gradient(900px 600px at -220px 50%, rgba(87, 145, 255, 0.22), transparent 75%),
    linear-gradient(180deg, #05070d 0%, #090f1f 55%, #04060a 100%);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

#app {
  width: 100%;
  height: 100%;
}

.app-shell {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 20px;
}

.top-controls {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.top-controls-left,
.top-controls-right {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}

.screen.screen--game {
  padding: 0;
  overflow: hidden;
}

.panel {
  max-width: 980px;
  margin: 0 auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.muted {
  color: var(--text-dim);
}

.menu-grid {
  margin-top: 20px;
  display: grid;
  gap: 12px;
}

.btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: linear-gradient(180deg, #1a253b, #11192b);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 183, 102, 0.7);
  background: linear-gradient(180deg, #243657, #192338);
}

.btn.primary:hover:not(:disabled) {
  border-color: rgba(255, 197, 110, 0.9);
  background: linear-gradient(180deg, #ffab47, #ff7e2f);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.primary {
  border-color: rgba(255, 177, 60, 0.6);
  background: linear-gradient(180deg, #ff982f, #ff6f28);
  color: #1d1206;
  font-weight: 700;
}

.btn.danger {
  border-color: rgba(255, 77, 95, 0.7);
  background: linear-gradient(180deg, #ff7887, #d63f50);
  color: #29080e;
}

.btn.inline {
  padding: 8px 12px;
  font-size: 14px;
}

.is-hidden {
  display: none !important;
}

.level-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.level-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(24, 35, 57, 0.88), rgba(15, 22, 37, 0.88));
  padding: 14px;
  display: grid;
  gap: 8px;
}

.level-card.locked {
  opacity: 0.5;
}

.level-card h3 {
  margin: 0;
  font-size: 17px;
}

.level-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 13px;
}

.settings-list {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.setting-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

input[type="range"] {
  width: min(400px, 100%);
}

input[type="text"],
input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(9, 13, 22, 0.7);
  color: var(--text);
}

.editor-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.editor-grid-wrap {
  max-height: 56vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(8, 12, 20, 0.7);
}

.editor-grid {
  display: inline-grid;
  gap: 4px;
}

.editor-cell {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(53, 78, 118, 0.68);
  cursor: pointer;
  padding: 0;
}

.editor-cell.blocked {
  background: rgba(57, 58, 65, 0.95);
}

.game-layout {
  width: 100%;
  height: 100%;
}

.game-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
}

.game-bottom-hud {
  width: min(760px, calc(100vw - 20px));
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.game-hud-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg-panel);
  display: grid;
  gap: 6px;
}

.stat-row {
  display: grid;
  gap: 5px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(149, 165, 200, 0.22);
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

.game-view {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #070b10;
}

.game-canvas-host {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.game-hint {
  position: absolute;
  left: 12px;
  bottom: 90px;
  color: rgba(232, 241, 255, 0.84);
  background: rgba(12, 18, 30, 0.72);
  border: 1px solid rgba(171, 193, 235, 0.28);
  border-radius: 8px;
  font-size: 12px;
  padding: 8px 10px;
  pointer-events: none;
}

.modal {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(2, 4, 8, 0.66);
  backdrop-filter: blur(2px);
}

.modal.active {
  display: grid;
}

.modal-card {
  width: min(92%, 420px);
  background: rgba(10, 16, 28, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.modal-card h3 {
  margin: 0;
  font-size: 21px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .screen {
    padding: 12px;
  }

  .screen.screen--game {
    padding: 0;
  }

  .game-bottom-hud {
    width: calc(100vw - 16px);
    gap: 8px;
  }

  .game-hud-card {
    padding: 8px 10px;
  }

  .stat-value {
    font-size: 18px;
  }

  .game-hint {
    display: none;
  }

  .top-controls {
    top: 8px;
    left: 8px;
    right: 8px;
  }
}
