:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #9aadc0;
  --panel: rgba(8, 13, 22, 0.78);
  --panel-solid: #0b111c;
  --line: rgba(255, 255, 255, 0.16);
  --cyan: #31e5ff;
  --lime: #7dff6a;
  --gold: #ffd166;
  --pink: #ff4fd8;
  --red: #ff4b62;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: #050812;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.game-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(transparent 0 94%, rgba(255, 255, 255, 0.06) 94%),
    linear-gradient(90deg, transparent 0 94%, rgba(255, 255, 255, 0.05) 94%),
    radial-gradient(circle at 20% 18%, rgba(49, 229, 255, 0.22), transparent 28%),
    radial-gradient(circle at 78% 78%, rgba(255, 79, 216, 0.2), transparent 30%),
    linear-gradient(135deg, #070b17 0%, #111728 52%, #060914 100%);
  background-size: 100% 100%, 42px 42px, 100% 100%, 100% 100%, 100% 100%;
}

#game-canvas {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  max-width: 100vw;
  max-height: 100vh;
  background: #060915;
  box-shadow: var(--shadow);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: clamp(18px, 4vw, 52px);
  pointer-events: none;
}

.screen.visible {
  display: grid;
  pointer-events: auto;
}

.menu-panel,
.drawer,
.pause-card {
  width: min(92vw, 560px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.menu-panel {
  position: relative;
  display: grid;
  gap: 26px;
  width: min(94vw, 680px);
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  border-color: rgba(49, 229, 255, 0.34);
  background:
    linear-gradient(135deg, rgba(49, 229, 255, 0.16), transparent 32%),
    linear-gradient(315deg, rgba(255, 79, 216, 0.18), transparent 36%),
    rgba(8, 13, 22, 0.84);
}

.menu-panel::before,
.menu-panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.menu-panel::before {
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
}

.menu-panel::after {
  right: -90px;
  top: -110px;
  width: 260px;
  height: 260px;
  border: 28px solid rgba(125, 255, 106, 0.09);
  transform: rotate(22deg);
}

.secret-door-button {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 3;
  width: 34px;
  height: 48px;
  border: 2px solid var(--gold);
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(180deg, rgba(8, 13, 22, 0.92), rgba(49, 229, 255, 0.18));
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.38);
  cursor: pointer;
}

.secret-door-button::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 23px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.brand-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-cube {
  width: 88px;
  height: 88px;
  border: 4px solid #07101a;
  border-radius: 8px;
  background:
    linear-gradient(45deg, transparent 38%, rgba(255, 255, 255, 0.75) 38% 48%, transparent 48%),
    linear-gradient(135deg, var(--lime), var(--cyan) 50%, var(--pink));
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.22), 0 0 38px rgba(49, 229, 255, 0.45);
  transform: rotate(6deg);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 0.95;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3.4rem, 8vw, 6.7rem);
  color: #ffffff;
  text-shadow:
    0 8px 0 rgba(0, 0, 0, 0.28),
    0 0 18px rgba(49, 229, 255, 0.42),
    0 0 42px rgba(255, 79, 216, 0.22);
}

h2 {
  font-size: clamp(1.9rem, 5vw, 3rem);
}

.stats-strip {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats-strip span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.035));
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stats-strip strong {
  color: var(--ink);
  font-size: 1.36rem;
}

.menu-actions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  gap: 10px;
}

.primary-action,
.ghost-action,
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 950;
}

.primary-action {
  border-color: rgba(125, 255, 106, 0.48);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 28%),
    linear-gradient(135deg, #7dff6a, #31e5ff);
  color: #061019;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.2), 0 0 28px rgba(49, 229, 255, 0.3);
}

.primary-action.small {
  min-height: 48px;
}

.ghost-action,
.icon-action {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.045));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ghost-action.active-tool {
  border-color: rgba(125, 255, 106, 0.62);
  background: rgba(125, 255, 106, 0.16);
  color: var(--lime);
}

.primary-action:hover,
.ghost-action:hover,
.icon-action:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.play-triangle {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 15px solid currentColor;
}

.drawer {
  display: grid;
  gap: 16px;
  padding: 22px;
  max-height: min(88vh, 720px);
  overflow: auto;
}

.drawer.compact {
  width: min(92vw, 440px);
}

.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.icon-action {
  width: 44px;
  min-height: 44px;
  font-size: 1.7rem;
}

.level-list {
  display: grid;
  gap: 10px;
  max-height: min(58vh, 520px);
  padding-right: 6px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-color: var(--cyan) rgba(255, 255, 255, 0.08);
}

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

.small-action {
  min-height: 38px;
}

.level-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.level-card:hover {
  border-color: rgba(49, 229, 255, 0.55);
  background: rgba(49, 229, 255, 0.1);
}

.secret-card {
  width: 100%;
  border-color: rgba(255, 209, 102, 0.48);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.16), rgba(255, 79, 216, 0.1));
  color: var(--ink);
}

.level-card strong {
  display: block;
  margin-bottom: 4px;
}

.level-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.level-badge {
  min-width: 70px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--gold);
  text-align: center;
  font-weight: 950;
}

.toggle-row,
.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 850;
}

.range-row {
  grid-template-columns: 1fr minmax(150px, 230px);
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--cyan);
}

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

.pause-card {
  display: grid;
  gap: 12px;
  width: min(92vw, 340px);
  padding: 24px;
}

.editor-screen {
  align-items: start;
  justify-items: start;
}

.editor-panel {
  display: grid;
  gap: 12px;
  width: min(92vw, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(18px);
}

.editor-tools,
.editor-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 8px;
}

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

.skin-section {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.skin-section strong {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.skin-button {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.skin-button.active-tool {
  border-color: var(--lime);
  box-shadow: 0 0 0 2px rgba(125, 255, 106, 0.22);
}

.hud {
  position: absolute;
  top: 16px;
  left: 50%;
  width: min(92vw, 900px);
  transform: translateX(-50%);
  pointer-events: none;
}

.hud.hidden {
  display: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
  color: var(--ink);
  font-weight: 950;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.65);
}

.progress-percent {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 950;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.72);
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.26);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lime), var(--cyan), var(--pink));
}

.leave-button {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 4;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.76);
  color: var(--ink);
  cursor: pointer;
  font-weight: 950;
  backdrop-filter: blur(12px);
}

.leave-button.hidden {
  display: none;
}

.developer-credit {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 3;
  max-width: min(42vw, 520px);
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.58rem, 1vw, 0.76rem);
  font-weight: 950;
  line-height: 1.1;
  text-align: right;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  overflow-wrap: anywhere;
  pointer-events: none;
}

.chance-board {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 3;
  display: grid;
  gap: 3px;
  min-width: 168px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(8, 13, 22, 0.72);
  color: rgba(248, 251, 255, 0.82);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.15;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.chance-board strong {
  color: var(--gold);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.input-hint {
  position: absolute;
  right: 16px;
  bottom: 14px;
  color: rgba(248, 251, 255, 0.68);
  font-size: 0.82rem;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

@media (max-width: 720px) {
  .menu-actions,
  .stats-strip {
    grid-template-columns: 1fr;
  }

  .brand-row {
    align-items: flex-start;
  }

  .brand-cube {
    width: 58px;
    height: 58px;
  }

  .input-hint {
    left: 12px;
    right: 12px;
    bottom: 104px;
    text-align: center;
  }

  .chance-board {
    left: 12px;
    bottom: 12px;
    min-width: 150px;
    padding: 8px 10px;
    font-size: 0.66rem;
  }

  .developer-credit {
    max-width: 54vw;
  }
}
