:root {
  color-scheme: dark;
  background: #10151c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  /* Safari on iOS draws its toolbar over a page that is 100% high. The dynamic
     unit gives only the height that the browser leaves visible. */
  height: 100dvh;
  margin: 0;
  overflow: hidden;
}

body {
  background: #10151c;
}

#app {
  display: grid;
  /* The track must have a definite size. An auto row gets its size from the
     canvas. The height of the canvas is a percentage of that row. Thus the
     canvas becomes larger at each frame. */
  grid-template: 100% / 100%;
  place-items: center;
  position: relative;
  /* The canvas keeps away from the camera housing and the home indicator. The
     HUD is drawn in the canvas, so it stays clear of them too. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  image-rendering: pixelated;
  touch-action: none;
  /* A long press on the canvas must not select it or open the iOS callout. */
  user-select: none;
  -webkit-touch-callout: none;
}

.release-screen {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  padding: max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  overflow: auto;
  place-items: center;
  color: #f4f6f8;
  background: rgb(13 17 22 / 46%);
  font-family: ui-sans-serif, -apple-system, "SF Pro Display", "Inter",
    system-ui, "Helvetica Neue", sans-serif;
  backdrop-filter: blur(5px);
}

.release-screen[hidden] {
  display: none;
}

.release-card {
  width: min(680px, 100%);
  max-height: 100%;
  padding: 28px;
  overflow: auto;
  background: rgb(13 17 22 / 94%);
  border: 1px solid rgb(44 52 61 / 90%);
  border-radius: 10px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 34%);
}

.release-kicker {
  margin: 0 0 8px;
  color: #48b8aa;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.release-card h1 {
  margin: 0;
  color: #f4f6f8;
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.release-card button {
  min-height: 46px;
  padding: 0 18px;
  color: #f4f6f8;
  background: #2c343d;
  border: 1px solid #2c343d;
  border-radius: 5px;
  font: 700 11px/1 ui-sans-serif, -apple-system, "SF Pro Display", "Inter",
    system-ui, "Helvetica Neue", sans-serif;
  letter-spacing: 0.12em;
}

.release-card button:hover {
  border-color: #9aa4ad;
}

.release-card button:focus-visible {
  outline: 3px solid #48b8aa;
  outline-offset: 3px;
}

.release-card .release-primary {
  color: #0d1116;
  background: #48b8aa;
  border-color: #48b8aa;
}

#finish {
  background: rgb(13 17 22 / 14%);
  backdrop-filter: blur(2px);
}

.finish-card {
  width: min(620px, 100%);
  background: rgb(13 17 22 / 68%);
  backdrop-filter: blur(9px);
}

.finish-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 22px;
  overflow: hidden;
  background: #2c343d;
  border: 1px solid #2c343d;
  border-radius: 6px;
}

.finish-summary > div {
  min-width: 0;
  padding: 14px;
  background: rgb(13 17 22 / 62%);
}

.finish-summary span {
  display: block;
  margin-bottom: 7px;
  color: #9aa4ad;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.finish-summary output {
  display: block;
  overflow: hidden;
  color: #f4f6f8;
  font-size: clamp(18px, 3vw, 27px);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.release-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.release-actions button {
  flex: 1 1 150px;
}

@media (max-width: 600px) {
  .release-card {
    padding: 20px;
  }

  .finish-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 480px) and (min-width: 601px) {
  .release-card {
    padding: 18px;
  }

  .finish-summary {
    margin-top: 12px;
  }

  .release-actions {
    margin-top: 12px;
  }
}

#app.model-mode {
  background: #f7f7f7;
}

#app.model-mode #game {
  position: absolute;
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  z-index: 1;
  image-rendering: auto;
}

#model-mark-layer {
  position: absolute;
  z-index: 2;
  width: min(100vw, 100vh);
  height: min(100vw, 100vh);
  pointer-events: none;
}

#model-mark-layer[hidden] {
  display: none;
}

#model-mark-layer.mark-mode,
#model-mark-layer.edit-mode {
  cursor: crosshair;
  pointer-events: auto;
}

#app.native-view #game {
  image-rendering: auto;
}

#model-check {
  position: absolute;
  z-index: 3;
  right: 12px;
  top: 12px;
  width: min(300px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 12px;
  color: #ecf1d0;
  background: rgb(12 17 24 / 92%);
  border: 1px solid #637078;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.45;
}

#model-check-title,
#model-check-data {
  display: block;
  white-space: pre-wrap;
}

.model-links {
  display: flex;
  gap: 12px;
  margin: 8px 0;
}

.model-links a {
  color: #ffdf68;
}

.model-toggle {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 0 0 9px;
}

#model-shader {
  accent-color: #ffdf68;
}

#model-light-controls {
  margin: 0 0 9px;
  padding: 8px;
  border: 1px solid #637078;
}

.model-light-grid {
  display: grid;
  grid-template-columns: 78px minmax(70px, 1fr) 42px;
  gap: 6px;
  align-items: center;
  margin-bottom: 7px;
}

.model-light-grid input {
  min-width: 0;
  accent-color: #ffdf68;
}

.model-light-grid output {
  color: #ffdf68;
  text-align: right;
}

#model-light-camera {
  margin-bottom: 5px;
}

#model-free-camera {
  accent-color: #ffdf68;
}

#model-camera-controls {
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid #637078;
}

#model-camera-controls.model-mark-lock {
  opacity: 0.5;
}

#model-point-editor,
#model-mark-editor {
  margin: 10px 0;
  padding: 8px;
  border: 1px solid #637078;
}

.model-point-actions,
.model-mark-actions,
.model-mark-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-point-actions,
.model-mark-actions {
  margin-bottom: 6px;
}

#model-point-editor.edit-mode #model-point-toggle,
#model-mark-editor.mark-mode #model-mark-toggle {
  color: #10151c;
  background: #ffdf68;
}

#model-point-status,
#model-mark-status {
  display: block;
  min-height: 2.8em;
  color: #bbc5ca;
}

.model-point-fields {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 6px 8px;
  align-items: center;
  margin-bottom: 6px;
}

.model-point-fields select {
  width: 100%;
  min-width: 0;
  padding: 4px;
  color: #10151c;
  background: #ecf1d0;
  border: 0;
  border-radius: 2px;
  font: inherit;
}

.model-point-fields .model-toggle {
  grid-column: 1 / -1;
  margin: 0;
}

.model-edit-point {
  position: absolute;
  min-width: 27px;
  min-height: 27px;
  padding: 2px;
  color: #10151c;
  background: #ffdf68;
  border: 2px solid #10151c;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 80%);
  transform: translate(-50%, -50%);
  touch-action: none;
}

.model-edit-shoulder {
  background: #70d7ff;
}

.model-edit-lower {
  background: #ff9770;
}

#model-mark-form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #637078;
}

.model-mark-fields {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px 8px;
  align-items: center;
}

.model-mark-fields select,
.model-mark-fields textarea {
  width: 100%;
  min-width: 0;
  padding: 4px;
  color: #10151c;
  background: #ecf1d0;
  border: 0;
  border-radius: 2px;
  font: inherit;
}

.model-mark-fields textarea {
  resize: vertical;
}

.model-mark-form-actions {
  margin-top: 7px;
}

#model-mark-list {
  display: grid;
  max-height: 188px;
  margin: 8px 0 0;
  padding: 0;
  gap: 5px;
  overflow: auto;
  list-style: none;
}

#model-mark-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 4px;
}

.model-mark-item {
  overflow: hidden;
  color: #ecf1d0;
  background: #303b45;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-mark-done .model-mark-item {
  color: #89959d;
  text-decoration: line-through;
}

.model-mark-done-button,
.model-mark-delete {
  padding-inline: 6px;
  color: #bbc5ca;
  background: #202a33;
}

.model-mark-delete {
  color: #ffb2a8;
}

.model-mark-region {
  position: absolute;
  left: var(--mark-x);
  top: var(--mark-y);
  width: var(--mark-size);
  aspect-ratio: 1;
  border: 3px solid #ff5a45;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(16 21 28 / 85%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.model-mark-region.model-mark-selected {
  border-color: #ffdf68;
}

.model-mark-region.model-mark-done {
  border-color: #8b979f;
  opacity: 0.55;
}

.model-mark-region.model-mark-draft {
  border-style: dashed;
  border-color: #ffdf68;
}

.model-mark-pin {
  position: absolute;
  left: 50%;
  top: 0;
  min-width: 24px;
  min-height: 24px;
  padding: 3px;
  color: #10151c;
  background: #ffdf68;
  border: 2px solid #10151c;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.model-camera-grid {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 5px 8px;
  align-items: center;
}

.model-camera-grid input {
  width: 100%;
  min-width: 0;
  color: #10151c;
  background: #ecf1d0;
  border: 0;
  border-radius: 2px;
  font: inherit;
}

.model-camera-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0 5px;
}

.model-camera-actions a {
  color: #ffdf68;
}

#qa {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: min(560px, calc(100% - 24px));
  padding: 10px;
  color: #ecf1d0;
  background: rgb(12 17 24 / 88%);
  border: 1px solid #637078;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.45;
  backdrop-filter: blur(4px);
}

.qa-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

button {
  padding: 5px 9px;
  color: #10151c;
  background: #ecf1d0;
  border: 0;
  border-radius: 3px;
  font: inherit;
  cursor: pointer;
}

#qa-state {
  display: block;
  white-space: pre-wrap;
}

#error {
  position: absolute;
  inset: 16px;
  overflow: auto;
  padding: 16px;
  color: #fff3e2;
  background: #491f24;
  border: 2px solid #ff7281;
  white-space: pre-wrap;
}
