:root {
  color-scheme: dark;
  --ink: #fff1dd;
  --muted: #d4b692;
  --panel: rgba(28, 21, 17, 0.94);
  --line: rgba(255, 220, 160, 0.2);
  --gold: #efbd63;
  --red: #b64a2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #11100f;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
  touch-action: none;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#543925, #2b211b);
  color: var(--ink);
  min-height: 42px;
  font: inherit;
  font-weight: 800;
}

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

.game {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
  background: #10100f;
}

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 130px 1fr 44px;
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.hud strong,
.hud span {
  display: block;
  overflow-wrap: anywhere;
}

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

.bars {
  display: grid;
  gap: 5px;
}

.bars i,
.bars b {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #14100d;
  border: 1px solid var(--line);
}

.bars i::before,
.bars b::before {
  content: "";
  display: block;
  height: 100%;
  width: var(--w, 100%);
}

.bars i::before {
  background: linear-gradient(90deg, #b64a2f, #efbd63);
}

.bars b::before {
  background: linear-gradient(90deg, #5586c8, #7dd0df);
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 112px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(239, 189, 99, 0.45);
  border-radius: 8px;
  background: rgba(18, 14, 12, 0.94);
}

.prompt span {
  color: var(--gold);
  font-weight: 800;
}

.quickbar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stick[hidden] {
  display: none;
}

.stick {
  position: absolute;
  left: 14px;
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 72px));
  width: 134px;
  height: 134px;
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 4px;
}

.stick button {
  min-height: 42px;
  background: rgba(38, 30, 25, 0.9);
}

.stick [data-dir="up"] {
  grid-column: 2;
}

.stick [data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

.stick [data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

.stick [data-dir="down"] {
  grid-column: 2;
  grid-row: 3;
}

.panel {
  position: absolute;
  left: 50%;
  bottom: max(66px, env(safe-area-inset-bottom));
  width: min(94vw, 520px);
  max-height: min(62dvh, 520px);
  overflow: auto;
  transform: translateX(-50%);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55);
}

.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel h1 {
  margin: 0;
  font-size: 20px;
}

#closePanel {
  width: 42px;
}

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

.card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

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

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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