:root {
  --panel: rgba(12, 15, 35, 0.88);
  --panel-border: rgba(93, 234, 255, 0.24);
  --cyan: #5df0ff;
  --cyan-soft: rgba(93, 240, 255, 0.5);
  --purple: #b35cff;
  --pink: #ff5fc8;
  --red: #ff3657;
  --green: #48ff9a;
  --text: #eafaff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(8, 9, 26, 0.12), rgba(8, 9, 26, 0.9)),
    radial-gradient(circle at 20% 15%, rgba(255, 95, 200, 0.22), transparent 28%),
    radial-gradient(circle at 76% 18%, rgba(93, 240, 255, 0.24), transparent 34%),
    linear-gradient(135deg, #11142b, #0a1021 58%, #11192e);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
}

body::before,
body::after {
  position: fixed;
  inset: auto 0 0;
  z-index: -2;
  height: 74vh;
  content: "";
  background:
    linear-gradient(90deg, transparent 0 3%, rgba(67, 88, 135, 0.55) 3% 8%, transparent 8% 10%),
    linear-gradient(90deg, transparent 0 14%, rgba(39, 55, 93, 0.88) 14% 20%, transparent 20% 23%),
    linear-gradient(90deg, transparent 0 29%, rgba(70, 92, 144, 0.62) 29% 34%, transparent 34% 39%),
    linear-gradient(90deg, transparent 0 47%, rgba(44, 64, 107, 0.78) 47% 54%, transparent 54% 58%),
    linear-gradient(90deg, transparent 0 66%, rgba(72, 96, 152, 0.6) 66% 72%, transparent 72% 76%),
    linear-gradient(90deg, transparent 0 86%, rgba(40, 54, 96, 0.84) 86% 94%, transparent 94%);
  filter: blur(1.5px);
  opacity: 0.8;
}

body::after {
  z-index: -1;
  height: 100vh;
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(93, 240, 255, 0.14) 35px 38px, transparent 39px 82px),
    repeating-linear-gradient(90deg, transparent 0 72px, rgba(255, 95, 200, 0.16) 73px 78px, transparent 79px 142px),
    linear-gradient(180deg, transparent 0 45%, rgba(5, 8, 21, 0.6) 100%);
  filter: blur(3px);
  opacity: 0.62;
}

.game {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  width: min(1320px, calc(100vw - 18px));
  height: min(930px, calc(100vh - 18px));
}

.hud,
.help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(18, 20, 44, 0.92), rgba(9, 12, 28, 0.9));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 24px rgba(93, 240, 255, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(12px);
}

.hud div {
  display: grid;
  gap: 1px;
  min-width: 98px;
}

.hud span {
  color: rgba(234, 250, 255, 0.62);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hud strong {
  color: var(--cyan);
  font-size: clamp(20px, 2.3vw, 30px);
  line-height: 1;
  text-shadow: 0 0 4px var(--cyan), 0 0 14px rgba(93, 240, 255, 0.78);
}

.board-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 8px;
  border: 1px solid rgba(93, 240, 255, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(93, 240, 255, 0.1), rgba(179, 92, 255, 0.12)),
    rgba(5, 8, 22, 0.64);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 45px rgba(93, 240, 255, 0.12),
    0 0 32px rgba(179, 92, 255, 0.22),
    0 24px 70px rgba(0, 0, 0, 0.44);
}

#maze {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 2px solid rgba(93, 240, 255, 0.36);
  border-radius: 6px;
  background: #cbd7ea;
  box-shadow:
    0 0 0 2px rgba(179, 92, 255, 0.24),
    0 0 24px rgba(93, 240, 255, 0.26),
    0 18px 40px rgba(0, 0, 0, 0.48);
}

.help {
  flex-wrap: wrap;
  color: rgba(194, 255, 235, 0.92);
  border-color: rgba(72, 255, 154, 0.26);
}

.help p {
  margin: 0;
  color: rgba(193, 255, 235, 0.9);
  font-size: 14px;
}

kbd {
  display: inline-grid;
  min-width: 28px;
  height: 26px;
  margin: 0 2px;
  place-items: center;
  border: 1px solid rgba(72, 255, 154, 0.64);
  border-radius: 6px;
  background: rgba(72, 255, 154, 0.12);
  color: #dffff1;
  font: 900 14px/1 system-ui, sans-serif;
  box-shadow: inset 0 0 8px rgba(72, 255, 154, 0.18), 0 0 10px rgba(72, 255, 154, 0.18);
}

button {
  border: 1px solid rgba(255, 150, 176, 0.8);
  border-radius: 8px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #ff738d, #c51d47);
  color: white;
  font: 900 15px/1 system-ui, sans-serif;
  box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.2), 0 0 20px rgba(255, 54, 87, 0.42);
  cursor: pointer;
}

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

.message {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 6, 18, 0.56);
  backdrop-filter: blur(5px);
}

.message > div {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(93, 240, 255, 0.28);
  border-radius: 8px;
  background: rgba(11, 15, 35, 0.96);
  text-align: center;
  box-shadow: 0 0 40px rgba(93, 240, 255, 0.18), 0 24px 70px rgba(0, 0, 0, 0.48);
}

.message p {
  margin: 10px 0;
  color: rgba(234, 250, 255, 0.82);
  font-size: 18px;
}

.message h1 {
  margin: 6px 0;
  color: var(--cyan);
  font-size: 34px;
  text-shadow: 0 0 14px rgba(93, 240, 255, 0.7);
}

#messageKicker {
  color: var(--green);
  font-weight: 900;
  text-transform: uppercase;
}

.hidden {
  display: none;
}

@media (max-width: 700px) {
  .game {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  .hud,
  .help {
    padding: 8px;
  }

  .hud div {
    min-width: auto;
  }

  .hud strong {
    font-size: 18px;
  }

  .board-wrap {
    padding: 6px;
  }
}
@media(pointer:coarse){.help p{display:none}.help{min-height:170px;align-items:start}.help #restartButton{width:auto;min-height:42px;margin-left:auto}#maze{touch-action:none}.game{height:calc(100dvh - 16px)}}
@media(pointer:coarse) and (orientation:landscape){
  .game{width:calc(100vw - 12px);height:calc(100dvh - 12px);grid-template-rows:auto minmax(0,1fr);gap:6px}
  .hud{padding:6px 10px}.hud div{min-width:0}.hud span{font-size:10px}.hud strong{font-size:18px}
  .board-wrap{margin-left:8px;margin-right:102px;padding:4px;overflow:hidden;touch-action:none}
  .help{position:absolute;right:0;top:62px;min-height:0;padding:0;background:none;border:0;box-shadow:none;backdrop-filter:none}
  .help #restartButton{font-size:11px;padding:10px 6px;min-height:44px}
}
@media(pointer:coarse) and (orientation:landscape){
 .message{padding:8px;overflow:auto;touch-action:pan-y}.message>div{max-height:100%;overflow:auto;padding:14px;touch-action:pan-y}.message h1{font-size:24px}.message p{font-size:14px}
}
