* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: #ffffff;
  color: #000000;
  font-family: "Courier New", Courier, monospace;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 16px;
}

.game-shell {
  width: min(560px, 100%);
  margin-top: 8px;
}

.top-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.profile-line {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  flex: 1;
}

.meta-block {
  flex: 1;
  min-width: 0;
}

.language-switch {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.2;
}

.language-switch a {
  color: #000000;
  text-decoration: underline;
}

.language-switch a[aria-current="page"] {
  text-decoration: none;
  font-weight: bold;
}

.app {
  width: 100%;
  background: #ffffff;
  border: 2px solid #000000;
  padding: 12px;
}

h1 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.2;
}

.title-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
}

.title-row h1 {
  margin: 0;
}

.title-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.ambient-note {
  margin: -2px 0 8px;
  font-size: 11px;
  line-height: 1.25;
}

.legend {
  border: 1px solid #000000;
  padding: 6px;
  background: #ffffff;
  font-size: 12px;
  line-height: 1.2;
}

.legend-title {
  margin: 0 0 4px;
  font-weight: bold;
}

.legend p {
  margin: 0 0 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend p:last-child {
  margin-bottom: 0;
}

.swatch {
  width: 10px;
  height: 10px;
  border: 1px solid #000000;
  display: inline-block;
}

.swatch-green {
  background: rgb(0, 170, 0);
}

.swatch-blue {
  background: rgb(0, 0, 255);
}

.swatch-red {
  background: rgb(255, 0, 0);
}

.swatch-black {
  background: rgb(0, 0, 0);
}

.swatch-gold {
  background: rgb(212, 175, 55);
}
.screen {
  width: 100%;
  border: 2px solid #000000;
  background: #ffffff;
  padding: 8px;
}

#worm-canvas {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  background: #ffffff;
  border: 1px solid #000000;
}

.stats,
.log {
  margin-top: 10px;
  border: 2px solid #000000;
  padding: 8px;
  background: #ffffff;
}

.stats p,
.log p {
  margin: 0 0 6px;
}

.stats p.stat-bar-row {
  margin: 0 0 8px;
}

.stat-bar-label {
  display: block;
  margin-bottom: 4px;
}

.stat-bar-track {
  display: block;
  width: 100%;
  height: 10px;
  border: 1px solid #000000;
  background: #ffffff;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: #000000;
}

.stats p:last-child,
.log p:last-child {
  margin-bottom: 0;
}

.log-title {
  font-weight: bold;
  margin: 0 0 6px;
}

.log.log-flash {
  animation: live-event-blink 0.35s ease-out;
}

#age {
  animation: age-blink 1.8s step-end infinite;
}

#age.age-near-gold {
  color: rgb(0, 140, 0);
  font-weight: bold;
}

#age.age-gold {
  color: rgb(212, 175, 55);
  font-weight: bold;
}

@keyframes age-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.35;
  }
}

@keyframes live-event-blink {
  0% {
    background: #000000;
    color: #ffffff;
  }
  100% {
    background: #ffffff;
    color: #000000;
  }
}

.repo-link {
  margin: 12px 0 0;
  text-align: center;
}

.session-controls {
  margin-top: 10px;
}

#reset-game {
  width: 100%;
  background: #000000;
  color: #ffffff;
}

#reset-game:focus-visible {
  outline: 2px solid #000000;
  outline-offset: 2px;
}

.repo-link a {
  color: #000000;
  text-decoration: underline;
}

.action-history {
  width: 100%;
  margin-top: 10px;
  border: 2px solid #000000;
  background: #ffffff;
  padding: 8px;
}

.action-history-title {
  margin: 0 0 6px;
  font-weight: bold;
}

#action-history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  height: 160px;
  overflow-y: auto;
}

#action-history-list li {
  margin: 0 0 4px;
  line-height: 1.25;
  word-break: break-word;
}

#action-history-list li:last-child {
  margin-bottom: 0;
}

.action-log-positive {
  color: rgb(0, 140, 0);
}

.action-log-negative {
  color: rgb(180, 0, 0);
}

.action-log-neutral {
  color: #000000;
}

#action-history-list li.action-log-final {
  font-weight: bold;
  border-left: 4px solid #000000;
  background: rgb(255, 244, 204);
  padding: 2px 4px;
}

.action-history-empty {
  opacity: 0.75;
}

.game-summary {
  width: 100%;
  margin-top: 10px;
  border: 2px solid #000000;
  background: #ffffff;
  padding: 8px;
}

.game-summary-title {
  margin: 0 0 6px;
  font-weight: bold;
}

#game-summary-text {
  margin: 0;
  line-height: 1.5;
  font-size: 13px;
}

.controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

button {
  border: 2px solid #000000;
  background: #ffffff;
  color: #000000;
  padding: 10px 8px;
  font: inherit;
  cursor: pointer;
  text-transform: lowercase;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 2px solid #000000;
  outline-offset: 2px;
}

@media (max-width: 420px) {
  h1 {
    font-size: 18px;
  }

  .title-note {
    font-size: 11px;
  }

  .app {
    padding: 10px;
  }

  .game-shell {
    margin-top: 8px;
  }

  .top-row {
    flex-direction: column;
    gap: 6px;
  }

  .legend {
    font-size: 11px;
    max-width: 100%;
    align-self: flex-start;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
