html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #e8f3fb;
}

#layout,
#stage,
.v3d-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.v3d-container canvas {
  touch-action: none;
}

.ui-hidden #lesson-ui,
.ui-hidden #result-modal {
  display: none;
}

.lesson-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: #1b2b38;
}

.top-strip {
  position: absolute;
  left: 18px;
  right: 72px;
  top: 16px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.title-block,
.score-board,
.control-panel,
.result-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(39, 68, 92, 0.13);
  box-shadow: 0 10px 28px rgba(22, 47, 68, 0.12);
  backdrop-filter: blur(12px);
}

.title-block {
  min-width: 250px;
  max-width: min(560px, 58vw);
  border-radius: 8px;
  padding: 12px 14px;
}

.lesson-title {
  font-size: 23px;
  font-weight: 900;
  line-height: 1.15;
  color: #163042;
}

.target-text {
  margin-top: 5px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  color: #406075;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(3, 78px);
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
}

.score-board div {
  min-height: 68px;
  display: grid;
  place-items: center;
  grid-template-rows: 36px 20px;
  border-left: 1px solid rgba(39, 68, 92, 0.1);
}

.score-board div:first-child {
  border-left: 0;
}

.score-board span {
  font-size: 25px;
  line-height: 1;
  font-weight: 950;
  color: #075e80;
}

.score-board small {
  font-size: 14px;
  font-weight: 800;
  color: #5b7180;
}

.control-panel {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(820px, calc(100vw - 28px));
  border-radius: 8px;
  padding: 12px;
  box-sizing: border-box;
  pointer-events: auto;
}

.panel-main {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) 134px;
  gap: 10px;
  align-items: end;
}

.coord-field {
  display: grid;
  gap: 5px;
}

.coord-field span {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 900;
  color: #2d485c;
}

.coord-field input {
  width: 100%;
  height: 48px;
  box-sizing: border-box;
  border: 1px solid rgba(33, 72, 98, 0.25);
  border-radius: 8px;
  background: #fff;
  color: #143144;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.coord-field input:focus {
  border-color: #1997b7;
  box-shadow: 0 0 0 3px rgba(25, 151, 183, 0.18);
}

.coord-field input::-webkit-outer-spin-button,
.coord-field input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.coord-field input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.btn {
  appearance: none;
  border: 1px solid rgba(33, 72, 98, 0.18);
  border-radius: 8px;
  background: #fff;
  color: #1d3a4e;
  min-height: 44px;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover,
.btn:focus-visible {
  background: #f2fbff;
  border-color: rgba(25, 151, 183, 0.4);
}

.btn.primary {
  border-color: rgba(224, 82, 45, 0.42);
  background: linear-gradient(180deg, #ff8b52, #ec5e32);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: linear-gradient(180deg, #ff9865, #e6532a);
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.message {
  min-height: 25px;
  margin-top: 9px;
  font-size: 17px;
  font-weight: 850;
  line-height: 1.45;
  color: #38586d;
  text-align: center;
}

.message.good {
  color: #127a48;
}

.message.warn {
  color: #b54622;
}

.message.bad {
  color: #b51f3a;
}

.result-modal {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(9, 24, 33, 0.2);
  backdrop-filter: blur(5px);
  pointer-events: auto;
  z-index: 6;
}

.result-modal.is-open {
  display: grid;
}

.result-card {
  width: min(360px, calc(100vw - 34px));
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  box-sizing: border-box;
}

.result-title {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 950;
  color: #14533c;
}

.result-body {
  margin: 10px 0 16px;
  font-size: 18px;
  line-height: 1.5;
  font-weight: 800;
  color: #365265;
}

@media (max-width: 760px), (max-height: 620px) {
  .top-strip {
    left: 10px;
    right: 56px;
    top: 10px;
    gap: 8px;
  }

  .title-block {
    min-width: 0;
    max-width: none;
    padding: 9px 10px;
  }

  .lesson-title {
    font-size: 20px;
  }

  .target-text {
    font-size: 15px;
  }

  .score-board {
    grid-template-columns: repeat(3, 56px);
  }

  .score-board div {
    min-height: 58px;
    grid-template-rows: 30px 18px;
  }

  .score-board span {
    font-size: 21px;
  }

  .score-board small {
    font-size: 12px;
  }

  .control-panel {
    bottom: 10px;
    padding: 9px;
  }

  .panel-main {
    grid-template-columns: 1fr 1fr 104px;
    gap: 8px;
  }

  .coord-field span {
    font-size: 14px;
  }

  .coord-field input {
    height: 42px;
    font-size: 21px;
  }

  .btn {
    min-height: 40px;
    padding: 0 10px;
    font-size: 15px;
  }

  .message {
    font-size: 15px;
    min-height: 22px;
  }
}

@media (max-width: 520px) {
  .top-strip {
    right: 46px;
    align-items: start;
  }

  .title-block {
    padding: 8px;
  }

  .lesson-title {
    font-size: 18px;
  }

  .target-text {
    font-size: 13px;
  }

  .score-board {
    grid-template-columns: 45px;
    grid-template-rows: repeat(3, 38px);
  }

  .score-board div {
    min-height: 38px;
    grid-template-rows: 20px 14px;
    border-left: 0;
    border-top: 1px solid rgba(39, 68, 92, 0.1);
  }

  .score-board div:first-child {
    border-top: 0;
  }

  .score-board span {
    font-size: 17px;
  }

  .score-board small {
    font-size: 10px;
  }

  .control-panel {
    width: calc(100vw - 16px);
    bottom: 8px;
    padding: 8px;
  }

  .panel-main {
    grid-template-columns: 1fr 1fr 88px;
    gap: 6px;
  }

  .coord-field span {
    font-size: 13px;
  }

  .coord-field input {
    height: 38px;
    font-size: 19px;
  }

  .panel-actions {
    gap: 6px;
    margin-top: 7px;
  }

  .btn {
    min-height: 36px;
    font-size: 13px;
    padding: 0 6px;
  }

  .message {
    margin-top: 6px;
    font-size: 13px;
  }
}
