:root {
  color-scheme: dark;
  --bg: #080908;
  --panel: rgba(20, 22, 19, 0.88);
  --panel-2: rgba(32, 34, 28, 0.9);
  --glass: rgba(10, 12, 10, 0.64);
  --line: rgba(230, 202, 142, 0.2);
  --line-hot: rgba(236, 141, 62, 0.45);
  --text: #f4ead4;
  --muted: #a99d84;
  --accent: #e0a64d;
  --green: #8bb86f;
  --blue: #7da9bf;
  --danger: #d95c46;
  --shadow: rgba(0, 0, 0, 0.58);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 75% 18%, rgba(210, 80, 42, 0.22), transparent 18rem),
    radial-gradient(circle at 15% 0%, rgba(217, 155, 64, 0.13), transparent 22rem),
    linear-gradient(180deg, #151510 0%, #0b0c0a 48%, #050605 100%);
  background-size: 100% 4px, auto, auto, auto;
  color: var(--text);
  letter-spacing: 0;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.38), transparent 14%, transparent 86%, rgba(0, 0, 0, 0.38)),
    radial-gradient(circle at 50% 35%, transparent 0, rgba(0, 0, 0, 0.45) 72%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid rgba(224, 166, 77, 0.24);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(244, 234, 213, 0.11), rgba(244, 234, 213, 0.035));
  color: var(--text);
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 24px rgba(0, 0, 0, 0.18);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.42;
}

.primary {
  background: linear-gradient(180deg, #f0b75d 0%, #b66e2d 100%);
  border-color: rgba(255, 229, 159, 0.36);
  color: #19110a;
  font-weight: 900;
}

.danger {
  background: linear-gradient(180deg, rgba(210, 78, 52, 0.34), rgba(96, 24, 20, 0.58));
  border-color: rgba(239, 101, 74, 0.48);
  color: #ffe4dc;
}

.ghost {
  background: linear-gradient(180deg, rgba(118, 154, 119, 0.24), rgba(27, 54, 41, 0.38));
  border-color: rgba(139, 184, 111, 0.38);
}

.small {
  min-height: 36px;
  padding: 8px 10px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(224, 166, 77, 0.2);
  border-radius: 7px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.34);
  color: var(--text);
  outline: none;
}

.phone-shell {
  width: min(100vw, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.screen {
  display: none;
  animation: screen-in 220ms ease-out;
}

.screen.active {
  display: block;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

.hero {
  min-height: calc(100dvh - 118px);
  border: 1px solid rgba(239, 174, 78, 0.22);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: #11120f;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.62);
}

.hero-art {
  width: 100%;
  height: 100%;
  min-height: calc(100dvh - 118px);
  object-fit: cover;
  display: block;
  filter: contrast(1.12) saturate(0.85) brightness(0.72);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 72% 28%, rgba(255, 92, 36, 0.36), transparent 12rem),
    linear-gradient(180deg, rgba(7, 8, 7, 0.08), rgba(7, 8, 7, 0.18) 38%, rgba(7, 8, 7, 0.94) 100%);
  z-index: 1;
}

.hero::after,
.panel::after,
.event-card::after,
.map-block::after,
.death-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 100% 5px;
  opacity: 0.22;
  mix-blend-mode: screen;
}

.hero-copy {
  position: absolute;
  z-index: 2;
  left: 18px;
  right: 18px;
  top: 50%;
  transform: translateY(-42%);
  text-align: center;
}

.hazard-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(238, 180, 74, 0.34);
  background: rgba(0, 0, 0, 0.38);
  box-shadow: 0 0 38px rgba(216, 94, 42, 0.35), inset 0 0 24px rgba(224, 166, 77, 0.12);
  font-size: 42px;
}

.hero h1 {
  margin: 8px 0 12px;
  font-size: 42px;
  line-height: 1.02;
  text-shadow: 0 5px 24px rgba(0, 0, 0, 0.86), 0 0 26px rgba(218, 99, 45, 0.38);
}

.hero p {
  margin: 0;
  color: #eadabb;
  line-height: 1.7;
}

.hero-actions {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.kicker,
.panel-label {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
}

.panel,
.event-card,
.map-block,
.player-card,
.battle-card {
  position: relative;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), transparent 32%),
    var(--panel);
  box-shadow: 0 14px 32px var(--shadow);
  overflow: hidden;
}

.panel h2,
.event-card h3 {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.role-list,
.location-list,
.choice-list,
.craft-list,
.npc-list,
.ending-list {
  display: grid;
  gap: 10px;
}

.role-card,
.location-card,
.choice-card,
.craft-card,
.npc-card,
.ending-item {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 13px;
  border-radius: 8px;
  border: 1px solid rgba(223, 197, 139, 0.18);
  background:
    linear-gradient(90deg, rgba(224, 166, 77, 0.08), transparent 44%),
    rgba(16, 18, 15, 0.82);
  overflow: hidden;
}

.role-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.role-card.selected {
  outline: 2px solid rgba(224, 166, 77, 0.82);
  background:
    linear-gradient(90deg, rgba(224, 166, 77, 0.2), transparent 60%),
    rgba(29, 26, 20, 0.94);
}

.role-avatar,
.player-avatar,
.npc-avatar {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(224, 166, 77, 0.28);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 28px;
}

.role-card strong,
.location-card strong,
.craft-card strong,
.npc-card strong {
  display: block;
  margin-bottom: 4px;
}

.npc-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
}

.npc-card span {
  grid-column: 2;
}

.role-card span,
.location-card span,
.craft-card span,
.npc-card span,
.ending-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.role-stats,
.location-meta,
.player-bars,
.base-buildings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid rgba(224, 166, 77, 0.2);
  border-radius: 999px;
  color: #eadabb;
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 10px;
  background: linear-gradient(180deg, rgba(8, 9, 8, 0.96), rgba(8, 9, 8, 0.74), transparent);
  backdrop-filter: blur(14px);
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

.player-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
}

.player-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.player-card p {
  margin: 0;
}

.meter {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #e0a64d);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.stat {
  min-height: 66px;
  padding: 10px 8px;
  border: 1px solid rgba(224, 166, 77, 0.16);
  border-radius: 8px;
  background: rgba(5, 6, 5, 0.62);
}

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

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
}

.event-card {
  min-height: 190px;
  border-color: rgba(224, 166, 77, 0.3);
  background:
    linear-gradient(180deg, rgba(96, 24, 20, 0.24), transparent 48%),
    rgba(18, 18, 15, 0.92);
}

.event-card h3 {
  font-size: 22px;
}

#event-story {
  color: #e7d4b4;
  line-height: 1.65;
  margin: 10px 0 14px;
  font-size: 16px;
}

.choice-card {
  color: #fff2d6;
}

.choice-card:nth-child(1) {
  border-color: rgba(217, 92, 70, 0.48);
}

.choice-card:nth-child(2) {
  border-color: rgba(224, 166, 77, 0.4);
}

.choice-card:nth-child(3) {
  border-color: rgba(139, 184, 111, 0.38);
}

.location-list {
  position: relative;
  padding: 8px;
  border: 1px solid rgba(125, 169, 191, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(rgba(125, 169, 191, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 169, 191, 0.055) 1px, transparent 1px),
    rgba(4, 8, 8, 0.36);
  background-size: 22px 22px;
}

.location-card strong {
  font-size: 17px;
}

.stars {
  color: #f1ad4e;
  letter-spacing: 0;
}

.inventory-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.item {
  min-height: 86px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(224, 166, 77, 0.16);
  background: rgba(0, 0, 0, 0.24);
}

.item span {
  color: var(--muted);
  font-size: 12px;
}

.item strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.base-actions,
.battle-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.battle-card {
  margin-top: 18px;
}

.battle-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid rgba(224, 166, 77, 0.14);
}

.battle-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.battle-actions {
  margin-top: 14px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(100vw, 520px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(224, 166, 77, 0.18);
  background: rgba(7, 8, 7, 0.94);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 1px;
  min-height: 50px;
  padding: 5px 2px;
  font-size: 11px;
  border-radius: 8px;
}

.nav-item span {
  display: block;
  font-size: 17px;
}

.nav-item.active {
  color: #ffe0a5;
  background: rgba(224, 166, 77, 0.18);
  border-color: rgba(224, 166, 77, 0.44);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 50;
  width: min(calc(100vw - 28px), 492px);
  transform: translateX(-50%);
  padding: 12px 14px;
  border: 1px solid rgba(139, 184, 111, 0.4);
  border-radius: 8px;
  background: rgba(13, 25, 18, 0.96);
  color: #dff7bc;
  box-shadow: 0 12px 32px var(--shadow);
}

.death-screen {
  min-height: calc(100dvh - 98px);
  place-items: center;
}

.death-screen.active {
  display: grid;
}

.death-card {
  position: relative;
  width: 100%;
  padding: 22px;
  border-radius: 10px;
  border: 1px solid rgba(217, 92, 70, 0.42);
  background:
    radial-gradient(circle at 50% 0%, rgba(217, 92, 70, 0.22), transparent 18rem),
    rgba(18, 12, 11, 0.96);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.62);
  overflow: hidden;
}

.ending-card {
  border-color: rgba(139, 184, 111, 0.45);
}

.death-card h2 {
  margin: 0 0 16px;
  font-size: 30px;
}

.death-card p {
  line-height: 1.6;
}

.death-card button + button {
  margin-top: 8px;
  width: 100%;
}

.death-card .primary {
  width: 100%;
}

.ending-item {
  border-left: 3px solid rgba(224, 166, 77, 0.45);
}

@media (min-width: 700px) {
  body {
    background:
      radial-gradient(circle at center top, rgba(167, 113, 50, 0.16), transparent 42rem),
      #070807;
  }

  .phone-shell {
    border-left: 1px solid rgba(226, 203, 154, 0.09);
    border-right: 1px solid rgba(226, 203, 154, 0.09);
  }
}
