* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

button {
  font: inherit;
}

.ftwBody {
  color: #f4f7fb;
  background:
    radial-gradient(circle at 20% 12%, rgba(113, 67, 180, 0.19), transparent 34%),
    radial-gradient(circle at 84% 80%, rgba(28, 152, 210, 0.14), transparent 31%),
    linear-gradient(145deg, #111827, #070a11 58%, #0d0716);
}

.ftwBody::before,
.ftwBody::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(2px);
}

.ftwBody::before {
  width: 42vmin;
  aspect-ratio: 1;
  top: -18vmin;
  right: -9vmin;
  border: 1px solid rgba(119, 202, 255, 0.13);
  box-shadow: 0 0 90px rgba(70, 165, 255, 0.08);
}

.ftwBody::after {
  width: 36vmin;
  aspect-ratio: 1;
  left: -18vmin;
  bottom: -15vmin;
  background: rgba(91, 55, 143, 0.08);
  filter: blur(28px);
}

.ftwApp {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.ftwScreen {
  width: 100%;
  height: 100%;
  padding: clamp(22px, 4vw, 54px);
}

.ftwScreen[hidden] {
  display: none !important;
}

.ftwIntro,
.ftwEnd {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 2vh, 22px);
  text-align: center;
}

.ftwKicker {
  color: #ffae60;
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.ftwIntro h1,
.ftwEnd h2,
.ftwLevelComplete h2 {
  color: #f7f4ee;
  font-size: clamp(38px, 6.8vw, 78px);
  font-weight: 760;
  line-height: 0.98;
  letter-spacing: -0.035em;
  text-shadow: 0 10px 34px rgba(0, 0, 0, 0.48);
}

.ftwLead {
  max-width: 690px;
  color: rgba(229, 239, 248, 0.8);
  font-size: clamp(14px, 1.55vw, 20px);
  line-height: 1.62;
}

.ftwFlagMark {
  position: relative;
  width: 76px;
  height: 70px;
  filter: drop-shadow(0 0 20px rgba(255, 166, 70, 0.22));
}

.ftwFlagPole {
  position: absolute;
  left: 20px;
  top: 5px;
  width: 5px;
  height: 60px;
  border-radius: 999px;
  background: linear-gradient(#d8f4ff, #6da7bf);
}

.ftwFlagPole::after {
  content: "";
  position: absolute;
  left: -9px;
  bottom: -1px;
  width: 23px;
  height: 5px;
  border-radius: 999px;
  background: #76b7d2;
}

.ftwFlagCloth {
  position: absolute;
  left: 25px;
  top: 8px;
  width: 43px;
  height: 29px;
  clip-path: polygon(0 0, 100% 17%, 77% 54%, 100% 100%, 0 82%);
  background: linear-gradient(135deg, #ffbd58, #ff6f32);
  box-shadow: 0 0 20px rgba(255, 128, 45, 0.32);
}

.ftwFlagMarkComplete {
  transform: scale(1.12);
}

.ftwIntroNotes {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
}

.ftwIntroNotes span {
  padding: 7px 11px;
  border: 1px solid rgba(121, 181, 221, 0.2);
  border-radius: 999px;
  color: rgba(220, 238, 250, 0.72);
  background: rgba(255, 255, 255, 0.035);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ftwPrimary,
.ftwSecondary {
  min-width: 164px;
  min-height: 46px;
  padding: 13px 22px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, filter 160ms ease, background-color 160ms ease;
}

.ftwPrimary {
  border: 1px solid rgba(134, 225, 255, 0.72);
  color: #fff;
  background: linear-gradient(100deg, #178fc9, #7152e8);
  box-shadow: 0 0 26px rgba(66, 151, 255, 0.24);
}

.ftwSecondary {
  border: 1px solid rgba(151, 190, 222, 0.25);
  color: #e2eff8;
  background: rgba(255, 255, 255, 0.055);
}

.ftwPrimary:hover,
.ftwSecondary:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
}

.ftwPrimary:focus-visible,
.ftwSecondary:focus-visible,
.ftwDpad button:focus-visible {
  outline: 2px solid #82ddff;
  outline-offset: 3px;
}

.ftwPlay {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.5vh, 15px);
  padding: clamp(18px, 2.8vw, 34px);
}

.ftwHud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-right: 54px;
}

.ftwHudCard {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(104, 158, 204, 0.2);
  border-radius: 12px;
  background: rgba(7, 17, 27, 0.66);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ftwHudCard span,
.ftwResultGrid span {
  color: rgba(188, 218, 237, 0.62);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ftwHudCard strong,
.ftwResultGrid strong {
  color: #ffb562;
  font-size: clamp(18px, 2.5vw, 27px);
  line-height: 1;
}

.ftwProgress {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.ftwProgress span {
  display: block;
  width: 33.333%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #42d7ff, #ffaf55);
  box-shadow: 0 0 14px rgba(76, 211, 255, 0.36);
  transition: width 240ms ease;
}

.ftwMazePanel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(81, 177, 224, 0.29);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 45%, rgba(34, 100, 135, 0.12), transparent 44%),
    linear-gradient(145deg, rgba(5, 15, 24, 0.9), rgba(8, 7, 18, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 20px 50px rgba(0, 0, 0, 0.24);
  touch-action: none;
}

#ftwCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.ftwLevelComplete {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 15px;
  padding: 24px;
  text-align: center;
  background: rgba(4, 10, 17, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.ftwLevelComplete[hidden] {
  display: none !important;
}

.ftwLevelComplete h2 {
  font-size: clamp(28px, 4.4vw, 50px);
}

.ftwLevelComplete p:not(.ftwKicker) {
  color: rgba(226, 239, 248, 0.8);
  font-size: 14px;
  line-height: 1.55;
}

.ftwPlayFooter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.ftwUtilityActions {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.ftwUtilityActions .ftwSecondary {
  min-width: 136px;
  min-height: 40px;
  padding: 10px 14px;
  font-size: 10px;
}

.ftwHint {
  min-width: 0;
  color: rgba(213, 231, 243, 0.68);
  font-size: 12px;
  line-height: 1.4;
}

.ftwDpad {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(2, 40px);
  gap: 5px;
}

.ftwDpad button {
  border: 1px solid rgba(94, 193, 234, 0.28);
  border-radius: 10px;
  color: #dff7ff;
  background: rgba(12, 34, 49, 0.76);
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.ftwDpad button:hover {
  border-color: rgba(102, 217, 255, 0.84);
  background: rgba(18, 54, 74, 0.92);
}

.ftwDpad button:active {
  transform: scale(0.94);
}

.ftwDpad button[data-direction="up"] {
  grid-column: 2;
  grid-row: 1;
}

.ftwDpad button[data-direction="left"] {
  grid-column: 1;
  grid-row: 2;
}

.ftwDpad button[data-direction="down"] {
  grid-column: 2;
  grid-row: 2;
}

.ftwDpad button[data-direction="right"] {
  grid-column: 3;
  grid-row: 2;
}

.ftwResultGrid {
  width: min(100%, 500px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ftwResultGrid div {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(104, 158, 204, 0.2);
  border-radius: 14px;
  background: rgba(7, 17, 27, 0.66);
}

.ftwEndActions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 680px) {
  .ftwScreen {
    padding: 18px 14px;
  }

  .ftwIntro,
  .ftwEnd {
    gap: 13px;
  }

  .ftwIntro h1,
  .ftwEnd h2 {
    font-size: clamp(36px, 12vw, 58px);
  }

  .ftwLead {
    font-size: 13px;
  }

  .ftwPlay {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: 12px;
    gap: 8px;
  }

  .ftwHud {
    gap: 6px;
    padding-right: 44px;
  }

  .ftwHudCard {
    padding: 8px;
    border-radius: 9px;
  }

  .ftwHudCard span {
    font-size: 7px;
  }

  .ftwHudCard strong {
    font-size: 16px;
  }

  .ftwMazePanel {
    border-radius: 13px;
  }

  .ftwPlayFooter {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .ftwUtilityActions {
    justify-content: space-between;
  }

  .ftwHint {
    font-size: 10px;
    text-align: right;
  }

  .ftwDpad {
    justify-self: center;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(2, 38px);
  }

  .ftwPrimary,
  .ftwSecondary {
    min-width: 145px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .ftwPlay {
    padding: 10px 14px;
    gap: 6px;
  }

  .ftwHudCard {
    padding: 6px 10px;
  }

  .ftwPlayFooter {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .ftwDpad {
    grid-template-columns: repeat(3, 34px);
    grid-template-rows: repeat(2, 30px);
  }

  .ftwDpad button {
    border-radius: 7px;
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
