.word-flight-shell {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 221, 140, 0.24), transparent 26%),
    linear-gradient(145deg, #182f55 0%, #246d8a 48%, #744f9b 100%);
}

.word-flight-app {
  max-width: none;
  width: 100vw;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.word-flight-stage-card {
  position: relative;
  width: min(calc(100vw - 16px), calc((100vh - 16px) * 16 / 9));
  aspect-ratio: 16 / 9;
  height: auto;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(14, 34, 68, 0.72);
  box-shadow: 0 22px 70px rgba(12, 18, 42, 0.34);
}

.word-flight-topbar {
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  border-radius: 8px;
  background: rgba(10, 30, 62, 0.72);
  color: #fff7db;
  backdrop-filter: blur(10px);
  padding: 7px 8px;
}

.word-flight-topbar .back {
  min-height: 34px;
  padding: 6px 10px;
}

.word-flight-topbar .topbar-title {
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  line-height: 1;
  white-space: nowrap;
}

.word-flight-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.word-flight-stats .stat-pill {
  padding: 6px 9px;
  font-size: 0.86rem;
  line-height: 1;
}

.word-flight-playfield {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
}

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

.word-flight-overlay {
  position: absolute;
  z-index: 2;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.word-flight-hint,
.word-flight-feedback {
  max-width: min(520px, 72vw);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(9, 26, 53, 0.72);
  color: #fff7db;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  backdrop-filter: blur(8px);
}

.word-flight-feedback {
  min-width: 180px;
  text-align: center;
}

.word-flight-feedback.is-good {
  background: rgba(31, 119, 80, 0.78);
}

.word-flight-feedback.is-warn {
  background: rgba(153, 74, 42, 0.82);
}

.word-flight-rescue,
.word-flight-loading {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 19, 42, 0.58);
  backdrop-filter: blur(8px);
}

.word-flight-rescue[hidden],
.word-flight-loading[hidden] {
  display: none;
}

.word-flight-rescue-panel,
.word-flight-loading-card {
  width: min(620px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 250, 230, 0.97), rgba(232, 244, 255, 0.96));
  color: #17365d;
  box-shadow: 0 24px 70px rgba(3, 11, 25, 0.38);
}

.word-flight-rescue-panel {
  padding: 18px;
  direction: inherit;
}

.word-flight-rescue-title {
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
  font-weight: 900;
  line-height: 1.1;
}

.word-flight-rescue-prompt {
  margin-top: 12px;
  line-height: 1.15;
  text-align: center;
  color: #102d54;
  overflow-wrap: anywhere;
}

.word-flight-rescue-context {
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 800;
  color: #31577f;
}

.word-flight-rescue-challenge {
  margin-top: 8px;
  font-size: clamp(1.65rem, 4.5vw, 2.7rem);
  font-weight: 950;
  color: #102d54;
}

.word-flight-rescue-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.word-flight-choice {
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  background: #225c90;
  color: #fff7db;
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.word-flight-choice:focus-visible {
  outline: 3px solid #ffd66b;
  outline-offset: 2px;
}

.word-flight-choice.is-correct {
  background: #27815b;
}

.word-flight-choice.is-wrong {
  background: #a94739;
}

.word-flight-loading-card {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 22px;
  font-weight: 900;
}

.word-flight-loader {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(35, 91, 142, 0.22);
  border-top-color: #235b8e;
  border-radius: 50%;
  animation: word-flight-spin 0.9s linear infinite;
}

@keyframes word-flight-spin {
  to {
    transform: rotate(360deg);
  }
}

body.pvp-searching .word-flight-playfield {
  filter: grayscale(0.45) brightness(0.72);
}

html body.word-flight-shell #pvpSearchBtn,
html body.word-flight-shell #pvpCancelBtn,
html body.word-flight-shell #pvpHint {
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 98px);
}

@media (max-width: 720px) {
  .word-flight-app {
    padding: 0;
  }

  .word-flight-stage-card {
    width: 100%;
    height: 100vh;
    aspect-ratio: auto;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .word-flight-topbar {
    grid-template-columns: auto 1fr;
    align-items: start;
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 6px;
  }

  .word-flight-topbar .back {
    min-height: 30px;
    padding: 5px 8px;
  }

  .word-flight-topbar .topbar-title {
    font-size: 1rem;
  }

  .word-flight-stats {
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 5px;
  }

  .word-flight-stats .stat-pill {
    padding: 5px 7px;
    font-size: 0.78rem;
  }

  .word-flight-overlay {
    left: 10px;
    right: 10px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 6px);
  }

  .word-flight-hint {
    display: none;
  }

  .word-flight-feedback {
    max-width: 100%;
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
  }

  html body.word-flight-shell #pvpSearchBtn,
  html body.word-flight-shell #pvpCancelBtn,
  html body.word-flight-shell #pvpHint {
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 72px);
    min-width: 118px;
    max-width: 42vw;
    padding: 10px 12px;
    font-size: 0.86rem;
  }

  .word-flight-rescue-options {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 520px) {
  .word-flight-app {
    padding: 0;
  }

  .word-flight-stage-card {
    width: 100%;
    height: 100vh;
    aspect-ratio: auto;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .word-flight-topbar {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .word-flight-overlay {
    bottom: 8px;
  }

  .word-flight-rescue-panel {
    padding: 12px;
  }

  .word-flight-rescue-title {
    font-size: 1rem;
  }

  .word-flight-rescue-prompt {
    margin-top: 8px;
  }

  .word-flight-rescue-context {
    font-size: clamp(0.82rem, 3.4vh, 1rem);
  }

  .word-flight-rescue-challenge {
    margin-top: 5px;
    font-size: clamp(1.15rem, 5vh, 1.65rem);
  }

  .word-flight-rescue-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-top: 10px;
  }

  .word-flight-choice {
    min-height: 42px;
    font-size: clamp(0.86rem, 3.8vh, 1.05rem);
  }

  html body.word-flight-shell #pvpSearchBtn,
  html body.word-flight-shell #pvpCancelBtn,
  html body.word-flight-shell #pvpHint {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 58px);
    min-width: 112px;
    max-width: 38vw;
    padding: 9px 11px;
    font-size: 0.8rem;
  }
}
