:root {
  color-scheme: dark;
  --ink: #f5ecd8;
  --muted: #b9ab92;
  --panel: rgba(29, 32, 29, 0.9);
  --line: rgba(226, 191, 122, 0.28);
  --accent: #d9a84f;
  --accent-hot: #f0c36d;
  --accent-2: #95a86d;
  --danger: #c25b45;
  --supply: #8fae72;
  --dark: #111510;
}

* {
  box-sizing: border-box;
}

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

button {
  border: 0;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template:
    "top top" auto
    "game game" minmax(0, 1fr)
    "inventory inventory" auto
    "left right" auto / minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 10px;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 25%, rgba(206, 146, 60, 0.18), transparent 28%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.32)),
    repeating-linear-gradient(90deg, rgba(226, 191, 122, 0.04) 0 1px, transparent 1px 42px),
    #12150f;
}

#game {
  grid-area: game;
  align-self: center;
  justify-self: center;
  width: min(100%, calc((100vh - 260px) * 0.5625));
  height: min(100%, calc(100vw * 1.7778));
  max-height: 100%;
  background: #7b684e;
  display: block;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(226, 191, 122, 0.32),
    0 0 0 5px rgba(14, 16, 12, 0.9),
    0 24px 80px rgba(0, 0, 0, 0.55);
}

.hud {
  z-index: 4;
  pointer-events: none;
}

.top {
  grid-area: top;
  width: min(680px, 100%);
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.meter {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(63, 65, 55, 0.94), rgba(20, 23, 19, 0.94));
  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 238, 195, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.34),
    0 7px 20px rgba(0, 0, 0, 0.28);
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.meter b {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.1;
  color: #fff1c8;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-left {
  grid-area: left;
  align-self: end;
  justify-self: start;
}

.stick {
  width: 118px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(226, 191, 122, 0.28);
  background:
    radial-gradient(circle at 50% 50%, rgba(217, 168, 79, 0.1) 0 24%, transparent 25%),
    radial-gradient(circle, rgba(255, 238, 195, 0.1), rgba(0, 0, 0, 0.34));
  pointer-events: auto;
  position: relative;
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.03), 0 12px 30px rgba(0, 0, 0, 0.4);
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #8f986e, #4d563c);
  border: 1px solid rgba(245, 236, 216, 0.35);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22), 0 6px 20px rgba(0, 0, 0, 0.4);
}

.bottom-right {
  grid-area: right;
  align-self: end;
  justify-self: end;
  display: grid;
  grid-template-columns: 56px 68px;
  grid-template-rows: 56px 68px;
  gap: 10px;
  align-items: end;
  justify-items: end;
}

.round {
  width: 56px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(67, 70, 58, 0.96), rgba(25, 27, 22, 0.96));
  border: 1px solid rgba(226, 191, 122, 0.3);
  color: #f7e5ba;
  font-size: 24px;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 2px 0 rgba(255, 238, 195, 0.12), 0 10px 24px rgba(0, 0, 0, 0.38);
}

.round.fire {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 68px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 223, 139, 0.45), transparent 34%),
    radial-gradient(circle at 50% 56%, rgba(75, 18, 13, 0.72), transparent 57%),
    linear-gradient(180deg, #b84d38, #6d241c);
  border-color: rgba(255, 203, 115, 0.68);
  font-size: 30px;
  box-shadow:
    inset 0 2px 0 rgba(255, 238, 195, 0.22),
    inset 0 -8px 14px rgba(43, 12, 9, 0.44),
    0 0 0 3px rgba(217, 168, 79, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.42);
}

.round:active,
.slot:active,
.primary:active {
  transform: translateY(1px) scale(0.98);
}

.inventory {
  grid-area: inventory;
  align-self: end;
  justify-self: center;
  display: flex;
  gap: 8px;
}

.slot {
  width: 72px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid rgba(226, 191, 122, 0.26);
  background:
    linear-gradient(90deg, rgba(217, 168, 79, 0.16), transparent 28%, transparent 72%, rgba(217, 168, 79, 0.1)),
    linear-gradient(180deg, rgba(52, 55, 47, 0.96), rgba(18, 20, 17, 0.96));
  pointer-events: auto;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  padding: 6px;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 238, 195, 0.1), 0 8px 18px rgba(0, 0, 0, 0.32);
}

.slot.active {
  border-color: rgba(217, 168, 79, 0.95);
  background:
    linear-gradient(90deg, rgba(240, 195, 109, 0.24), transparent 33%, transparent 70%, rgba(240, 195, 109, 0.12)),
    linear-gradient(180deg, rgba(82, 84, 58, 0.98), rgba(32, 31, 21, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(217, 168, 79, 0.45),
    inset 0 -5px 12px rgba(0, 0, 0, 0.26),
    0 0 22px rgba(217, 168, 79, 0.2);
}

.slot span {
  color: var(--accent-hot);
  font-size: 12px;
  font-weight: 800;
}

.slot b {
  font-size: 13px;
  white-space: nowrap;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(rgba(17, 18, 15, 0.18), rgba(17, 18, 15, 0.78)),
    radial-gradient(circle at 50% 28%, rgba(217, 168, 79, 0.22), transparent 30%),
    repeating-linear-gradient(90deg, rgba(226, 191, 122, 0.05) 0 1px, transparent 1px 38px),
    #151711;
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(420px, 100%);
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(43, 45, 38, 0.94), rgba(16, 18, 15, 0.94));
  padding: 22px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
}

.intro {
  color: var(--muted);
  line-height: 1.55;
  margin: 14px 0 18px;
}

.primary {
  width: 100%;
  height: 48px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 245, 210, 0.22), transparent 26%, transparent 74%, rgba(255, 245, 210, 0.14)),
    linear-gradient(180deg, #e6bd69, #b67b2c);
  color: #20170b;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 245, 210, 0.35), 0 10px 24px rgba(0, 0, 0, 0.26);
}

.primary:disabled {
  cursor: wait;
  opacity: 0.72;
  filter: saturate(0.72);
}

.keys {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: 74px;
  min-width: 180px;
  max-width: min(460px, calc(100vw - 28px));
  transform: translateX(-50%);
  padding: 9px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(39, 39, 32, 0.92), rgba(17, 18, 15, 0.92));
  border: 1px solid var(--line);
  text-align: center;
  color: var(--ink);
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 520px) {
  .top {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .meter {
    padding: 5px 6px;
  }

  .meter b {
    font-size: 13px;
  }

  .slot {
    width: 64px;
    height: 42px;
  }

  .bottom-right {
    grid-template-columns: 50px 62px;
    grid-template-rows: 50px 62px;
  }

  .round {
    width: 50px;
  }

  .round.fire {
    width: 62px;
  }

  .stick {
    width: 108px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app {
    grid-template:
      "top game right" auto
      "left game right" minmax(0, 1fr)
      "inventory game right" auto / minmax(104px, 1fr) minmax(230px, 42vw) minmax(96px, 1fr);
    gap: 6px 8px;
    padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  }

  #game {
    width: min(100%, 42vw);
    height: min(100%, calc(100vh - 12px));
    border-radius: 6px;
  }

  .top {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter {
    padding: 4px 5px;
  }

  .meter span {
    font-size: 10px;
  }

  .meter b {
    font-size: 13px;
  }

  .bottom-left,
  .bottom-right {
    align-self: center;
  }

  .bottom-left {
    justify-self: center;
  }

  .stick {
    width: 88px;
  }

  .knob {
    width: 36px;
  }

  .bottom-right {
    grid-template-columns: 44px 56px;
    grid-template-rows: 44px 56px;
    gap: 6px;
  }

  .round {
    width: 44px;
    font-size: 20px;
  }

  .round.fire {
    width: 56px;
    font-size: 26px;
  }

  .inventory {
    align-self: end;
    flex-wrap: wrap;
    max-width: 190px;
    gap: 6px;
  }

  .slot {
    width: 58px;
    height: 36px;
    grid-template-columns: 16px 1fr;
    padding: 5px;
  }

  .slot span,
  .slot b {
    font-size: 11px;
  }
}

@media (min-width: 900px) and (min-height: 620px) {
  .app {
    grid-template:
      ". top ." auto
      "left game right" minmax(0, 1fr)
      ". inventory ." auto / minmax(160px, 1fr) minmax(360px, 56vh) minmax(160px, 1fr);
    padding: 18px;
  }

  #game {
    width: min(100%, calc((100vh - 150px) * 0.5625));
    height: min(100%, calc(56vh * 1.7778));
  }

  .bottom-left,
  .bottom-right {
    align-self: center;
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 900px) and (min-height: 620px) {
  .app {
    grid-template:
      ". top ." auto
      ". game ." minmax(0, 1fr)
      ". inventory ." auto / minmax(220px, 1fr) minmax(360px, 56vh) minmax(220px, 1fr);
  }

  .bottom-left,
  .bottom-right {
    display: none;
  }
}
