body {
  margin: 0;
  min-height: 100vh;
  font-family: "Courier New", Courier, monospace;
  background:
    linear-gradient(180deg, rgba(26, 34, 24, 0.95) 0%, rgba(10, 13, 9, 0.98) 100%);
  background-size: 100% 100%;
  color: #d8e0cc;
  image-rendering: pixelated;
}

.panel {
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
  background-image:
    linear-gradient(rgba(143, 180, 123, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(143, 180, 123, 0.06) 1px, transparent 1px);
  background-size: 8px 8px;
}

.hero,
.start-card,
.status-card,
.rules-card,
.footer-bar,
.message,
.choice-button,
.custom-action-form,
.talk-controls {
  border: 2px solid #5c744f;
  border-radius: 0;
  box-shadow:
    inset -2px -2px 0 #0a0d09,
    inset 2px 2px 0 rgba(214, 230, 200, 0.06),
    4px 4px 0 rgba(6, 8, 5, 0.9);
}

.hero {
  padding: 14px;
  background: rgba(15, 22, 15, 0.95);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #a3ca8f;
  text-shadow: 1px 1px 0 #0a0d09;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  color: #edf4e2;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #0a0d09;
}

.scene-meta {
  margin: 10px 0 0;
  color: #91a388;
  font-size: 13px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.start-card {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(18, 24, 18, 0.92);
}

.start-button {
  margin-top: 12px;
  width: 100%;
}

.status-card {
  padding: 12px;
  background: rgba(18, 24, 18, 0.92);
}

.status-label {
  margin: 0 0 8px;
  color: #bfd3b0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.health-bar {
  height: 16px;
  border: 2px solid #5c744f;
  background: rgba(11, 15, 10, 0.95);
  box-shadow: inset 2px 2px 0 rgba(214, 230, 200, 0.04);
}

.health-fill {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      #82c46b 0,
      #82c46b 8px,
      #6ca757 8px,
      #6ca757 16px
    );
}

.health-text,
.custom-action-status {
  margin: 8px 0 0;
  font-size: 12px;
  color: #a8b89c;
}

.health-delta {
  margin: 6px 0 0;
  min-height: 16px;
  font-size: 12px;
  color: #91a388;
}

.health-delta.damage {
  color: #ff8a8a;
}

.health-delta.heal {
  color: #9fe38a;
}

.rules-card {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(18, 24, 18, 0.92);
}

.rules-title {
  margin: 0 0 6px;
  color: #bfd3b0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.rules-copy {
  margin: 0;
  color: #a8b89c;
  font-size: 13px;
  line-height: 1.5;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  min-height: 220px;
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 4px;
}

.message {
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  background: rgba(12, 17, 12, 0.96);
}

.message.system {
  color: #95a88a;
}

.message.narrator {
  color: #dfe8d3;
}

.message.choice,
.message.dialogue {
  align-self: flex-end;
  background: rgba(26, 39, 27, 1);
  color: #b6d7aa;
}

.message.loading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #8ea180;
}

.loading-cube {
  width: 12px;
  height: 12px;
  background: #8fb47b;
  border: 2px solid #d9f2c9;
  box-shadow:
    2px 2px 0 #0a0d09,
    inset -2px -2px 0 rgba(10, 13, 9, 0.7);
  animation: cube-turn 1s steps(4, end) infinite;
}

.choices-section {
  margin-top: 16px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.talk-controls {
  margin-top: 12px;
  padding: 12px;
  background: rgba(18, 24, 18, 0.92);
}

.talk-row,
.custom-action-row,
.dialogue-header {
  display: grid;
  gap: 10px;
}

.talk-row,
.custom-action-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.dialogue-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 10px;
}

.panel.loading .choices-section,
.panel.loading .custom-action-form,
.panel.dialogue-mode .choices-section {
  display: none;
}

.panel.prestart .status-grid,
.panel.prestart .rules-card,
.panel.prestart .chat-messages,
.panel.prestart .choices-section,
.panel.prestart .custom-action-form {
  display: none;
}

.panel:not(.dialogue-mode) .custom-action-form {
  display: none;
}

.choice-button,
.restart-button,
.npc-select,
.custom-action-input {
  border: 2px solid #5c744f;
  border-radius: 0;
  background: linear-gradient(180deg, #1d281a 0%, #121911 100%);
  color: #edf4e2;
  font: inherit;
  box-shadow:
    inset -2px -2px 0 #0a0d09,
    inset 2px 2px 0 rgba(214, 230, 200, 0.06),
    4px 4px 0 rgba(6, 8, 5, 0.9);
}

.choice-button,
.restart-button {
  padding: 12px;
  text-align: left;
  cursor: pointer;
  text-transform: uppercase;
}

.npc-select,
.custom-action-input {
  padding: 10px 12px;
  outline: none;
  appearance: none;
}

.npc-select option {
  background: #121911;
  color: #edf4e2;
}

.choice-button:hover,
.restart-button:hover {
  border-color: #a3ca8f;
}

.choice-button:disabled,
.restart-button:disabled,
.custom-action-input:disabled,
.npc-select:disabled {
  opacity: 0.5;
  cursor: wait;
}

.choice-key {
  display: block;
  margin-bottom: 6px;
  color: #a3ca8f;
  font-size: 12px;
  letter-spacing: 0.16em;
}

.custom-action-form {
  margin-top: 16px;
  padding: 12px;
  background: rgba(18, 24, 18, 0.92);
}

.custom-action-input::placeholder {
  color: #77866e;
}

.footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  background: rgba(12, 17, 12, 0.96);
}

.config-status {
  margin: 0;
  font-size: 12px;
  color: #91a388;
}

.restart-button {
  min-width: 110px;
  text-align: center;
}

@keyframes cube-turn {
  0% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(90deg) scale(1.08);
  }

  50% {
    transform: rotate(180deg) scale(1);
  }

  75% {
    transform: rotate(270deg) scale(1.08);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 12px;
  }

  .status-grid,
  .choices {
    grid-template-columns: 1fr;
  }

  .talk-row,
  .custom-action-row,
  .dialogue-header,
  .footer-bar {
    grid-template-columns: 1fr;
  }

  .footer-bar {
    display: grid;
  }
}
