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; }

.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;
}

#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;
}

#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;
  }

  .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;
  }
}

@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;
  }
}
