* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #05051b;
  color: white;
  font-family: system-ui, sans-serif;
  overflow: hidden;
}
canvas {
  display: block;
}
header {
  position: absolute;
  top: 22px;
  left: 5%;
  right: 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
h1 {
  margin: 0;
  font-size: clamp(20px, 4vw, 34px);
}
small {
  color: #acd0ee;
}
#hud {
  text-align: right;
  font-weight: bold;
}
#prompt {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
#letter {
  font-size: clamp(70px, 14vw, 125px);
  font-weight: 900;
  text-shadow: 0 0 35px #47eaff;
}
#track {
  width: 190px;
  background: #ffffff25;
  border-radius: 10px;
  overflow: hidden;
}
#time {
  height: 9px;
  background: #60ffcf;
  transform-origin: left;
}
footer {
  position: absolute;
  bottom: 24px;
  width: 100%;
  text-align: center;
}
#message {
  font-size: 20px;
  font-weight: 700;
  margin: 12px;
}
#keys {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
kbd {
  padding: 8px 18px;
  border: 1px solid #8adaff80;
  background: #12244c;
  border-radius: 10px;
  font: bold 24px system-ui;
}
kbd.active {
  background: #68ebd7;
  color: #081c33;
}
details {
  position: absolute;
  left: 20px;
  bottom: 20px;
  background: #0e1736ed;
  padding: 12px;
  border-radius: 12px;
  max-width: 260px;
}
summary {
  cursor: pointer;
}
input {
  width: 100%;
  padding: 8px;
  margin: 8px 0;
}
button {
  padding: 8px 12px;
  cursor: pointer;
}
#error {
  position: absolute;
  top: 40%;
  width: 100%;
  text-align: center;
}
@media (max-width: 700px) {
  details {
    bottom: 130px;
  }
  #message {
    font-size: 16px;
  }
}

#keys {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}
.key-row {
  display: flex;
  gap: 5px;
}
.key {
  width: clamp(25px, 4.5vw, 43px);
  height: clamp(30px, 4vw, 39px);
  padding: 0;
  border-radius: 7px;
  border: 1px solid #8adaff80;
  background: #12244c;
  color: white;
  font: 700 22px system-ui;
}
.key.unused {
  opacity: 0.24;
  cursor: default;
}
.key.active {
  background: #68ebd7;
  color: #081c33;
  box-shadow: 0 0 20px #68ebd755;
}
footer {
  bottom: 15px;
}
details {
  bottom: auto;
  top: 90px;
  z-index: 2;
}
#message {
  font-size: 17px;
}
#prompt {
  top: 20%;
}
#letter {
  font-size: clamp(65px, 11vw, 105px);
}

footer {
  background: #05051b;
  border-top: 1px solid #8adaff25;
  padding-top: 6px;
}
.header-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}
.keyboard-toggle {
  background: #12244c;
  color: #d9faff;
  border: 1px solid #8adaff80;
  border-radius: 8px;
}
@media (max-height: 580px) {
  header {
    top: 10px;
  }
  h1 {
    font-size: 20px;
  }
  header small {
    display: none;
  }
  #letter {
    font-size: 48px;
  }
  #prompt {
    top: 18%;
  }
  #message {
    margin: 5px;
  }
  .key {
    height: 28px;
    font-size: 18px;
  }
  .key-row {
    gap: 4px;
  }
  #keys {
    gap: 3px;
  }
  details {
    top: 72px;
    max-height: 65vh;
    overflow: auto;
  }
}

/* Translucent flight deck. */
body {
  background: #040915;
  color: #e6f7ff;
}
header {
  top: 20px;
  left: 24px;
  right: 24px;
  z-index: 1;
  align-items: flex-start;
}
h1 {
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: -0.05em;
  font-weight: 600;
}
header small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #8ba9c2;
}
#hud,
details,
footer,
.keyboard-toggle {
  background: linear-gradient(135deg, #152c426e, #081426a8);
  border: 1px solid #a3ddff26;
  box-shadow:
    inset 0 1px 0 #ffffff0d,
    0 12px 40px #00000024;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
#hud {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
}
.keyboard-toggle {
  border-radius: 20px;
  font-size: 11px;
  padding: 7px 13px;
  color: #bce8ef;
}
#prompt {
  top: 22%;
  pointer-events: none;
}
#letter {
  line-height: 1.2;
  font-weight: 500;
  text-shadow:
    0 0 22px #83fff9aa,
    0 0 70px #3bcde65c;
}
#track {
  width: 150px;
  height: 3px;
  margin: 14px auto 0;
  background: #c2f3ff18;
  box-shadow: 0 0 18px #5bfff51a;
}
#time {
  height: 3px;
  background: linear-gradient(90deg, #54a5ff, #8bffe2);
  box-shadow: 0 0 12px #8bffe2;
}
footer {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  border-radius: 22px;
  padding: 8px 24px 16px;
}
#message {
  font-size: 13px;
  font-weight: 500;
  color: #bbdce8;
  margin: 8px 0 14px;
  letter-spacing: 0.025em;
}
.key {
  background: linear-gradient(150deg, #53799630, #15283e65);
  border: 1px solid #a5dfff30;
  color: #cde9f2;
  font-size: 17px;
  font-weight: 500;
  border-radius: 9px;
  box-shadow: inset 0 1px 0 #ffffff0d;
  transition:
    background 0.18s,
    box-shadow 0.18s,
    transform 0.18s;
}
.key.unused {
  opacity: 0.28;
}
.key.active {
  background: linear-gradient(135deg, #adffe8, #65d9ed);
  color: #062639;
  box-shadow:
    0 0 24px #65e6dc44,
    inset 0 1px 0 #ffffffaa;
  transform: translateY(-2px);
}
button:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 2px solid #8bffe2;
  outline-offset: 4px;
}
.key.enabled:hover {
  border-color: #9bffe7;
}
details {
  left: 24px;
  top: 100px;
  border-radius: 16px;
  font-size: 12px;
  color: #bdd5e6;
}
details[open] {
  background: #0b1b2eeb;
}
summary {
  color: #c3eeef;
}
details form {
  margin-top: 16px;
}
input {
  background: #020b1780;
  color: #e6f7ff;
  border: 1px solid #a5dfff30;
  border-radius: 8px;
}
details button {
  background: #8bffe2;
  color: #082537;
  border: 0;
  border-radius: 8px;
  margin-bottom: 12px;
}
#error {
  z-index: 3;
  background: #10243e;
  padding: 20px;
}
@media (max-width: 700px) {
  header {
    left: 14px;
    right: 14px;
    top: 14px;
    gap: 10px;
  }
  header small {
    max-width: 145px;
    line-height: 1.6;
    font-size: 10px;
  }
  #hud {
    max-width: 180px;
    font-size: 10px;
    line-height: 1.7;
    padding: 8px 10px;
  }
  details {
    left: 14px;
    top: 115px;
  }
  footer {
    padding: 6px 10px 12px;
  }
  #message {
    font-size: 11px;
  }
  .key-row {
    gap: 4px;
  }
}
@media (max-height: 580px) {
  header {
    top: 10px;
  }
  header small {
    display: none;
  }
  details {
    top: 76px;
  }
  #prompt {
    top: 25%;
  }
  #letter {
    font-size: 42px;
  }
  #track {
    margin-top: 5px;
  }
  footer {
    padding-top: 3px;
    padding-bottom: 8px;
    bottom: 6px;
  }
  #message {
    margin: 4px 0 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .key {
    transition: none;
  }
}
footer {
  left: 14px;
  bottom: 14px;
  transform: none;
  padding: 6px 12px 12px;
}
.drag-handle {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: #9bbdcb;
  font: 11px system-ui;
  letter-spacing: 0.08em;
  cursor: grab;
  touch-action: none;
  padding: 6px;
}
.drag-handle:active {
  cursor: grabbing;
}
footer .key {
  width: clamp(23px, 3vw, 32px);
  height: 30px;
  font-size: 15px;
}
@media (max-width: 700px) {
  footer {
    left: 10px;
    bottom: 10px;
  }
}
#prompt {
  top: 116px;
  left: auto;
  right: 22px;
  transform: none;
}
#letter {
  font-size: 28px;
}
#track {
  width: 100px;
  margin-top: 6px;
}
#flight-status {
  position: fixed;
  bottom: 12px;
  right: 18px;
  max-width: 300px;
  text-align: right;
  z-index: 2;
}
#message {
  padding: 8px 12px;
  border-radius: 12px;
  background: #071322cc;
}
#hoop-label {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  color: #b5fff1;
  font-size: 24px;
  font-weight: 700;
  text-shadow: 0 0 12px #071322;
}
#hoop-label.edge {
  padding: 8px 12px;
  border: 1px solid #80ffe780;
  border-radius: 18px;
  background: #071322cc;
  font-size: 16px;
}
.deck-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.deck-controls button,
#restart {
  background: #10283e;
  color: #c5fff0;
  border: 1px solid #8adaff60;
  border-radius: 8px;
  font-size: 11px;
}
.key.feedback-good {
  background: #77ffe3;
  box-shadow: 0 0 24px #77ffe3;
  color: #092737;
}
.key.feedback-wrong {
  background: #ffbc65;
  box-shadow: 0 0 24px #ffbc6577;
  color: #35230a;
}
select {
  width: 100%;
  background: #10283e;
  color: #ddf7ff;
  padding: 8px;
  margin: 8px 0 14px;
  border: 1px solid #8adaff60;
  border-radius: 8px;
}
details {
  max-height: calc(100dvh - 145px);
  overflow: auto;
}
@media (max-width: 700px) {
  #flight-status {
    bottom: auto;
    top: 160px;
    right: 12px;
    max-width: 190px;
  }
  #message {
    font-size: 10px;
  }
  #prompt {
    top: 112px;
    right: 16px;
  }
}

.underwater-header > div:first-child {
  color: #fff;
  padding: 5px 12px;
  background: #073142d9;
  border-radius: 12px;
}
.underwater-header small {
  color: #caeee7;
}

[data-environment='land'] {
  --rally-panel: #242822ec;
  --rally-border: #f9e4af47;
  --rally-ink: #fff2cd;
}
[data-environment='land'] header > div:first-child {
  padding: 8px 14px;
  border-left: 4px solid #f7ae4e;
  border-radius: 2px 10px 10px 2px;
  background: var(--rally-panel);
}
[data-environment='land'] h1 {
  color: #fff4d5;
}
[data-environment='land'] header small {
  color: #ffdc95;
}
[data-environment='land']
  :is(#hud, .keyboard-toggle, details, footer, #message, #restart) {
  background: var(--rally-panel);
  border-color: var(--rally-border);
  color: var(--rally-ink);
}
[data-environment='land'] :is(summary, .drag-handle, details small) {
  color: #ffe0a1;
}
[data-environment='land'] :is(.deck-controls button, select, .key) {
  background: #404238;
  border-color: var(--rally-border);
  color: var(--rally-ink);
}
[data-environment='land'] :is(.key.active, .key.feedback-good, details button) {
  background: #ffcb73;
  color: #29261e;
  box-shadow: none;
}
[data-environment='land'] .key.feedback-wrong {
  background: #e76d4c;
  color: #26190c;
}
[data-environment='land'] #prompt {
  padding: 5px 10px 9px;
  background: var(--rally-panel);
  border-radius: 8px;
}
[data-environment='land'] #letter {
  color: var(--rally-ink);
  text-shadow: none;
}
[data-environment='land'] #time {
  background: #ffbf63;
}
[data-environment='land'] #hoop-label {
  background: #292722ed;
  color: #fff4d5;
  padding: 0.02em 0.35em 0.13em;
  border: 1px solid #ffe6a9;
  border-radius: 5px;
  line-height: 1.1;
  text-shadow: none;
}
