* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  padding: 18px;
  background: #141414;
  color: #f6f3ea;
  font-family: Arial, Helvetica, sans-serif;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 12px;
  width: min(100%, 1080px);
  margin: 0 auto;
}

.hud,
.story-panel,
.inventory-panel,
.log-panel,
.partner-panel {
  border: 2px solid #383838;
  border-radius: 8px;
  background: #202020;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.hud {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.hud > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.label,
.panel-heading {
  color: #b9b3a5;
  font-size: 0.82rem;
  font-weight: 800;
}

strong {
  color: #ffffff;
  font-size: 1.35rem;
  line-height: 1;
}

button {
  border: 0;
  border-radius: 8px;
  background: #f7c948;
  color: #191919;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

#restartButton {
  min-height: 42px;
  padding: 0 16px;
}

.story-panel {
  min-height: 520px;
  padding: 28px;
}


.portrait-stage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.portrait-stage figure {
  display: grid;
  gap: 8px;
  margin: 0;
}

.portrait-stage img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: contain;
  border: 2px solid #383838;
  border-radius: 8px;
  background: #151515;
}

.portrait-stage figcaption {
  color: #f7c948;
  font-size: 0.88rem;
  font-weight: 800;
}

.chapter-line {
  color: #f7c948;
  font-weight: 800;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 18px;
  font-size: 2.4rem;
  line-height: 1.1;
}

#sceneText {
  min-height: 178px;
  margin: 0 0 28px;
  color: #eee8da;
  font-size: 1.1rem;
  line-height: 1.72;
  white-space: pre-line;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-button {
  min-height: 62px;
  padding: 12px 16px;
  text-align: left;
  background: #f6f3ea;
}

.choice-button strong {
  display: block;
  color: #191919;
  font-size: 1rem;
  margin-bottom: 4px;
}

.choice-button span {
  display: block;
  color: #4d4637;
  font-size: 0.9rem;
  line-height: 1.35;
}

.inventory-panel,
.log-panel,
.partner-panel {
  padding: 18px;
}

.inventory-panel {
  min-height: 278px;
}

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

.stats-grid {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
}

.stat-row,
.item-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #383838;
  padding: 8px 0;
}

.stat-row span:first-child,
.item-row span:first-child {
  color: #d9d4c8;
  font-weight: 800;
}

.stat-row span:last-child,
.item-row span:last-child {
  color: #ffffff;
  text-align: right;
}

.item-list {
  display: grid;
  gap: 6px;
}

.empty-text {
  color: #b9b3a5;
  line-height: 1.5;
}

.partner-panel {
  grid-column: 2;
}

.partner-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.partner-form label {
  display: grid;
  gap: 6px;
  color: #d9d4c8;
  font-size: 0.9rem;
  font-weight: 800;
}

.partner-form input,
.partner-form textarea {
  width: 100%;
  border: 1px solid #4a4a4a;
  border-radius: 8px;
  background: #151515;
  color: #ffffff;
  font: inherit;
  padding: 11px 12px;
}

.partner-form textarea {
  resize: vertical;
  min-height: 120px;
}

.partner-form input:focus,
.partner-form textarea:focus {
  border-color: #f7c948;
  outline: none;
}

.partner-form button {
  min-height: 44px;
  margin-top: 2px;
}

ol {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding-left: 18px;
  color: #eee8da;
  line-height: 1.45;
}

@media (max-width: 820px) {
  body {
    padding: 10px;
  }

  .game-shell {
    grid-template-columns: 1fr;
  }

  .partner-panel {
    grid-column: auto;
  }

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

  .hud > div {
    display: grid;
    gap: 2px;
  }

  #restartButton {
    grid-column: 1 / -1;
    width: 100%;
  }

  .story-panel {
    min-height: auto;
    padding: 20px;
  }

  .portrait-stage {
    grid-template-columns: 1fr;
  }

  .portrait-stage img {
    height: 180px;
  }

  h1 {
    font-size: 1.9rem;
  }
}
