:root {
  color-scheme: light;
  --paper: #f6f4ee;
  --ink: #1f2726;
  --muted: #64706c;
  --line: #cfd6d1;
  --panel: #fffdf8;
  --panel-strong: #ece9df;
  --green: #2f7d62;
  --blue: #2f5f86;
  --amber: #b7791f;
  --red: #b8463f;
  --shadow: 0 12px 32px rgba(31, 39, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  align-items: flex-start;
  background:
    linear-gradient(180deg, rgba(246, 244, 238, 0.94), rgba(237, 240, 235, 0.98)),
    repeating-linear-gradient(90deg, rgba(47, 95, 134, 0.06) 0 1px, transparent 1px 72px);
  color: var(--ink);
  display: flex;
  font-family: Arial, Helvetica, sans-serif;
  justify-content: center;
  line-height: 1.35;
  padding: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.game-shell {
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  height: 720px;
  min-height: 720px;
  overflow: hidden;
  padding: 12px;
  width: min(100vw, 640px);
}

.topbar {
  align-items: center;
  background: #26312f;
  color: #fffdf8;
  display: flex;
  justify-content: space-between;
  min-height: 66px;
  padding: 12px;
}

.topbar > div {
  min-width: 0;
}

.topbar h1,
.topbar p,
.section-title h2,
.section-title p,
.request-panel h2,
.request-panel p,
.log-panel h2,
.ending-panel h2,
.ending-panel p {
  margin: 0;
}

.topbar h1 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.topbar p {
  color: #cfded8;
  font-size: 13px;
  margin-top: 2px;
}

.plain-button,
.primary-button {
  border: 1px solid rgba(31, 39, 38, 0.25);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 12px;
}

.plain-button {
  background: #fffdf8;
  color: var(--ink);
}

.primary-button {
  background: var(--green);
  color: white;
  font-weight: 700;
}

.meters {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.meter-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 62px;
  padding: 8px;
}

.meter-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.meter-card strong {
  display: block;
  font-size: 18px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.bar {
  background: #d8ded8;
  border-radius: 999px;
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
}

.bar i {
  background: var(--green);
  display: block;
  height: 100%;
  width: 62%;
}

.bar.condition i {
  background: var(--blue);
}

.request-panel,
.tools-panel,
.actions-panel,
.log-panel,
.ending-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.request-meta {
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  gap: 8px;
  text-transform: uppercase;
}

.request-panel h2 {
  font-size: 20px;
  margin-top: 4px;
}

.request-panel p {
  color: #38423f;
  font-size: 14px;
  margin-top: 6px;
}

.request-panel .impact-line {
  color: var(--amber);
  font-weight: 700;
}

.section-title {
  align-items: baseline;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title h2,
.log-panel h2 {
  font-size: 15px;
}

.section-title p {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.upgrade-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.upgrade-button,
.action-button {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-width: 0;
  text-align: left;
  width: 100%;
}

.upgrade-button {
  min-height: 76px;
  padding: 8px;
}

.upgrade-button strong,
.action-button strong {
  display: block;
  font-size: 13px;
}

.upgrade-button span,
.action-button span,
.action-button small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

.upgrade-button:disabled,
.action-button:disabled {
  background: #edece5;
  color: #7c8580;
  opacity: 0.72;
}

.upgrade-button:not(:disabled):hover,
.action-button:not(:disabled):hover {
  border-color: var(--blue);
}

.action-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.action-button {
  min-height: 104px;
  padding: 9px;
}

.action-button .tag {
  color: var(--blue);
  font-weight: 700;
  text-transform: uppercase;
}

.action-button .costs {
  color: #3e4a45;
  margin-top: 6px;
}

.log-panel {
  min-height: 82px;
}

.log-panel ol {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding-left: 20px;
}

.log-panel li {
  color: #38423f;
  font-size: 12px;
}

.ending-panel {
  border-color: rgba(47, 125, 98, 0.45);
  box-shadow: inset 0 0 0 2px rgba(47, 125, 98, 0.08);
  gap: 8px;
  position: absolute;
  inset: 12px;
  z-index: 20;
  overflow: auto;
}

.ending-panel.is-visible {
  display: grid;
}

.score-box {
  align-items: center;
  background: var(--panel-strong);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
}

.score-box span,
.share-label,
.copy-status {
  color: var(--muted);
  font-size: 12px;
}

.score-box strong {
  font-size: 22px;
}

.share-label {
  font-weight: 700;
}

#shareText {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 76px;
  padding: 8px;
  resize: vertical;
  width: 100%;
}

.ending-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 560px) {
  .game-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 8px;
  }

  .ending-panel {
    position: static;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .meters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upgrade-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .action-button {
    min-height: 82px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .section-title p {
    text-align: left;
  }
}

@media (max-width: 420px) {
  .plain-button,
  .primary-button {
    width: 100%;
  }
}
