@font-face {
  font-family: Arena;
  src: url('../assets/arena-display.woff') format('woff');
  font-display: swap;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101b27;
  color: #f2f0e8;
  font:
    14px Arial,
    sans-serif;
  touch-action: none;
}
button,
a,
select {
  font: inherit;
}
button,
a {
  min-height: 42px;
  border: 1px solid #4c6478;
  border-radius: 4px;
  padding: 10px 14px;
  background: #172c40;
  color: #f2f0e8;
  text-decoration: none;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid #94b9ff;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.52;
  cursor: default;
}
button.primary {
  background: #396de7;
  border-color: #6c9aff;
}
#training-world,
#battle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.training-header {
  position: absolute;
  z-index: 3;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.training-header strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 8px #000;
}
.training-header span {
  display: block;
  font-size: 11px;
  color: #d2e0e5;
  margin-top: 5px;
  text-shadow: 0 1px 5px #000;
}
.training-options {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.training-objective {
  position: absolute;
  z-index: 2;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: min(460px, 70vw);
  padding: 9px 12px;
  border: 1px solid #58718488;
  background: #102131d9;
  pointer-events: none;
  text-align: center;
}
.training-objective strong {
  font:
    24px Arena,
    Arial,
    sans-serif;
  letter-spacing: 0.08em;
}
.training-objective span {
  font-size: 12px;
}
.training-pilot {
  position: absolute;
  z-index: 3;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 240px;
  padding: 12px;
  background: #101e2de8;
  border: 1px solid #526b7d;
}
.training-pilot > strong {
  font-size: 13px;
  letter-spacing: 0.06em;
}
.training-pilot strong span {
  float: right;
  color: #a8c5f3;
  font-size: 11px;
}
.training-health {
  height: 20px;
  background: #253546;
  position: relative;
  margin: 7px 0;
}
.training-health i {
  display: block;
  background: #5798ad;
  height: 100%;
  width: 100%;
}
.training-health span {
  position: absolute;
  inset: 3px 0;
  text-align: center;
  font-size: 11px;
  font-weight: bold;
}
.training-pilot small {
  font-size: 11px;
  color: #c1d0dc;
}
.training-actions {
  position: absolute;
  z-index: 3;
  bottom: max(18px, env(safe-area-inset-bottom));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  gap: 7px;
}
.training-actions button {
  font-weight: bold;
  min-width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.training-actions kbd {
  font: 10px Arial;
  color: #bacbe0;
  font-weight: normal;
}
.training-hint {
  position: absolute;
  z-index: 2;
  bottom: 95px;
  right: 18px;
  font-size: 11px;
  background: #101e2dc9;
  padding: 8px;
  color: #d0dde5;
  pointer-events: none;
}
#touch-controls {
  display: none;
}
.stick {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  border: 2px solid #acc6d66b;
  background: #11273982;
  touch-action: none;
  user-select: none;
}
.stick span {
  position: absolute;
  inset: 15px;
  border: 1px solid #a9cce166;
  border-radius: 50%;
}
.stick i {
  position: absolute;
  left: calc(50% - 21px);
  top: calc(50% - 21px);
  width: 42px;
  height: 42px;
  background: #b5d6e9b3;
  border: 1px solid #eff8ff;
  border-radius: 50%;
  font-style: normal;
  text-align: center;
  line-height: 39px;
  color: #112536;
}
.stick small {
  position: absolute;
  bottom: -18px;
  width: 100%;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.12em;
}
#move-stick {
  left: max(28px, env(safe-area-inset-left));
}
#aim-stick {
  right: max(28px, env(safe-area-inset-right));
}
#training-notice {
  position: absolute;
  z-index: 4;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 20px;
  background: #112536ee;
  border: 1px solid #7293aa;
  text-align: center;
  max-width: 80vw;
  pointer-events: none;
}
dialog {
  color: #edf3f5;
  background: #122233;
  border: 1px solid #59768c;
  border-radius: 6px;
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100dvh - 24px);
  padding: 18px;
  overflow: auto;
  touch-action: pan-y;
}
dialog::backdrop {
  background: #050b13ba;
}
dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}
dialog h1 {
  font-size: 22px;
  margin: 0;
}
dialog header button {
  font-size: 24px;
  padding: 2px 12px;
}
dialog p {
  color: #c8d7e1;
  line-height: 1.5;
}
dialog .menu-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 5px;
}
dialog .upgrade-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
dialog .upgrade-list button {
  display: flex;
  justify-content: space-between;
  text-align: left;
  align-items: center;
  gap: 12px;
}
dialog .upgrade-list small {
  display: block;
  font-size: 11px;
  color: #b9ccda;
  margin-top: 4px;
}
dialog label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding: 14px 0;
  border-bottom: 1px solid #354c60;
}
dialog select {
  background: #223a50;
  color: #fff;
  padding: 8px;
  border: 1px solid #59768c;
  border-radius: 3px;
}
.return-note {
  font-size: 11px;
}
.training-result {
  font-size: 28px;
  color: #b4d3ff;
}
@media (pointer: coarse) {
  #touch-controls {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
  }
  #touch-controls .stick {
    pointer-events: auto;
  }
  .training-hint {
    display: none;
  }
  .training-pilot {
    left: 50%;
    transform: translateX(-50%);
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 200px;
    padding: 8px 10px;
  }
  .training-actions {
    right: 158px;
    bottom: 94px;
    display: grid;
    grid-template-columns: repeat(2, 60px);
    gap: 5px;
  }
  .training-actions button {
    min-width: 0;
    min-height: 42px;
    padding: 7px 4px;
    font-size: 11px;
  }
  .training-actions kbd {
    display: none;
  }
  .training-header > div:first-child {
    max-width: 45%;
  }
  .training-header span {
    max-width: 250px;
  }
  .training-objective {
    top: 73px;
    width: 310px;
    padding: 7px 10px;
  }
  .training-options button,
  .training-options a {
    padding: 8px 10px;
    font-size: 12px;
  }
}
@media (max-width: 700px) and (orientation: landscape) {
  .training-header {
    top: 8px;
    left: 12px;
    right: 12px;
    gap: 5px;
  }
  .training-header strong {
    font-size: 12px;
  }
  .training-header span {
    font-size: 9px;
    max-width: 210px;
    line-height: 1.2;
  }
  .training-options {
    gap: 4px;
  }
  .training-options button,
  .training-options a {
    padding: 6px 8px;
    min-height: 34px;
    font-size: 11px;
  }
  .training-objective {
    top: 59px;
    padding: 4px 8px;
    width: 270px;
  }
  .training-objective strong {
    font-size: 19px;
  }
  .training-objective span {
    font-size: 10px;
  }
  .stick {
    width: 94px;
    height: 94px;
    bottom: 22px;
  }
  #move-stick {
    left: 22px;
  }
  #aim-stick {
    right: 22px;
  }
  .training-pilot {
    width: 166px;
    bottom: 8px;
    padding: 7px 8px;
  }
  .training-pilot > strong {
    font-size: 10px;
  }
  .training-pilot small {
    font-size: 10px;
  }
  .training-actions {
    right: 128px;
    bottom: 98px;
    grid-template-columns: repeat(2, 54px);
    gap: 4px;
  }
  .training-actions button {
    min-height: 34px;
    font-size: 10px;
    padding: 6px 2px;
  }
  .training-health {
    height: 17px;
    margin: 5px 0;
  }
  .training-health span {
    top: 2px;
    font-size: 10px;
  }
}
@media (orientation: portrait) and (pointer: coarse) {
  .training-header {
    flex-direction: column;
    gap: 10px;
  }
  .training-header > div:first-child {
    max-width: 100%;
  }
  .training-header span {
    max-width: 100%;
  }
  .training-objective {
    top: 125px;
    width: calc(100vw - 40px);
  }
  .training-pilot {
    top: 205px;
    bottom: auto;
    left: 20px;
    transform: none;
    width: 210px;
  }
  .training-actions {
    right: 22px;
    bottom: 170px;
    grid-template-columns: repeat(2, 58px);
  }
  #training-notice {
    top: 47%;
  }
}

[data-training-mode='breakline'] {
  --breakline-surface: #1b2523f1;
  --breakline-edge: #a49679;
  --breakline-text: #f4e9d5;
  --breakline-accent: #f5a967;
}

[data-training-mode='breakline'] [hidden] {
  display: none;
}

[data-training-mode='breakline'] .training-header strong {
  font-family: Arena, Arial, sans-serif;
  font-size: 23px;
  color: var(--breakline-text);
}

[data-training-mode='breakline'] .training-header span {
  margin-top: 1px;
}

[data-training-mode='breakline'] :is(button, a, .training-objective, .training-pilot, dialog) {
  background: var(--breakline-surface);
  color: var(--breakline-text);
  border-color: var(--breakline-edge);
}

[data-training-mode='breakline'] button.primary {
  background: var(--breakline-accent);
  border-color: #ffcfab;
  color: #241c16;
  font-weight: bold;
}

[data-training-mode='breakline'] .training-objective {
  width: min(330px, calc(100vw - 32px));
  top: max(13px, env(safe-area-inset-top));
  padding: 6px 10px 8px;
  border-top: 2px solid var(--breakline-accent);
  gap: 3px;
}

[data-training-mode='breakline'] .training-objective strong {
  color: #ffe3ba;
  font-variant-numeric: tabular-nums;
}

.relay-charge {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.relay-charge label {
  display: grid;
  gap: 3px;
  font-size: 10px;
  text-align: left;
}

.relay-charge progress {
  appearance: none;
  border: 0;
  width: 100%;
  height: 5px;
  color: var(--charge);
  background: #50584d;
  --charge: #87dbef;
}

.relay-charge #rival-relay {
  --charge: #ffa683;
}

.relay-charge progress::-webkit-progress-bar {
  background: #50584d;
}
.relay-charge progress::-webkit-progress-value {
  background: var(--charge);
}
.relay-charge progress::-moz-progress-bar {
  background: var(--charge);
}

[data-training-mode='breakline'] .training-pilot {
  border-top: 2px solid #87dbef;
}

[data-training-mode='breakline'] :is(#training-level, #training-record) {
  display: none;
}

[data-training-mode='breakline'] .training-health {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  [data-training-mode='breakline'] .training-objective {
    top: max(56px, calc(env(safe-area-inset-top) + 50px));
    width: min(270px, calc(100vw - 32px));
  }
}

@media (pointer: coarse) {
  [data-training-mode='breakline'] .training-actions {
    grid-template-columns: repeat(2, minmax(55px, auto));
  }

  [data-training-mode='breakline'] :is(.training-options, .training-actions) button,
  [data-training-mode='breakline'] .training-options a {
    min-height: 44px;
  }
}

@media (orientation: portrait) and (pointer: coarse) {
  [data-training-mode='breakline'] .training-header {
    flex-direction: row;
    gap: 6px;
  }

  [data-training-mode='breakline'] .training-header strong {
    font-size: clamp(15px, 4.6vw, 21px);
  }

  [data-training-mode='breakline'] .training-header span {
    display: none;
  }

  [data-training-mode='breakline'] .training-objective {
    top: max(64px, calc(env(safe-area-inset-top) + 51px));
  }

  [data-training-mode='breakline'] .training-pilot {
    top: auto;
    bottom: max(9px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: min(175px, calc(100vw - 28px));
  }

  [data-training-mode='breakline'] .training-actions {
    bottom: calc(max(78px, env(safe-area-inset-bottom) + 68px) + clamp(70px, 23vw, 94px) + 10px);
  }

  [data-training-mode='breakline'] .stick {
    width: clamp(70px, 23vw, 94px);
    height: clamp(70px, 23vw, 94px);
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 68px));
  }
}
