* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #020305;
  --root-panel: rgba(7, 10, 15, 0.78);
  --board-panel: rgba(3, 5, 8, 0.92);
  --board-shell: rgba(5, 8, 13, 0.88);
  --glass: rgba(8, 13, 20, 0.72);
  --glass-strong: rgba(5, 18, 22, 0.92);
  --line: rgba(31, 102, 112, 0.36);
  --line-strong: rgba(71, 224, 209, 0.38);
  --ink: #e6fff7;
  --muted: #94bfc7;
  --muted-deep: #567a89;
  --cyan: #10f2df;
  --cyan-core: #b8ffef;
  --gold: #ffd89a;
  --amber: #ffa838;
  --warning: #ff8c57;
  --danger: #ff6d75;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(145deg, rgba(2, 14, 18, 0.72) 0%, transparent 42%, rgba(36, 18, 5, 0.15) 100%),
    linear-gradient(180deg, rgba(2, 5, 10, 0.98) 0%, rgba(1, 4, 6, 0.99) 54%, #020305 100%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
select {
  font: inherit;
}

a {
  color: var(--cyan);
}

.play-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
  padding: 20px 0 24px;
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  color: #f8fffc;
  font-size: 22px;
  font-weight: 900;
  text-decoration: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.48);
}

.brand::before {
  width: 22px;
  height: 22px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--gold) 0 18%, transparent 19%),
    conic-gradient(from 120deg, transparent 0 26%, rgba(98, 239, 207, 0.95) 26% 34%, transparent 34% 62%, rgba(255, 240, 183, 0.95) 62% 70%, transparent 70% 100%),
    rgba(98, 239, 207, 0.1);
  box-shadow: 0 0 24px rgba(16, 242, 223, 0.36), inset 0 0 14px rgba(16, 242, 223, 0.22);
  content: "";
}

.home-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid rgba(71, 224, 209, 0.28);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(3, 8, 11, 0.72);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(230, 255, 247, 0.03);
}

.game-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  align-items: stretch;
  gap: 20px;
}

.stage,
.hud {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--root-panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.44), inset 0 0 0 1px rgba(230, 255, 247, 0.025);
}

.stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
}

.stage-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stage-topline > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted-deep);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 660px;
  margin: 0 0 14px;
  color: #f8fffc;
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.52);
}

.stage-pills {
  width: min(640px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 126px);
  gap: 8px;
}

.stage-pill {
  min-width: 0;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(71, 224, 209, 0.18);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px rgba(230, 255, 247, 0.025), 0 12px 34px rgba(0, 0, 0, 0.20);
  color: var(--muted);
  font-size: 26px;
  font-weight: 900;
  text-align: center;
}

.stage-pill span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.objective-pill {
  color: var(--muted);
}

.move-pill {
  gap: 12px;
  background: rgba(5, 35, 38, 0.66);
}

.move-pill strong {
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
}

.move-glyph {
  position: relative;
  width: 30px;
  height: 24px;
  color: var(--muted);
}

.move-glyph::before,
.move-glyph::after {
  position: absolute;
  content: "";
}

.move-glyph::before {
  inset: 9px 5px auto 5px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(23deg);
}

.move-glyph::after {
  inset: 3px auto auto 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background:
    radial-gradient(circle, currentColor 0 52%, transparent 54%),
    transparent;
  box-shadow: 18px 8px 0 currentColor;
}

.level-select-wrap {
  display: grid;
  gap: 6px;
  flex: 0 0 178px;
}

.level-select-wrap label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--glass-strong);
  font-weight: 800;
}

.board-shell {
  min-height: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(31, 102, 112, 0.42);
  border-radius: 8px;
  padding: clamp(12px, 2vw, 22px);
  background:
    linear-gradient(180deg, rgba(8, 15, 20, 0.96), rgba(4, 8, 12, 0.94)),
    var(--board-shell);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42), inset 0 -5px 0 rgba(16, 242, 223, 0.10);
}

canvas {
  width: min(100%, 72vh);
  max-width: 720px;
  aspect-ratio: 1;
  display: block;
  border-radius: 8px;
  touch-action: none;
  user-select: none;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.status-panel {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(71, 224, 209, 0.22);
  border-radius: 8px;
  padding: 16px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1px rgba(230, 255, 247, 0.025);
}

.status-panel span,
.meters span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-panel strong {
  min-height: 46px;
  display: block;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.meters div {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 1px solid rgba(71, 224, 209, 0.22);
  border-radius: 8px;
  padding: 10px;
  background: rgba(3, 8, 11, 0.78);
}

.meters strong {
  color: var(--gold);
  font-size: 20px;
  line-height: 1;
}

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

button {
  min-height: 78px;
  display: grid;
  grid-template-rows: 34px auto;
  place-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px 12px;
  color: var(--ink);
  background: rgba(4, 24, 27, 0.92);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), inset 0 0 0 1px rgba(230, 255, 247, 0.025);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(16, 242, 223, 0.66);
  color: var(--cyan-core);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32), 0 0 24px rgba(16, 242, 223, 0.12);
  transform: translateY(-1px);
}

button:disabled {
  color: rgba(86, 122, 137, 0.72);
  background: rgba(3, 7, 10, 0.84);
  cursor: not-allowed;
  opacity: 1;
  box-shadow: inset 0 0 0 1px rgba(230, 255, 247, 0.02);
}

button.primary {
  color: #021010;
  background: linear-gradient(180deg, rgba(184, 255, 239, 0.95), rgba(16, 242, 223, 0.82));
}

button.primary:hover:not(:disabled) {
  color: #021010;
  background: linear-gradient(180deg, rgba(255, 216, 154, 0.98), rgba(16, 242, 223, 0.86));
}

button.primary:disabled {
  color: rgba(86, 122, 137, 0.72);
  background: rgba(3, 7, 10, 0.84);
}

.action-icon {
  position: relative;
  width: 34px;
  height: 34px;
  color: currentColor;
}

.action-icon::before,
.action-icon::after {
  position: absolute;
  content: "";
}

.action-icon-hint::before {
  inset: 3px 8px 12px;
  border-radius: 50% 50% 44% 44%;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}

.action-icon-hint::after {
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 9px;
  border-top: 4px solid currentColor;
  border-bottom: 4px solid currentColor;
}

.action-icon-undo::before,
.action-icon-reset::before {
  inset: 6px;
  border: 4px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.action-icon-undo::after {
  left: 2px;
  top: 11px;
  border-top: 7px solid transparent;
  border-right: 11px solid currentColor;
  border-bottom: 7px solid transparent;
}

.action-icon-reset::before {
  border-right-color: transparent;
  border-left-color: currentColor;
}

.action-icon-reset::after {
  right: 2px;
  top: 11px;
  border-top: 7px solid transparent;
  border-left: 11px solid currentColor;
  border-bottom: 7px solid transparent;
}

.action-icon-next::before {
  left: 7px;
  top: 6px;
  border-top: 11px solid transparent;
  border-left: 15px solid currentColor;
  border-bottom: 11px solid transparent;
}

.action-icon-next::after {
  right: 6px;
  top: 7px;
  width: 5px;
  height: 20px;
  border-radius: 999px;
  background: currentColor;
}

.rules {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 2px 0 0 22px;
  color: #c8dfdf;
  font-size: 14px;
}

.rules li::marker {
  color: var(--cyan);
  font-weight: 900;
}

@media (max-width: 900px) {
  .play-shell {
    width: calc(100% - 24px);
    max-width: 720px;
    padding-top: 14px;
  }

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

  .stage {
    padding: 14px;
  }

  .stage-topline {
    flex-direction: column;
  }

  h1 {
    font-size: 46px;
  }

  .level-select-wrap {
    width: 100%;
    flex-basis: auto;
  }

  canvas {
    width: min(100%, 80svw);
  }

  .hud {
    padding: 14px;
  }
}

@media (max-width: 520px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .play-shell {
    width: 100%;
    max-width: 100%;
    padding: 12px 10px 18px;
  }

  .play-header {
    align-items: flex-start;
  }

  h1 {
    font-size: 38px;
  }

  .stage-pills {
    grid-template-columns: 1fr;
  }

  .stage-pill {
    min-height: 48px;
    font-size: 21px;
  }

  .board-shell {
    width: 100%;
    max-width: 100%;
    padding: 8px;
  }

  canvas {
    width: 100%;
    max-width: calc(100svw - 56px);
  }

  .game-layout,
  .stage,
  .hud,
  .stage-topline,
  .stage-pills {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .meters,
  .controls {
    grid-template-columns: 1fr;
  }

  button {
    min-height: 60px;
    grid-template-columns: 34px auto;
    grid-template-rows: 1fr;
    justify-content: center;
  }

  .status-panel strong {
    min-height: 0;
    font-size: 17px;
  }
}
