html,
body {
  height: 100%;
  overflow: hidden;
  width: 100%;
}

body {
  background: rgb(16, 31, 29);
  color: rgb(245, 241, 218);
  font-family: Arial, sans-serif;
  margin: 0;
}

[hidden] {
  display: none !important;
}

#main-menu {
  align-items: center;
  background:
    radial-gradient(circle at 72% 18%, rgba(255, 245, 168, 0.92) 0 4%, transparent 4.3%),
    linear-gradient(180deg, rgb(48, 151, 218) 0%, rgb(32, 183, 218) 62%, rgb(34, 117, 69) 62.5%, rgb(12, 60, 35) 100%);
  box-sizing: border-box;
  display: flex;
  inset: 0;
  justify-content: center;
  overflow: hidden;
  padding: 1.25rem;
  position: fixed;
}

#main-menu::before,
#main-menu::after {
  background: rgba(255, 255, 255, 0.92);
  border: 4px solid rgb(40, 62, 66);
  border-radius: 50%;
  box-shadow: 42px 7px 0 -5px rgba(255, 255, 255, 0.92), 77px -2px 0 -9px rgba(255, 255, 255, 0.92);
  content: "";
  height: 42px;
  opacity: 0.9;
  position: absolute;
  width: 58px;
}

#main-menu::before {
  left: 8%;
  top: 15%;
}

#main-menu::after {
  right: 15%;
  top: 28%;
  transform: scale(0.72);
}

.menu-card {
  background: rgba(16, 31, 29, 0.94);
  border: 4px solid rgb(245, 241, 218);
  border-radius: 1.5rem;
  box-shadow: 0 12px 0 rgba(5, 15, 12, 0.75), 0 24px 55px rgba(5, 15, 12, 0.45);
  box-sizing: border-box;
  max-width: 31rem;
  padding: clamp(1.5rem, 5vw, 2.6rem);
  position: relative;
  text-align: center;
  width: min(100%, 31rem);
  z-index: 1;
}

.menu-kicker {
  color: rgb(112, 245, 222);
  font-size: 0.78rem;
  font-weight: bold;
  letter-spacing: 0.16em;
  margin: 0 0 0.45rem;
  text-transform: uppercase;
}

#game-title {
  color: rgb(255, 205, 65);
  font-size: clamp(2.6rem, 10vw, 4.8rem);
  letter-spacing: -0.06em;
  line-height: 0.9;
  margin: 0;
  text-shadow: 0 5px 0 rgb(119, 73, 22);
}

.menu-copy {
  color: rgba(245, 241, 218, 0.82);
  line-height: 1.5;
  margin: 1.35rem auto 1.65rem;
  max-width: 26rem;
}

#mode-choice,
.menu-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

#options-menu {
  margin: 1.4rem auto 0;
  max-width: 23rem;
  text-align: left;
}

#options-menu h2 {
  color: rgb(255, 205, 65);
  font-size: 1.45rem;
  margin: 0 0 1.2rem;
  text-align: center;
}

.option-row {
  align-items: baseline;
  display: flex;
  font-weight: bold;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

#music-volume-value,
#effects-volume-value,
#pause-music-volume-value,
#pause-effects-volume-value {
  color: rgb(112, 245, 222);
  font-variant-numeric: tabular-nums;
}

#music-volume,
#effects-volume,
#pause-music-volume,
#pause-effects-volume {
  accent-color: rgb(255, 205, 65);
  cursor: pointer;
  width: 100%;
}

#music-volume:focus-visible,
#effects-volume:focus-visible,
#pause-music-volume:focus-visible,
#pause-effects-volume:focus-visible {
  outline: 3px solid rgb(112, 245, 222);
  outline-offset: 4px;
}

.menu-help {
  color: rgba(245, 241, 218, 0.72);
  font-size: 0.85rem;
  line-height: 1.45;
  margin: 0.75rem 0 1.2rem;
}

#options-back-button {
  display: block;
  margin: 0 auto;
}

.menu-button {
  background: rgb(245, 241, 218);
  border: 3px solid rgb(5, 15, 12);
  border-radius: 0.7rem;
  box-shadow: 0 5px 0 rgb(5, 15, 12);
  color: rgb(16, 31, 29);
  cursor: pointer;
  font: bold 1rem Arial, sans-serif;
  min-height: 3.2rem;
  padding: 0.65rem 1.15rem;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.menu-button:hover,
.menu-button:focus-visible {
  transform: translateY(-2px);
}

.menu-button:active {
  box-shadow: 0 2px 0 rgb(5, 15, 12);
  transform: translateY(3px);
}

.menu-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.menu-button-primary {
  background: rgb(255, 205, 65);
}

.menu-button-quiet {
  background: rgb(152, 180, 175);
}

#multiplayer-form {
  margin: 1.4rem auto 0;
  max-width: 23rem;
  text-align: left;
}

#multiplayer-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: bold;
  letter-spacing: 0.06em;
  margin: 0.9rem 0 0.35rem;
  text-transform: uppercase;
}

#multiplayer-form input {
  background: rgb(255, 252, 232);
  border: 3px solid rgb(5, 15, 12);
  border-radius: 0.6rem;
  box-sizing: border-box;
  color: rgb(16, 31, 29);
  font: bold 1rem Arial, sans-serif;
  padding: 0.75rem;
  width: 100%;
}

#multiplayer-form input:focus {
  outline: 3px solid rgb(112, 245, 222);
  outline-offset: 2px;
}

#multiplayer-error {
  color: rgb(255, 151, 125);
  min-height: 1.3em;
  text-align: center;
}

canvas {
  cursor: crosshair;
  display: block;
  height: 100vh;
  width: 100vw;
}

.controls {
  background: rgba(16, 31, 29, 0.86);
  border: 2px solid rgba(245, 241, 218, 0.28);
  border-radius: 999px;
  bottom: max(1rem, env(safe-area-inset-bottom));
  font-size: 0.9rem;
  left: 50%;
  letter-spacing: 0.02em;
  margin: 0;
  max-width: calc(100vw - 2rem);
  padding: 0.55rem 0.8rem;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translateX(-50%);
  width: max-content;
}

.control-group {
  display: inline-block;
  white-space: nowrap;
}

.hud-panel {
  background:
    linear-gradient(145deg, rgba(27, 45, 40, 0.72), rgba(8, 20, 18, 0.58));
  border: 2px solid rgba(245, 241, 218, 0.3);
  box-shadow:
    inset 0 0 0 1px rgba(5, 15, 12, 0.55),
    0 8px 22px rgba(5, 15, 12, 0.28);
  box-sizing: border-box;
  pointer-events: none;
  position: fixed;
  z-index: 3;
}

@supports (backdrop-filter: blur(8px)) {
  .hud-panel {
    backdrop-filter: blur(8px) saturate(1.12);
  }
}

#player-status {
  border-radius: 0.9rem;
  left: max(0.75rem, env(safe-area-inset-left));
  padding: 0.72rem;
  top: max(0.75rem, env(safe-area-inset-top));
  width: clamp(17.5rem, 29vw, 21rem);
}

.hud-meter-row {
  align-items: center;
  display: flex;
  gap: 0.62rem;
}

.hud-meter-row + .hud-meter-row,
#progression {
  margin-top: 0.62rem;
}

.hud-meter-icon,
.level-badge {
  align-items: center;
  display: flex;
  flex: 0 0 2.15rem;
  height: 2.15rem;
  justify-content: center;
}

.health-icon {
  color: rgb(255, 118, 106);
  font-size: 1.65rem;
  text-shadow: 0 2px 0 rgb(104, 35, 38);
}

.level-badge {
  background: rgb(255, 205, 65);
  border: 2px solid rgb(75, 49, 20);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 245, 168, 0.5), 0 2px 0 rgba(5, 15, 12, 0.7);
  color: rgb(50, 37, 19);
  font-size: 0.92rem;
  font-weight: bold;
}

.hud-meter-block {
  flex: 1 1 auto;
  min-width: 0;
}

.hud-meter-label {
  align-items: baseline;
  display: flex;
  font-size: 0.65rem;
  font-weight: bold;
  justify-content: space-between;
  letter-spacing: 0.09em;
  margin-bottom: 0.26rem;
  text-transform: uppercase;
}

.hud-meter-label strong {
  color: rgba(245, 241, 218, 0.88);
  font-size: 0.69rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.hud-meter {
  background: rgba(5, 15, 12, 0.82);
  border: 2px solid rgba(245, 241, 218, 0.24);
  border-radius: 0.28rem;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.42);
  height: 0.78rem;
  overflow: hidden;
}

.hud-meter-fill {
  display: block;
  height: 100%;
  min-width: 0;
  transition: width 180ms ease-out;
  width: 0;
}

.health-meter .hud-meter-fill {
  background: linear-gradient(90deg, rgb(196, 53, 55), rgb(255, 126, 101));
  box-shadow: inset 0 2px 0 rgba(255, 214, 181, 0.35);
  width: 100%;
}

.experience-meter .hud-meter-fill {
  background: linear-gradient(90deg, rgb(44, 178, 168), rgb(112, 245, 222));
  box-shadow: inset 0 2px 0 rgba(220, 255, 245, 0.35);
}

.wealth-row {
  align-items: center;
  border-bottom: 1px solid rgba(245, 241, 218, 0.16);
  border-top: 1px solid rgba(245, 241, 218, 0.16);
  display: flex;
  margin-top: 0.7rem;
  min-height: 2.75rem;
  padding: 0.2rem 0.1rem;
}

.wealth-row strong {
  color: rgb(255, 222, 91);
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-left: 0.55rem;
  text-shadow: 0 2px 0 rgb(93, 55, 22);
}

.wealth-label {
  color: rgba(245, 241, 218, 0.62);
  font-size: 0.62rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  margin-left: 0.42rem;
  text-transform: uppercase;
}

.coin-stack {
  height: 1.9rem;
  position: relative;
  width: 2.35rem;
}

.coin-stack i {
  background: linear-gradient(180deg, rgb(255, 230, 101), rgb(224, 154, 39));
  border: 2px solid rgb(108, 65, 22);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 245, 168, 0.48), 0 2px 0 rgba(5, 15, 12, 0.45);
  height: 1.22rem;
  position: absolute;
  width: 1.22rem;
}

.coin-stack i:nth-child(1) { left: 0.02rem; top: 0.47rem; }
.coin-stack i:nth-child(2) { left: 0.72rem; top: 0.07rem; }
.coin-stack i:nth-child(3) { left: 1.05rem; top: 0.64rem; }

.hud-stats {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: 0.85fr 0.85fr 1.3fr;
  margin: 0.58rem 0 0;
}

.hud-stats div {
  min-width: 0;
}

.hud-stats dt {
  color: rgba(245, 241, 218, 0.54);
  font-size: 0.56rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-stats dd {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-weight: bold;
  margin: 0.13rem 0 0;
  white-space: nowrap;
}

.hud-stats small {
  color: rgb(112, 245, 222);
  font-size: 0.58rem;
  font-weight: normal;
}

#equipment-hud {
  border-radius: 0.75rem;
  bottom: max(5.75rem, calc(env(safe-area-inset-bottom) + 5.75rem));
  padding: 0.55rem 0.62rem 0.65rem;
  right: max(0.75rem, env(safe-area-inset-right));
  width: 15rem;
}

#equipment-title {
  border-bottom: 1px solid rgba(255, 205, 65, 0.38);
  color: rgb(255, 222, 91);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  margin: 0 0 0.48rem;
  padding: 0 0 0.38rem;
  text-align: center;
  text-transform: uppercase;
}

.equipment-layout {
  align-items: center;
  display: grid;
  gap: 0.38rem;
  grid-template-columns: 4.25rem 4.25rem 4.25rem;
  grid-template-rows: 4.7rem 4.7rem;
  justify-content: center;
}

.equipment-slot {
  align-items: center;
  align-self: stretch;
  background: rgba(5, 15, 12, 0.52);
  border: 1px solid rgba(245, 241, 218, 0.32);
  border-radius: 0.42rem;
  box-shadow: inset 0 0 0 1px rgba(5, 15, 12, 0.7);
  color: rgb(245, 241, 218);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.equipment-slot:not(.is-empty) {
  border-color: rgba(255, 205, 65, 0.56);
  box-shadow: inset 0 0 12px rgba(255, 205, 65, 0.08);
}

.weapon-slot { grid-column: 1; grid-row: 1; }
.charm-slot { grid-column: 3; grid-row: 1; }
.boots-slot { grid-column: 2; grid-row: 2; }
.off-hand-slot { grid-column: 3; grid-row: 2; }

.slot-label {
  color: rgba(245, 241, 218, 0.48);
  font-size: 0.48rem;
  font-weight: bold;
  left: 0;
  letter-spacing: 0.08em;
  position: absolute;
  right: 0;
  text-align: center;
  text-transform: uppercase;
  top: 0.25rem;
}

.slot-name {
  bottom: 0.24rem;
  font-size: 0.51rem;
  font-weight: bold;
  left: 0.12rem;
  overflow: hidden;
  position: absolute;
  right: 0.12rem;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}

.slot-icon {
  fill: none;
  height: 2.35rem;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  width: 2.35rem;
}

.is-empty .slot-icon,
.equipment-slot.is-empty .slot-name {
  color: rgba(245, 241, 218, 0.38);
}

.weapon-shape,
.charm-equipped,
.boots-winged {
  display: none;
}

#weapon-slot[data-item="none"] .weapon-shape-empty,
#weapon-slot[data-item="sword"] .weapon-shape-sword,
#weapon-slot[data-item="gun"] .weapon-shape-gun,
#weapon-slot[data-item="machineGun"] .weapon-shape-machine-gun,
#charm-slot[data-item="magnet"] .charm-equipped,
#boots-slot[data-item="winged"] .boots-winged {
  display: inline;
}

#charm-slot[data-item="magnet"] .charm-empty,
#boots-slot[data-item="winged"] .boots-standard {
  display: none;
}

.equipment-avatar {
  align-items: center;
  display: flex;
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  justify-content: center;
}

.equipment-avatar svg {
  fill: rgba(245, 241, 218, 0.58);
  filter: drop-shadow(0 2px 0 rgba(5, 15, 12, 0.75));
  height: 4.4rem;
  width: 3.1rem;
}

.potion-icon {
  background: linear-gradient(160deg, rgb(255, 121, 145) 0 56%, rgb(174, 43, 77) 57% 100%);
  border: 2px solid rgb(58, 24, 38);
  border-radius: 0.28rem 0.28rem 0.5rem 0.5rem;
  box-shadow: inset 0.18rem 0.12rem 0 rgba(255, 233, 224, 0.48), 0 0.2rem 0 rgba(5, 15, 12, 0.42);
  display: inline-block;
  height: 1.65rem;
  margin-top: 0.08rem;
  position: relative;
  width: 1.42rem;
}

.potion-icon::before {
  background: rgb(222, 188, 129);
  border: 2px solid rgb(58, 24, 38);
  border-bottom: 0;
  border-radius: 0.18rem 0.18rem 0 0;
  content: "";
  height: 0.42rem;
  left: 0.28rem;
  position: absolute;
  top: -0.55rem;
  width: 0.62rem;
}

.potion-icon i {
  background: rgba(255, 245, 230, 0.72);
  border-radius: 999px;
  height: 0.48rem;
  left: 0.27rem;
  position: absolute;
  top: 0.3rem;
  transform: rotate(24deg);
  width: 0.2rem;
}

.is-empty .potion-icon,
#off-hand-slot[data-item="none"] .potion-icon {
  display: none;
}

#inventory-window {
  align-items: center;
  background: rgba(5, 15, 12, 0.62);
  box-sizing: border-box;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  position: fixed;
  z-index: 18;
}

.inventory-card {
  background: linear-gradient(145deg, rgb(35, 82, 55), rgb(16, 38, 31));
  border: 4px solid rgb(245, 241, 218);
  border-radius: 1.35rem;
  box-shadow: 0 1.2rem 3rem rgba(5, 15, 12, 0.62), inset 0 0 0 2px rgba(5, 15, 12, 0.62);
  box-sizing: border-box;
  max-width: 35rem;
  overflow: hidden;
  width: min(35rem, 100%);
}

.inventory-header {
  align-items: center;
  background: rgba(5, 15, 12, 0.32);
  border-bottom: 2px solid rgba(255, 205, 65, 0.4);
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.15rem 0.9rem;
}

.inventory-header .menu-kicker {
  margin-bottom: 0.22rem;
}

#inventory-title {
  color: rgb(255, 222, 91);
  font-size: 1.65rem;
  margin: 0;
}

#inventory-close {
  background: rgba(5, 15, 12, 0.5);
  border: 2px solid rgba(245, 241, 218, 0.5);
  border-radius: 999px;
  color: rgb(245, 241, 218);
  cursor: pointer;
  font: bold 1.45rem/1 Arial, sans-serif;
  height: 2.3rem;
  width: 2.3rem;
}

#inventory-close:hover,
#inventory-close:focus-visible {
  border-color: rgb(255, 222, 91);
  outline: none;
}

.backpack-shell {
  background: linear-gradient(145deg, rgb(105, 63, 37), rgb(67, 39, 27));
  border: 3px solid rgb(43, 27, 21);
  border-radius: 1.2rem 1.2rem 1.65rem 1.65rem;
  box-shadow: inset 0 0 0 2px rgba(222, 171, 100, 0.24), inset 0 -1rem 2rem rgba(26, 16, 14, 0.3);
  margin: 1.2rem auto;
  max-width: 25rem;
  padding: 1rem;
  position: relative;
}

.backpack-shell::before {
  border: 4px solid rgb(43, 27, 21);
  border-bottom: 0;
  border-radius: 2rem 2rem 0 0;
  content: "";
  height: 2.2rem;
  left: 50%;
  position: absolute;
  top: -1.1rem;
  transform: translateX(-50%);
  width: 7rem;
  z-index: -1;
}

#backpack-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.backpack-slot {
  align-items: center;
  aspect-ratio: 1;
  background: rgba(16, 31, 29, 0.74);
  border: 2px solid rgba(245, 241, 218, 0.34);
  border-radius: 0.65rem;
  color: rgb(245, 241, 218);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font: bold 0.74rem Arial, sans-serif;
  justify-content: center;
  min-height: 5.5rem;
  padding: 0.55rem;
  position: relative;
}

.backpack-slot:not(.is-empty) {
  border-color: rgba(255, 205, 65, 0.7);
}

.backpack-slot.is-equipped {
  box-shadow: 0 0 0 3px rgb(112, 245, 222), inset 0 0 1rem rgba(112, 245, 222, 0.18);
}

.backpack-slot:hover:not(.is-empty),
.backpack-slot:focus-visible:not(.is-empty) {
  background: rgba(30, 78, 58, 0.95);
  outline: none;
}

.backpack-slot.is-empty {
  color: rgba(245, 241, 218, 0.34);
  cursor: default;
}

.slot-number {
  color: rgba(245, 241, 218, 0.38);
  font-size: 0.58rem;
  left: 0.38rem;
  position: absolute;
  top: 0.28rem;
}

.backpack-slot-name {
  margin-top: 0.45rem;
}

.backpack-slot-count {
  background: rgb(255, 205, 65);
  border: 2px solid rgb(43, 27, 21);
  border-radius: 999px;
  bottom: 0.25rem;
  color: rgb(16, 31, 29);
  font-size: 0.72rem;
  min-width: 1rem;
  padding: 0.08rem 0.18rem;
  position: absolute;
  right: 0.25rem;
}

.backpack-slot.is-empty .backpack-slot-count {
  display: none;
}

.inventory-footer {
  background: rgba(5, 15, 12, 0.3);
  border-top: 1px solid rgba(245, 241, 218, 0.18);
  padding: 0.9rem 1.15rem 1.1rem;
}

.inventory-footer p {
  color: rgba(245, 241, 218, 0.72);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0.65rem 0 0;
}

.inventory-off-hand {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
}

.inventory-off-hand span {
  color: rgb(152, 180, 175);
  font-size: 0.68rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.inventory-off-hand strong {
  color: rgb(112, 245, 222);
}

#biome-status {
  background: rgba(16, 31, 29, 0.72);
  border: 1px solid rgba(245, 241, 218, 0.26);
  border-radius: 999px;
  font: bold 0.82rem Arial, sans-serif;
  left: 50%;
  letter-spacing: 0.04em;
  margin: 0;
  padding: 0.42rem 0.78rem;
  pointer-events: none;
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top));
  transform: translateX(-50%);
}

#biome-status span {
  color: rgb(152, 180, 175);
  font-size: 0.67rem;
  letter-spacing: 0.09em;
  margin-right: 0.35rem;
  text-transform: uppercase;
}

#time-status {
  align-items: center;
  background: rgba(16, 31, 29, 0.86);
  border: 2px solid rgba(255, 230, 151, 0.62);
  border-radius: 999px;
  color: rgb(245, 241, 218);
  display: flex;
  font: 0.78rem Arial, sans-serif;
  gap: 0.65rem;
  left: 50%;
  margin: 0;
  padding: 0.42rem 0.8rem;
  position: fixed;
  top: max(3.6rem, calc(env(safe-area-inset-top) + 3.6rem));
  transform: translateX(-50%);
  z-index: 3;
}

#time-status strong { color: rgb(255, 210, 83); }
#time-value { color: rgb(181, 231, 231); }

#village-prompt {
  background: rgba(16, 31, 29, 0.92);
  border: 3px solid rgb(255, 210, 83);
  border-radius: 0.8rem;
  bottom: max(5.2rem, calc(env(safe-area-inset-bottom) + 5.2rem));
  color: rgb(245, 241, 218);
  font: bold 0.95rem Arial, sans-serif;
  left: 50%;
  margin: 0;
  padding: 0.65rem 1rem;
  position: fixed;
  transform: translateX(-50%);
  z-index: 6;
}

.inventory-armor {
  align-items: center;
  display: flex;
  gap: 0.55rem;
}

.inventory-armor span { color: rgb(181, 231, 231); font-size: 0.74rem; text-transform: uppercase; }
.inventory-armor strong { color: rgb(255, 210, 83); }

#armor-slot[data-item="armor1"] { background: linear-gradient(145deg, rgba(91, 117, 91, 0.94), rgba(48, 69, 57, 0.94)); }
#armor-slot[data-item="armor2"] { background: linear-gradient(145deg, rgba(116, 91, 78, 0.96), rgba(58, 51, 57, 0.96)); }
#armor-slot[data-item="armor3"] { background: linear-gradient(145deg, rgba(92, 119, 137, 0.98), rgba(40, 52, 70, 0.98)); }

#shop-window {
  align-items: center;
  background: rgba(5, 15, 12, 0.76);
  box-sizing: border-box;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 24;
}

.shop-card {
  background: linear-gradient(160deg, rgba(34, 54, 44, 0.99), rgba(16, 31, 29, 0.99));
  border: 4px solid rgb(235, 205, 139);
  border-radius: 1.25rem;
  box-shadow: 0 12px 0 rgba(5, 15, 12, 0.7), 0 26px 65px rgba(5, 15, 12, 0.72);
  box-sizing: border-box;
  color: rgb(245, 241, 218);
  max-height: calc(100vh - 2rem);
  max-width: 58rem;
  overflow-y: auto;
  padding: 1.3rem;
  width: 100%;
}

.shop-balance { align-items: center; display: flex; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.shop-balance strong { color: rgb(255, 210, 83); font-size: 1.4rem; }

.shop-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shop-grid button {
  background: rgba(233, 220, 174, 0.1);
  border: 2px solid rgba(233, 220, 174, 0.38);
  border-radius: 0.75rem;
  color: rgb(245, 241, 218);
  cursor: pointer;
  display: grid;
  gap: 0.25rem;
  min-height: 6.6rem;
  padding: 0.75rem;
  text-align: left;
}

.shop-grid button:hover, .shop-grid button:focus-visible { background: rgba(255, 210, 83, 0.16); border-color: rgb(255, 210, 83); outline: none; }
.shop-grid button:disabled { cursor: default; filter: grayscale(0.7); opacity: 0.45; }
.shop-grid button strong { color: rgb(255, 220, 116); font-size: 1rem; }
.shop-grid button span { color: rgb(198, 224, 207); font-size: 0.76rem; }
.shop-grid button em { color: rgb(255, 210, 83); font-size: 0.78rem; font-style: normal; font-weight: bold; }
#shop-message { color: rgb(198, 224, 207); margin: 1rem 0 0; min-height: 1.2rem; }

#network-status {
  background: rgba(16, 31, 29, 0.82);
  border: 2px solid rgba(245, 241, 218, 0.24);
  border-radius: 999px;
  color: rgb(245, 241, 218);
  font-size: 0.82rem;
  padding: 0.45rem 0.7rem;
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  text-decoration: none;
  top: max(0.75rem, env(safe-area-inset-top));
}

#network-status[data-mode="shared"] {
  border-color: rgba(112, 245, 222, 0.65);
  color: rgb(152, 255, 235);
}

#network-status[data-mode="connecting"],
#network-status[data-mode="reconnecting"] {
  color: rgb(255, 222, 91);
}

#music-toggle {
  background: rgba(16, 31, 29, 0.82);
  border: 2px solid rgba(245, 241, 218, 0.24);
  border-radius: 999px;
  color: rgb(245, 241, 218);
  cursor: pointer;
  font: bold 0.82rem Arial, sans-serif;
  padding: 0.45rem 0.7rem;
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  top: max(3.35rem, calc(env(safe-area-inset-top) + 3.35rem));
  z-index: 2;
}

#music-toggle[aria-pressed="false"] {
  color: rgb(152, 180, 175);
}

#music-toggle:hover,
#music-toggle:focus-visible {
  border-color: rgba(112, 245, 222, 0.65);
}

#pause-menu {
  align-items: center;
  background: rgba(5, 15, 12, 0.72);
  box-sizing: border-box;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  position: fixed;
  z-index: 20;
}

.pause-card {
  background: rgba(16, 31, 29, 0.97);
  border: 4px solid rgb(245, 241, 218);
  border-radius: 1.35rem;
  box-shadow: 0 10px 0 rgba(5, 15, 12, 0.78), 0 22px 55px rgba(5, 15, 12, 0.62);
  box-sizing: border-box;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: clamp(1.35rem, 5vw, 2.25rem);
  text-align: center;
  width: min(100%, 27rem);
}

#pause-title {
  color: rgb(255, 205, 65);
  font-size: clamp(2rem, 8vw, 3.2rem);
  margin: 0 0 1.35rem;
  text-shadow: 0 4px 0 rgb(119, 73, 22);
}

#pause-actions {
  display: grid;
  gap: 0.8rem;
}

#pause-main-menu-button {
  align-items: center;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  text-decoration: none;
}

#pause-settings {
  text-align: left;
}

#pause-settings h3 {
  color: rgb(255, 205, 65);
  font-size: 1.35rem;
  margin: 0 0 1.15rem;
  text-align: center;
}

#pause-settings-back-button {
  display: block;
  margin: 0 auto;
}

.brushbound-paused canvas {
  cursor: default;
}

#network-diagnostics-toggle {
  background: rgba(16, 31, 29, 0.82);
  border: 2px solid rgba(245, 241, 218, 0.24);
  border-radius: 999px;
  color: rgb(152, 255, 235);
  cursor: pointer;
  font: bold 0.82rem Arial, sans-serif;
  padding: 0.45rem 0.7rem;
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  top: max(5.95rem, calc(env(safe-area-inset-top) + 5.95rem));
  z-index: 2;
}

#network-diagnostics-toggle:hover,
#network-diagnostics-toggle:focus-visible,
#network-diagnostics-toggle[aria-expanded="true"] {
  border-color: rgba(112, 245, 222, 0.72);
  outline: none;
}

#network-diagnostics {
  background: rgba(5, 15, 12, 0.9);
  border: 2px solid rgba(112, 245, 222, 0.55);
  border-radius: 0.8rem;
  color: rgb(245, 241, 218);
  font: bold 0.74rem/1.55 monospace;
  padding: 0.65rem 0.75rem;
  pointer-events: none;
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right));
  top: max(8.55rem, calc(env(safe-area-inset-top) + 8.55rem));
  white-space: pre;
  z-index: 2;
}

kbd {
  background: rgb(255, 205, 65);
  border: 2px solid rgb(5, 15, 12);
  border-radius: 0.35rem;
  box-shadow: 0 2px 0 rgb(5, 15, 12);
  color: rgb(16, 31, 29);
  display: inline-block;
  font: bold 0.8rem Arial, sans-serif;
  min-width: 1.2rem;
  padding: 0.2rem 0.4rem;
  text-align: center;
}

@media (max-width: 560px) {
  #mode-choice,
  .menu-actions {
    flex-direction: column;
  }

  #options-menu {
    max-width: none;
  }

  .pause-card {
    padding: 1.25rem;
  }

  .controls {
    bottom: max(0.55rem, env(safe-area-inset-bottom));
    font-size: 0.72rem;
    padding: 0.4rem 0.55rem;
  }

  #player-status,
  #biome-status,
  #network-status,
  #music-toggle,
  #network-diagnostics-toggle {
    font-size: 0.7rem;
  }

  #player-status {
    padding: 0.55rem;
    width: 15.25rem;
  }

  #equipment-hud {
    bottom: max(5.3rem, calc(env(safe-area-inset-bottom) + 5.3rem));
    padding: 0.45rem;
    width: 12rem;
  }

  .equipment-layout {
    gap: 0.28rem;
    grid-template-columns: 3.35rem 3.35rem 3.35rem;
    grid-template-rows: 4rem 4rem;
  }

  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-card { padding: 0.9rem; }

  .inventory-card {
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
  }

  .backpack-shell {
    margin: 1rem;
  }

  .backpack-slot {
    min-height: 4.5rem;
  }

  .wealth-row {
    min-height: 2.35rem;
  }

  .wealth-row strong {
    font-size: 1.5rem;
  }

  #network-diagnostics {
    font-size: 0.66rem;
  }

  kbd {
    font-size: 0.68rem;
    min-width: 1rem;
    padding: 0.15rem 0.3rem;
  }
}

@media (max-height: 500px) {
  #equipment-hud {
    transform: scale(0.82);
    transform-origin: bottom right;
  }
}

#character-window {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 25, 29, 0.78);
  backdrop-filter: blur(4px);
}

#character-window[hidden] { display: none; }

.character-card {
  width: min(960px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 22px;
  border: 4px solid #352c27;
  border-radius: 18px;
  color: #29241f;
  background: linear-gradient(145deg, #f5e8c6, #d8bd82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 3px rgba(255,255,255,.28);
}

.character-summary, .character-footer div {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
}

.character-summary {
  margin: 10px 0 18px;
  padding: 12px 15px;
  border-radius: 10px;
  background: rgba(61, 49, 39, .1);
}

.attribute-panel h3, .skill-panel h3 { margin: 14px 0 8px; }
.attribute-panel h3 small, .skill-panel h3 small { font-weight: normal; opacity: .68; }
.attribute-grid, .skill-paths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.attribute-grid button, .skill-path button {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 11px;
  border: 2px solid #66513d;
  border-radius: 9px;
  color: inherit;
  text-align: left;
  background: rgba(255, 250, 224, .72);
  cursor: pointer;
}
.attribute-grid button:hover:not(:disabled), .skill-path button:hover:not(:disabled) { transform: translateY(-1px); background: #fff7d7; }
.attribute-grid button:disabled, .skill-path button:disabled { cursor: not-allowed; opacity: .52; }
.attribute-grid em { color: #7a3f25; font-size: 11px; font-style: normal; font-weight: bold; text-transform: uppercase; }
.skill-path { padding: 10px; border-radius: 11px; background: rgba(83, 66, 49, .1); }
.skill-path h4 { margin: 0 0 8px; text-align: center; }
.skill-path button { margin-top: 8px; min-height: 64px; }
.skill-path button.is-unlocked { border-color: #3e7650; color: #214b31; background: rgba(142, 196, 132, .5); opacity: 1; }
.character-footer { margin-top: 16px; padding-top: 12px; border-top: 2px solid rgba(70,55,42,.28); }
.character-footer p { margin: 0 0 8px; }
#progression-toast { position: fixed; top: 18%; left: 50%; z-index: 40; transform: translateX(-50%); padding: 10px 18px; border: 2px solid #f5d886; border-radius: 999px; color: white; background: rgba(38, 49, 43, .92); box-shadow: 0 5px 18px rgba(0,0,0,.35); }

@media (max-width: 760px) {
  .attribute-grid, .skill-paths { grid-template-columns: 1fr; }
  .character-card { padding: 14px; }
}

@media (max-height: 300px) {
  .controls {
    display: none;
  }

  #music-toggle,
  #network-diagnostics-toggle {
    display: none;
  }

  #player-status {
    transform: scale(0.78);
    transform-origin: top left;
  }

  #equipment-hud {
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    transform: scale(0.62);
    transform-origin: bottom right;
  }
}
