:root {
  color-scheme: dark;
  font-family: "Press Start 2P", monospace;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #17131c;
}

#app {
  min-height: 100vh;
  padding: 1rem;
}

.app-shell {
  box-sizing: border-box;
  width: min(100%, 1100px);
  min-height: calc(100vh - 2rem);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
  position: relative;
  inset: auto;
}

.app-header,
.app-footer,
.button-row,
.stat-row,
.battle-layout,
.hero-grid,
.auth-grid {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-header,
.app-footer,
.button-row,
.stat-row {
  justify-content: space-between;
}

.app-header {
  border-bottom: 2px solid #b89557;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1rem, 3vw, 1.6rem);
}

.app-header button,
.app-footer button {
  flex: 0 0 auto;
}

.screen {
  max-width: 900px;
  margin: 0 auto;
}

.screen h2,
.screen h3 {
  color: #f1d68f;
  line-height: 1.7;
}

.screen p,
.screen li,
.screen label,
.screen small,
.app-header button {
  font-size: clamp(0.55rem, 1.3vw, 0.8rem);
  line-height: 1.9;
}

.screen p,
.screen li {
  color: #f5f0dc;
}

.auth-grid {
  align-items: stretch;
}

.auth-card,
.panel {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  padding: 1rem;
  position: relative;
}

.auth-card h2,
.panel h2,
.panel h3 {
  font-size: clamp(0.8rem, 2vw, 1.1rem);
}

.field {
  display: block;
  margin: 1rem 0;
}

.field span,
.field input {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.field input {
  margin-top: 0.4rem;
  padding: 0.75rem;
  border: 2px solid #b89557;
  background: #211c25;
  color: #fff;
  font: 0.75rem "Press Start 2P", monospace;
}

.field input:focus,
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #f1d68f;
  outline-offset: 3px;
}

.app-button {
  min-width: 150px;
  min-height: 48px;
  padding: 0.5rem 1rem;
  font: 0.7rem "Press Start 2P", monospace;
}

.notice {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 2px solid #b89557;
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.8;
}

.notice.error {
  border-color: #d46b6b;
}

.hero-grid {
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  margin: 2rem 0;
}

.hero-card {
  box-sizing: border-box;
  width: min(100%, 190px);
  padding: 0.75rem;
  border: 2px solid #806a48;
  text-align: center;
}

.hero-card img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: contain;
}

.hero-card label {
  display: block;
  cursor: pointer;
}

.hero-card input {
  margin: 0.75rem;
}

.app-footer {
  margin-top: 2rem;
  border-top: 2px solid #806a48;
  padding-top: 1rem;
}

.story-image,
.enemy-image {
  display: block;
  max-width: 100%;
  max-height: 48vh;
  margin: 0 auto 1.5rem;
  object-fit: contain;
}

.story-text {
  min-height: 8rem;
  padding: 1rem;
  border: 2px solid #806a48;
  line-height: 2.2 !important;
}

.battle-layout {
  align-items: flex-start;
}

.battle-stats {
  flex: 0 0 240px;
}

.battle-scene {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.healthbar {
  width: 100%;
  height: 20px;
  margin: 0.75rem 0 1.25rem;
  border: 2px solid #ddd;
  background: #382e38;
}

.healthbar span {
  display: block;
  height: 100%;
  background: #45a85a;
  transition: width 180ms ease;
}

.healthbar.enemy span {
  background: #c84d4d;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.loading,
.empty-state {
  padding: 2rem 0;
  color: #f5f0dc;
  text-align: center;
  line-height: 2;
}

.screen-image {
  display: block;
  width: min(60%, 320px);
  margin: 1rem auto;
}

@media (max-width: 700px) {
  #app {
    padding: 0.5rem;
  }

  .app-shell {
    min-height: calc(100vh - 1rem);
  }

  .auth-grid,
  .battle-layout {
    flex-direction: column;
  }

  .battle-stats,
  .battle-scene {
    width: 100%;
    flex-basis: auto;
  }

  .app-header {
    align-items: flex-start;
  }

  .app-header h1 {
    text-align: left;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
