/* ===== Base styles ===== */
:root {
  color-scheme: dark;
  --bg: #111016;
  --panel: #1c1924;
  --panel-light: #272230;
  --border: #393142;
  --text: #f2edf6;
  --muted: #a69cad;
  --purple: #a78bfa;
  --purple-dark: #7655bd;
  --red: #f07886;
  --green: #71d6a0;
  --gold: #f3ca77;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, #30213e 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.6;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 5vw, 4rem);
  border-bottom: 1px solid var(--border);
  background: rgb(17 16 22 / 80%);
}

.logo {
  color: var(--text);
  font-weight: 850;
  letter-spacing: 0.09em;
  text-decoration: none;
}

.logo span {
  color: var(--purple);
  margin-right: 0.4rem;
}

.header-label,
.eyebrow {
  color: var(--purple);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.header-label {
  color: var(--muted);
}

.game-container {
  width: min(1120px, 100% - 2rem);
  margin: 0 auto;
}

.intro {
  padding: 3rem 0 2rem;
  text-align: center;
}

.intro .eyebrow {
  margin-bottom: 0.4rem;
}

.intro h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 4rem);
  line-height: 1.15;
  letter-spacing: -0.05em;
}

.intro h1 span {
  color: var(--purple);
}

.intro > p:last-child {
  max-width: 560px;
  margin: 1rem auto 0;
  color: var(--muted);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.75fr) minmax(0, 1.6fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 1.25rem;
  background: rgb(28 25 36 / 95%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 16px 50px rgb(0 0 0 / 15%);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2,
.log-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgb(113 214 160 / 50%);
}

.avatar {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 1.5rem auto 0.5rem;
  border: 1px solid #4c3b63;
  border-radius: 50%;
  background: linear-gradient(145deg, #39284a, #211c2d);
  font-size: 2.6rem;
}

.player-title {
  margin: 0 0 1.5rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.85rem;
}

.stat {
  margin-top: 1rem;
}

.stat-label {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
}

.stat-label span {
  color: var(--muted);
}

.stat-label strong {
  font-variant-numeric: tabular-nums;
}

.meter {
  overflow: hidden;
  height: 9px;
  border-radius: 99px;
  background: #0e0d12;
}

.meter-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 220ms ease;
}

.health-fill {
  background: var(--green);
}

.enemy-fill {
  background: var(--red);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.mini-stat {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #17141e;
}

.mini-stat-icon {
  grid-row: span 2;
  font-size: 1.25rem;
}

.mini-stat-label {
  color: var(--muted);
  font-size: 0.72rem;
}

.mini-stat strong {
  font-size: 1.1rem;
}

.inventory {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.inventory h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.inventory p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.room-badge {
  padding: 0.25rem 0.65rem;
  border: 1px solid #4c3b63;
  border-radius: 99px;
  background: #30243e;
  color: #d5c2ff;
  font-size: 0.75rem;
  white-space: nowrap;
}

.scene {
  display: flex;
  min-height: 230px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  padding: 1.5rem;
  border: 1px solid #3c304a;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at center, #332541 0%, #211b2b 65%, #1a1721 100%);
  text-align: center;
}

.scene-icon {
  font-size: 3.3rem;
  line-height: 1.3;
}

.scene-label {
  margin: 0.75rem 0 0.25rem;
  color: var(--purple);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.scene h3 {
  margin: 0;
  font-size: 1.4rem;
}

.scene > p:last-child {
  max-width: 460px;
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.enemy-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #75404d;
  border-radius: 12px;
  background: #2a1a24;
}

.enemy-card[hidden] {
  display: none;
}

.enemy-card .eyebrow {
  margin: 0;
  color: var(--red);
  font-size: 0.65rem;
}

.enemy-card h3 {
  margin: 0.2rem 0 0;
}

.enemy-icon {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  font-size: 2rem;
}

.enemy-health {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.button {
  display: inline-flex;
  flex: 1 1 135px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 160ms ease, filter 160ms ease,
    background 160ms ease;
}

.button:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-2px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  background: var(--purple-dark);
  color: white;
}

.button-danger {
  background: #873847;
  color: white;
}

.button-secondary {
  border-color: var(--border);
  background: var(--panel-light);
  color: var(--text);
}

.action-hint {
  min-height: 1.5em;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.log-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.log-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.log-heading span {
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
}

.event-log {
  display: grid;
  gap: 0.5rem;
  max-height: 210px;
  overflow-y: auto;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.log-entry {
  padding: 0.65rem 0.75rem;
  border-left: 2px solid var(--purple-dark);
  border-radius: 0 8px 8px 0;
  background: #17141e;
  color: #c6bdce;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.game-footer p {
  margin: 0;
}

@media (max-width: 700px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .player-panel {
    order: 2;
  }

  .adventure-panel {
    order: 1;
  }

  .intro {
    padding-top: 2rem;
  }

  .header-label {
    font-size: 0.6rem;
    text-align: right;
  }
}

@media (max-width: 420px) {
  .game-container {
    width: min(100% - 1rem, 1120px);
  }

  .panel {
    padding: 0.9rem;
  }

  .game-footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
