:root {
  --ink: #2b2723;
  --line: #4c3326;
  --wood: #bd9665;
  --wood-dark: #8e704d;
  --paper: #f0dfac;
  --mint: #a9e8bb;
  --green: #5aa35f;
  --gold: #e5c45a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #58cde9;
  color: var(--ink);
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

button,
input,
select {
  font: inherit;
}

#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  image-rendering: pixelated;
}

body:has(#startScreen:not(.hidden)) #world,
body:has(#startScreen:not(.hidden)) .portal-layer,
body:has(#startScreen:not(.hidden)) .effect-layer,
body:has(#startScreen:not(.hidden)) .coin-layer {
  display: none;
}

.coin-layer,
.portal-layer,
.effect-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.portal-layer {
  z-index: 2;
}

.effect-layer {
  z-index: 3;
}

.coin-sprite {
  position: absolute;
  width: 34px;
  height: 39px;
  image-rendering: pixelated;
  transform: translate(-9999px, -9999px);
  will-change: transform;
}

.gem-sprite {
  position: absolute;
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  object-fit: contain;
  transform: translate(-9999px, -9999px);
  will-change: transform;
  filter: drop-shadow(0 4px 0 rgba(0, 20, 60, 0.36)) drop-shadow(0 0 8px rgba(76, 203, 255, 0.5));
}

.portal-sprite {
  position: absolute;
  width: 440px;
  height: 440px;
  image-rendering: pixelated;
  transform: translate(-9999px, -9999px);
  will-change: transform;
}

.hitmarker,
.explosion {
  position: absolute;
  image-rendering: pixelated;
  pointer-events: none;
}

.hitmarker {
  width: 86px;
  height: 86px;
  animation: hitmarker-pop 220ms steps(3) forwards;
}

.explosion {
  width: 210px;
  height: 210px;
  animation: explosion-fade 900ms steps(8) forwards;
}

@keyframes hitmarker-pop {
  from {
    opacity: 1;
    transform: scale(0.72) rotate(-8deg);
  }
  to {
    opacity: 0;
    transform: scale(1.25) rotate(8deg);
  }
}

@keyframes explosion-fade {
  0% {
    opacity: 1;
    transform: scale(0.8);
  }
  85% {
    opacity: 1;
    transform: scale(1.25);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

.shell {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  align-content: start;
  padding-top: clamp(24px, 4vh, 50px);
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(54, 170, 224, 0.04), rgba(58, 124, 67, 0.1)),
    url("assets/splash-background.png") center center / cover no-repeat;
}

.splash-clouds {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.splash-cloud {
  position: absolute;
  width: clamp(140px, 15vw, 280px);
  height: auto;
  opacity: 0.72;
  image-rendering: pixelated;
  animation-name: cloud-drift;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.cloud-a {
  top: 5%;
  animation-duration: 76s;
  animation-delay: -10s;
}

.cloud-b {
  top: 14%;
  width: clamp(110px, 12vw, 230px);
  opacity: 0.58;
  animation-duration: 98s;
  animation-delay: -42s;
}

.cloud-c {
  top: 27%;
  width: clamp(170px, 19vw, 340px);
  opacity: 0.54;
  animation-duration: 118s;
  animation-delay: -64s;
}

.cloud-d {
  top: 9%;
  width: clamp(90px, 10vw, 190px);
  opacity: 0.46;
  animation-duration: 86s;
  animation-delay: -56s;
}

@keyframes cloud-drift {
  from {
    transform: translateX(-34vw);
  }
  to {
    transform: translateX(110vw);
  }
}

.brand {
  display: grid;
  justify-items: center;
  margin-bottom: clamp(10px, 2vh, 22px);
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.28));
  position: relative;
  z-index: 1;
}

.brand img {
  width: min(560px, calc(100vw - 34px));
  height: auto;
  display: block;
}

.auth-window {
  width: min(470px, calc(100vw - 32px));
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 244, 182, 0.16), transparent 38%),
    linear-gradient(180deg, rgba(45, 47, 55, 0.84), rgba(21, 20, 25, 0.92)),
    url("assets/stone-panel.avif") center / 190px auto repeat;
  border: 5px solid #17131a;
  border-radius: 7px;
  box-shadow:
    inset 0 0 0 3px rgba(255, 235, 157, 0.35),
    inset 0 0 0 8px rgba(57, 43, 34, 0.36),
    inset 0 0 44px rgba(0, 0, 0, 0.5),
    0 8px 0 rgba(15, 12, 17, 0.72),
    0 0 0 2px rgba(105, 239, 255, 0.5),
    0 0 32px rgba(157, 70, 255, 0.2);
  pointer-events: auto;
  padding-top: 12px;
  position: relative;
  z-index: 1;
}

.character-picker {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 14px;
  align-items: center;
  justify-items: center;
  padding: 20px 34px 10px;
}

.arrow {
  width: 42px;
  height: 42px;
  color: #fff2bd;
  background:
    linear-gradient(180deg, rgba(255, 239, 164, 0.18), transparent 45%),
    linear-gradient(180deg, #5e5964, #25232c);
  border: 4px solid #17131a;
  border-radius: 5px;
  font-size: 30px;
  font-weight: 1000;
  line-height: 20px;
  text-shadow: 2px 2px 0 #070707;
  box-shadow:
    inset 0 0 0 2px rgba(255, 235, 157, 0.52),
    0 4px 0 rgba(0, 0, 0, 0.48),
    0 0 0 2px rgba(122, 235, 255, 0.32);
}

.hero-preview {
  width: 112px;
  height: 122px;
  display: grid;
  place-items: center;
  overflow: hidden;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.34));
}

.hero-preview canvas {
  width: 112px;
  height: 122px;
  image-rendering: pixelated;
}

.login-form {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 14px 50px 28px;
}

.login-form input,
.login-form select {
  width: min(310px, 100%);
  min-height: 36px;
  background:
    linear-gradient(180deg, #fff4bf, #dfc46e);
  border: 4px solid #17131a;
  border-radius: 4px;
  color: var(--ink);
  padding: 3px 8px;
  text-align: center;
  font-weight: 900;
  box-shadow:
    inset 0 0 0 2px #fff8d8,
    0 4px 0 rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(114, 234, 255, 0.22);
}

.login-form input::placeholder {
  color: rgba(43, 39, 35, 0.62);
  text-transform: lowercase;
}

.login-form input.error {
  background:
    linear-gradient(180deg, #ffd6dc, #d98794);
  box-shadow:
    inset 0 0 0 2px #ffe9ed,
    0 4px 0 rgba(0, 0, 0, 0.32),
    0 0 0 2px rgba(255, 125, 150, 0.42);
}

.enter,
.wallet {
  justify-self: center;
  width: min(260px, 100%);
  min-height: 42px;
  margin-top: 2px;
  color: #1f1b20;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 40%),
    linear-gradient(180deg, #ffe687, #d39a32);
  border: 4px solid #17131a;
  border-radius: 5px;
  font-weight: 1000;
  box-shadow:
    inset 0 0 0 2px #fff4b8,
    0 5px 0 rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(255, 225, 88, 0.48),
    0 0 18px rgba(255, 199, 66, 0.22);
}

.wallet {
  width: min(270px, 100%);
  margin-top: 8px;
  color: #f8ffe9;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 42%),
    linear-gradient(180deg, #9f55ef, #4a1b86);
  text-shadow: 2px 2px 0 #261438;
  box-shadow:
    inset 0 0 0 2px #b987ff,
    0 5px 0 rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(164, 105, 255, 0.58),
    0 0 22px rgba(166, 75, 255, 0.26);
}

.wallet.connected {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 42%),
    linear-gradient(180deg, #4aba82, #207a51);
  box-shadow:
    inset 0 0 0 2px #8ff1b7,
    0 5px 0 rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(123, 239, 176, 0.5),
    0 0 22px rgba(87, 235, 162, 0.24);
}

.wallet.error {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 42%),
    linear-gradient(180deg, #d95e72, #7d2338);
  box-shadow:
    inset 0 0 0 2px #ffadb8,
    0 5px 0 rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(255, 125, 150, 0.48);
}

.enter:hover,
.wallet:hover,
.arrow:hover {
  filter: brightness(1.08) saturate(1.06);
}

.enter:active,
.wallet:active,
.arrow:active {
  transform: translateY(2px);
}

.hud {
  position: fixed;
  z-index: 4;
  top: 12px;
  left: auto;
  right: 12px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}

.hud-panel,
.chat,
.online-badge {
  color: #fff8dd;
  background: rgba(116, 80, 48, 0.9);
  border: 4px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(239, 207, 146, 0.7);
  text-shadow: 2px 2px 0 var(--ink);
}

.hud-panel {
  padding: 7px 12px;
  font-weight: 1000;
}

.stat-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-label {
  min-width: 31px;
  color: #d9ffae;
  font-weight: 1000;
}

.hearts {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 112px;
}

.heart {
  width: 21px;
  height: 21px;
  object-fit: contain;
  image-rendering: pixelated;
}

.heart.empty {
  filter: grayscale(1) brightness(0.42);
  opacity: 0.55;
}

.sol-balance {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sol-balance img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
}

.online-badge {
  position: fixed;
  z-index: 4;
  right: 12px;
  bottom: 212px;
  padding: 8px 12px;
  font-weight: 1000;
  pointer-events: none;
}

.leaderboard-button {
  position: fixed;
  z-index: 5;
  top: 12px;
  left: 12px;
  min-height: 42px;
  padding: 7px 14px;
  color: #fff8dd;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 42%),
    linear-gradient(180deg, #7d4ce0, #3d1b75);
  border: 4px solid #201629;
  border-radius: 6px;
  font-weight: 1000;
  text-shadow: 2px 2px 0 #17131a;
  box-shadow:
    inset 0 0 0 2px rgba(190, 146, 255, 0.75),
    0 5px 0 rgba(0, 0, 0, 0.44),
    0 0 0 2px rgba(95, 231, 255, 0.34);
}

.leaderboard-button:hover {
  filter: brightness(1.08) saturate(1.08);
}

.leaderboard-button:active {
  transform: translateY(2px);
}

.leaderboard-panel {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(14, 10, 20, 0.42);
  pointer-events: auto;
}

.leaderboard-card {
  width: min(680px, calc(100vw - 28px));
  color: #fff8dd;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 227, 126, 0.18), transparent 35%),
    linear-gradient(180deg, rgba(55, 53, 62, 0.92), rgba(24, 22, 30, 0.96)),
    url("assets/stone-panel.avif") center / 170px auto repeat;
  border: 5px solid #17131a;
  border-radius: 7px;
  box-shadow:
    inset 0 0 0 3px rgba(255, 235, 157, 0.34),
    inset 0 0 38px rgba(0, 0, 0, 0.48),
    0 8px 0 rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(95, 231, 255, 0.38);
  overflow: hidden;
}

.leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(35, 21, 54, 0.72);
  border-bottom: 4px solid #17131a;
  font-size: 18px;
  text-shadow: 2px 2px 0 #17131a;
}

.leaderboard-head button {
  width: 34px;
  height: 34px;
  color: #fff8dd;
  background: linear-gradient(180deg, #e06478, #8d243d);
  border: 3px solid #17131a;
  border-radius: 5px;
  font-size: 24px;
  font-weight: 1000;
  line-height: 20px;
  box-shadow: inset 0 0 0 2px rgba(255, 205, 205, 0.45);
}

.leaderboard-table {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 42px minmax(150px, 1.25fr) minmax(100px, 1fr) minmax(74px, 0.45fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 6px 9px;
  background: rgba(239, 220, 165, 0.18);
  border: 3px solid rgba(23, 19, 26, 0.86);
  border-radius: 5px;
  font-weight: 1000;
  text-shadow: 2px 2px 0 #17131a;
}

.leaderboard-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-header {
  color: #ffe88c;
  background: rgba(28, 21, 37, 0.78);
}

.leaderboard-row.current {
  color: #fff8c8;
  background: rgba(116, 65, 196, 0.54);
  box-shadow:
    inset 0 0 0 2px rgba(122, 235, 255, 0.38),
    0 0 16px rgba(145, 78, 255, 0.24);
}

.wallet-ok {
  color: #a9ffc8;
}

.wallet-off {
  color: #f7a3b1;
}

.chat {
  position: fixed;
  z-index: 4;
  left: 12px;
  bottom: 12px;
  width: min(380px, calc(100vw - 24px));
  padding: 10px;
  font-weight: 900;
  pointer-events: auto;
}

.chat-line + .chat-line {
  margin-top: 4px;
}

.chat-title {
  margin-bottom: 7px;
  color: #d9ffae;
  font-size: 14px;
  font-weight: 1000;
}

.chat-messages {
  max-height: 150px;
  overflow: hidden;
  padding-right: 2px;
}

.chat-line {
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 6px;
  margin-top: 9px;
}

.chat-form input,
.chat-form button {
  min-height: 34px;
  border: 3px solid var(--line);
  border-radius: 4px;
  font-weight: 900;
}

.chat-form input {
  min-width: 0;
  padding: 4px 8px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: inset 0 0 0 2px #fff4c2;
}

.chat-form button {
  color: var(--ink);
  background: #e6c36f;
  box-shadow: inset 0 0 0 2px #fff0a6;
}

.hidden {
  display: none;
}

@media (max-width: 620px) {
  .shell {
    padding-top: 36px;
  }

  .login-form {
    padding-inline: 18px;
  }

  .leaderboard-row {
    grid-template-columns: 32px minmax(92px, 1fr) minmax(76px, 0.8fr) 58px;
    gap: 5px;
    font-size: 12px;
  }

  .event {
    margin-left: 0;
    width: 100%;
  }
}
