:root {
  color-scheme: light;
  --outline:
    -2px 0 #111,
    2px 0 #111,
    0 -2px #111,
    0 2px #111,
    -2px -2px #111,
    2px -2px #111,
    -2px 2px #111,
    2px 2px #111;
  --panel: rgba(0, 0, 0, 0.56);
  --panel-border: rgba(255, 255, 255, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #93b4e8;
}

body {
  overflow: hidden;
  font-family: "Arial Black", Impact, "Trebuchet MS", sans-serif;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, #abc1ea 0%, #abc1ea 46%, #92ab66 46.4%, #728b4a 100%);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud__top {
  position: absolute;
  inset: 18px 22px auto 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.stats {
  width: min(360px, calc(100vw - 150px));
  padding: 12px 14px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stats__row + .stats__row {
  margin-top: 10px;
}

.stats__row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
}

.stats__label,
.stats__value {
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  text-shadow: var(--outline);
}

.meter {
  height: 14px;
  border: 2px solid #111;
  background: rgba(255, 255, 255, 0.12);
}

.meter__fill {
  height: 100%;
  width: 100%;
}

.meter__fill--health {
  background: linear-gradient(90deg, #f86f7c, #ffb46a);
}

.meter__fill--hunger {
  background: linear-gradient(90deg, #f0b436, #fff079);
}

.hud__day,
.hud__status,
.hud__sound,
.hud__hint {
  color: #fff;
  text-shadow: var(--outline);
}

.hud__day {
  font-size: clamp(2rem, 4.8vw, 4.3rem);
  line-height: 0.95;
}

.hud__status {
  position: absolute;
  left: 50%;
  bottom: 154px;
  transform: translateX(-50%);
  font-size: clamp(1.3rem, 3vw, 3rem);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.hud__bottom-left {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.hud__hint {
  max-width: 100%;
  font-size: clamp(0.72rem, 1.22vw, 0.98rem);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.hud__sound {
  max-width: 100%;
  font-size: clamp(0.78rem, 1.28vw, 1.04rem);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.controls-panel {
  position: absolute;
  right: 20px;
  bottom: 132px;
  width: min(440px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 2px solid #111;
  background: rgba(12, 16, 19, 0.78);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 32px rgba(0, 0, 0, 0.24);
}

.controls-panel__title {
  margin: 0 0 12px;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  text-shadow: var(--outline);
}

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

.controls-item {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.controls-item__key,
.controls-item__desc {
  color: #fff;
  text-shadow: var(--outline);
}

.controls-item__key {
  font-size: 0.78rem;
}

.controls-item__desc {
  font-size: 0.76rem;
  line-height: 1.25;
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  opacity: 0.82;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(147, 238, 244, 0.95);
  box-shadow:
    0 0 0 1px rgba(17, 17, 17, 0.82),
    0 0 12px rgba(147, 238, 244, 0.34);
}

.crosshair::before {
  top: 1px;
  left: 50%;
  width: 2px;
  height: 32px;
  transform: translateX(-50%);
}

.crosshair::after {
  top: 50%;
  left: 1px;
  width: 32px;
  height: 2px;
  transform: translateY(-50%);
}

.action-meter {
  position: absolute;
  left: 50%;
  bottom: 132px;
  width: min(320px, calc(100vw - 36px));
  padding: 10px 12px;
  border: 2px solid #111;
  background: rgba(0, 0, 0, 0.58);
  transform: translateX(-50%);
}

.action-meter__label {
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  text-shadow: var(--outline);
}

.action-meter__track {
  margin-top: 8px;
  height: 12px;
  border: 2px solid #111;
  background: rgba(255, 255, 255, 0.1);
}

.action-meter__fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #81ecff, #f4ff93);
}

.hotbar {
  position: absolute;
  left: 50%;
  bottom: 34px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  width: min(760px, calc(100vw - 28px));
  transform: translateX(-50%);
}

.slot {
  min-height: 74px;
  padding: 8px 8px 6px;
  border: 3px solid #111;
  background: rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 5px 0 rgba(0, 0, 0, 0.24);
}

.slot.is-active {
  background: rgba(255, 248, 184, 0.82);
  transform: translateY(-4px);
}

.slot.is-empty {
  opacity: 0.72;
}

.slot__key,
.slot__name,
.slot__count {
  display: block;
  color: #fff;
  text-shadow: var(--outline);
  line-height: 1;
}

.slot__key {
  font-size: 0.72rem;
  opacity: 0.94;
}

.slot__name {
  margin-top: 9px;
  font-size: 0.92rem;
}

.slot__count {
  margin-top: 10px;
  font-size: 1.1rem;
}

.inventory-panel,
.settings-panel,
.death-screen {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(760px, calc(100vw - 30px));
  padding: 20px;
  border: 3px solid #111;
  background: rgba(18, 19, 22, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 80px rgba(0, 0, 0, 0.42);
  color: #fff;
  transform: translate(-50%, -50%);
}

.inventory-panel,
.settings-panel {
  pointer-events: auto;
}

.inventory-panel {
  max-height: min(78vh, 680px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #e5cf8d rgba(255, 255, 255, 0.1);
}

.inventory-panel::-webkit-scrollbar {
  width: 16px;
}

.inventory-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-left: 2px solid rgba(17, 17, 17, 0.72);
}

.inventory-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #f3e1a3, #bb9450);
  border: 2px solid #111;
}

.inventory-panel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #fff2bf, #c89f59);
}

.inventory-panel__title,
.settings-panel__title,
.death-screen__title {
  margin: 0 0 14px;
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
  text-shadow: var(--outline);
}

.inventory-panel__subtitle {
  margin: 0 0 10px;
  font-size: 1rem;
  text-shadow: var(--outline);
}

.inventory-panel__note,
.settings-panel__note,
.death-screen__body,
.death-screen__hint {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}

.settings-panel {
  width: min(500px, calc(100vw - 30px));
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.settings-field {
  display: grid;
  grid-template-columns: 132px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.settings-field__label,
.settings-field__value,
.settings-toggle span {
  color: #fff;
  text-shadow: var(--outline);
}

.settings-field__label {
  font-size: 0.88rem;
}

.settings-field__value {
  min-width: 46px;
  font-size: 0.88rem;
  text-align: right;
}

.settings-field input[type="range"] {
  width: 100%;
}

.settings-toggles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 14px;
}

.settings-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.settings-toggle input {
  width: 18px;
  height: 18px;
}

.inventory-section + .inventory-section {
  margin-top: 16px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.inventory-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}

.inventory-item.is-selected {
  background: rgba(255, 239, 170, 0.2);
  border-color: rgba(255, 239, 170, 0.9);
}

.craft-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.recipe-card {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.recipe-card.is-unavailable {
  opacity: 0.42;
}

.recipe-card.is-unavailable:hover {
  opacity: 0.5;
}

.recipe-card__title,
.recipe-card__give,
.recipe-card__cost,
.recipe-card__note {
  display: block;
}

.recipe-card__title {
  font-size: 0.98rem;
  text-shadow: var(--outline);
}

.recipe-card__give,
.recipe-card__cost,
.recipe-card__note {
  margin-top: 6px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.death-screen {
  width: min(460px, calc(100vw - 30px));
  text-align: center;
  background: rgba(40, 0, 0, 0.8);
}

.death-screen__body {
  margin-top: 8px;
}

.death-screen__hint {
  margin-top: 14px;
  opacity: 0.92;
}

.is-hidden {
  display: none;
}

@media (max-width: 760px) {
  .hud__top {
    inset: 12px 12px auto;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .stats {
    width: 100%;
  }

  .hud__day {
    align-self: flex-end;
  }

  .hud__status {
    bottom: 164px;
    width: calc(100vw - 30px);
    white-space: normal;
  }

  .hotbar {
    gap: 4px;
    bottom: 58px;
  }

  .action-meter {
    bottom: 148px;
  }

  .slot {
    min-height: 68px;
    padding-inline: 5px;
  }

  .slot__name {
    font-size: 0.72rem;
  }

  .slot__count {
    font-size: 0.98rem;
  }

  .hud__hint {
    left: 12px;
    right: 12px;
    bottom: 16px;
    max-width: none;
  }

  .controls-panel {
    right: 12px;
    left: 12px;
    bottom: 148px;
    width: auto;
  }

  .controls-panel__grid {
    grid-template-columns: 1fr;
  }

  .inventory-grid {
    grid-template-columns: 1fr;
  }

  .craft-grid {
    grid-template-columns: 1fr;
  }

  .inventory-panel {
    max-height: min(82vh, 760px);
  }

  .settings-field {
    grid-template-columns: 1fr;
  }

  .settings-field__value {
    text-align: left;
  }

  .settings-toggles {
    grid-template-columns: 1fr;
  }
}
