:root {
  color-scheme: dark;
  --screen: #090c0c;
  --toolbar: #181b1c;
  --control: #252a2c;
  --edge: #3e4646;
  --text: #edf2ee;
  --muted: #a7b4b2;
  --teal: #80dece;
  --green: #a4ec7d;
  --red: #ff9090;
  --interface: Roboto, "Helvetica Neue", Arial, sans-serif;
  --code: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
  font-family: var(--interface);
  font-size: 100%;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #121516;
  color: var(--text);
  line-height: 1.45;
}

button {
  min-height: 2.75rem;
  border: 1px solid var(--edge);
  border-radius: 3px;
  background: var(--control);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

button:active:not(:disabled) {
  background: #3a5450;
  border-color: var(--teal);
}

button:disabled {
  background: #171c1d;
  color: #879492;
  border-color: #2d3434;
  cursor: default;
}

.primary {
  background: #2a3f3c;
  border-color: #54877f;
  color: #d9fff5;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 29rem;
  margin-inline: auto;
  background: var(--screen);
  border-inline: 1px solid #282d2d;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) 0
    max(1rem, env(safe-area-inset-left));
  background: var(--toolbar);
  border-bottom: 1px solid #405451;
}

.toolbar img {
  flex: none;
}

.toolbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.015em;
}

.toolbar-button {
  background: transparent;
  border-color: transparent;
  color: var(--teal);
  font-size: 0.875rem;
}

.screen {
  padding: 1rem max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.menu {
  padding-top: 1.25rem;
}

.menu-buttons {
  display: grid;
  gap: 0.5rem;
}

.menu-buttons button {
  min-height: 3.125rem;
}

.debug-buttons {
  margin-top: 1.125rem;
  padding-top: 1.125rem;
  border-top: 1px solid #303838;
}

.game {
  display: grid;
  gap: 1rem;
}

.start-pause {
  width: 100%;
}

.player {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding-inline: 0.125rem;
  font-variant-numeric: tabular-nums;
}

.reputation {
  font-size: 1.25rem;
  font-weight: 500;
}

.cash {
  color: var(--teal);
  overflow-wrap: anywhere;
  text-align: right;
}

.utilities,
.keys {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.375rem;
}

.utilities > div {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.utilities button {
  min-width: 0;
  padding-inline: 0.175rem;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.utilities [data-buy] {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.firewall {
  padding-top: 0.875rem;
  border-top: 1px solid #303838;
}

.host {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.rate,
.progress,
.code-head {
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.rate {
  margin-inline-start: 0.25rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 400;
}

.progress {
  color: var(--teal);
  flex-shrink: 0;
  font-family: var(--code);
}

.tracking {
  height: 0.5rem;
  margin: 0.625rem 0 1rem;
  background: #252e2b;
  border-radius: 2px;
  overflow: hidden;
}

.tracking span {
  display: block;
  width: var(--fill, 0%);
  height: 100%;
  background: var(--track-color, var(--green));
}

.code-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  min-height: 1.25rem;
  margin-bottom: 0.375rem;
  color: var(--muted);
}

.code ol {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 2.85rem);
  gap: 0.3rem;
  padding: 0;
  margin: 0 0 0.875rem;
  list-style: none;
}

.code-cell {
  display: grid;
  place-items: center;
  min-height: 2.75rem;
  border: 1px solid #475454;
  border-radius: 2px;
  background: #141918;
  font: 600 1.325rem / 1 var(--code);
}

.code-cell.correct {
  background: #1a2b18;
  border-color: #487a46;
  color: var(--green);
}

.code-cell.incorrect {
  background: #331e1c;
  border-color: #9f5450;
  color: var(--red);
}

#feedback.granted {
  color: var(--green);
}

#feedback.denied {
  color: var(--red);
}

.keys button {
  min-height: 4rem;
  border-color: #52605e;
  font: 600 1.5rem / 1 var(--code);
}

.keys button:disabled {
  border-color: #2d3434;
}

.game-log {
  min-height: 4rem;
  color: var(--green);
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
}

.text-screen p {
  margin: 0 0 1rem;
}

.help-list {
  margin: 0;
}

.help-list dt {
  font-weight: 700;
  margin-top: 0.875rem;
  color: var(--teal);
}

.help-list dd {
  margin: 0.125rem 0 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid var(--edge);
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

dialog {
  width: min(calc(100% - 2rem), 22rem);
  max-height: calc(100% - 2rem);
  overflow: auto;
  padding: 1.25rem;
  border: 1px solid #475453;
  border-radius: 5px;
  background: var(--toolbar);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(4 7 7 / 76%);
}

dialog h2 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
}

#success-title,
.result-reputation {
  color: var(--green);
}

.countdown-dialog {
  border-color: #405451;
  text-align: center;
  padding: 0.75rem;
}

.countdown-dialog button {
  width: 100%;
  min-height: 6rem;
  background: transparent;
  border-color: transparent;
  color: var(--green);
  font: 600 clamp(2rem, 9vw, 3.25rem) / 1 var(--code);
}

.result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.result dd {
  margin: 0;
  text-align: right;
  color: var(--teal);
}

.result-reputation {
  margin: 0.5rem 0 1rem;
}

dialog progress {
  width: 100%;
  height: 0.55rem;
  display: block;
  accent-color: var(--green);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (max-width: 29rem) {
  .app {
    border-inline: 0;
  }
}
