:root {
  --green: #7cfc00;
  --green-deep: #2e7d12;
  --croak: #b6ff5e;
  --gold: #ffd166;
  --cyan: #7fd9ff;
  --bg0: #0c140d;
  --bg1: #14241a;
  --panel: rgba(10, 20, 13, 0.82);
  --bd: rgba(124, 252, 0, 0.32);
  --pixel: "Press Start 2P", monospace;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
  color: #eafff0;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
}
.hidden {
  display: none !important;
}
kbd {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font: 11px monospace;
}
.croak {
  color: var(--croak);
  font-weight: 700;
}
#game {
  position: fixed;
  inset: 0;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
  background: #3f6b38;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  font-size: 13px;
}
.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

/* citizen card */
#playercard {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 250px;
}
.pc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 15px;
}
.cls {
  font-size: 11px;
  color: var(--cyan);
  background: rgba(127, 217, 255, 0.12);
  padding: 3px 7px;
  border-radius: 6px;
}
.res-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 10px;
}
.res {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.res-ico {
  font-size: 13px;
}
.res-ico.croak {
  color: var(--croak);
}
.res span:nth-child(2) {
  font-weight: 800;
  font-size: 15px;
}
.res-lbl {
  font-size: 10px;
  opacity: 0.6;
}

/* city bar */
#citybar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 50vw);
  text-align: center;
}
.cb-top {
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--gold);
}
.cb-lvl {
  color: #fff;
}
.cb-bar {
  height: 12px;
  margin: 8px 0 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  overflow: hidden;
}
#prosperityFill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green-deep), var(--green), var(--gold));
  transition: width 0.4s;
}
.cb-text {
  font-size: 11px;
  opacity: 0.8;
  font-family: monospace;
}

/* right column */
#rightcol {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 210px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lb-panel {
  padding: 8px 10px !important;
}
.lb-head {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--gold);
  margin-bottom: 8px;
  text-align: center;
}
#leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
}
#leaderboard li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#leaderboard .rank {
  width: 16px;
  text-align: right;
  opacity: 0.6;
  font-family: monospace;
}
#leaderboard .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}
#leaderboard .nm {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#leaderboard .amt {
  color: var(--gold);
  font-weight: 700;
  font-family: monospace;
}
#leaderboard li.me {
  background: rgba(124, 252, 0, 0.1);
  border-radius: 4px;
}
#minimap {
  pointer-events: none;
  border-radius: 8px;
  background: rgba(8, 18, 12, 0.8);
  border: 1px solid var(--bd);
  width: 190px;
  height: 142px;
  align-self: flex-end;
}

/* plot panel */
#plotpanel {
  position: absolute;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%);
  width: min(320px, 86vw);
  text-align: center;
}
.pp-title {
  font-weight: 800;
  font-size: 15px;
}
.pp-sub {
  font-size: 12px;
  opacity: 0.8;
  margin: 4px 0 9px;
}
.pp-btn {
  font-family: var(--pixel);
  font-size: 10px;
  color: #0a120c;
  background: linear-gradient(180deg, #9be15d, #5be84d);
  border: none;
  border-radius: 9px;
  padding: 11px 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 #2e7d12;
}
.pp-btn:disabled {
  filter: grayscale(0.7);
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* objective */
.objbar {
  position: absolute;
  bottom: 152px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 16, 12, 0.84);
  border: 1px solid rgba(120, 255, 170, 0.45);
  color: #dffbe6;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 20px;
  pointer-events: none;
  max-width: 84vw;
  text-align: center;
}

/* city buzz */
.cb-buzz {
  font-size: 11px;
  color: var(--gold);
  margin-top: 3px;
  min-height: 14px;
}

/* chat */
#chat {
  position: absolute;
  bottom: 76px;
  left: 14px;
  width: 320px;
  max-width: 42vw;
  z-index: 22;
}
#chatlog {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  pointer-events: none;
}
.chatmsg {
  background: rgba(10, 20, 13, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 13px;
  width: fit-content;
  max-width: 100%;
  animation: tin 0.2s ease;
  word-break: break-word;
}
#chatInput {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--bd);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
}
#chatInput:focus {
  outline: none;
  border-color: var(--green);
}

/* controls */
#controls {
  position: absolute;
  bottom: 14px;
  left: 14px;
  font-size: 12px;
  line-height: 1.9;
}
#connDot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5be84d;
  margin-left: 4px;
}
#connDot.bad {
  background: #ff5050;
}

/* actions */
#actions {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}
.actbtn {
  font-family: var(--pixel);
  font-size: 9px;
  color: #0a120c;
  background: linear-gradient(180deg, #9be15d, #5be84d);
  border: none;
  border-radius: 10px;
  padding: 12px 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2e7d12, 0 6px 14px rgba(0, 0, 0, 0.4);
}
.actbtn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2e7d12;
}
.actbtn .hot {
  background: rgba(0, 0, 0, 0.22);
  padding: 1px 4px;
  border-radius: 4px;
  margin-left: 3px;
}
.actbtn.collect {
  background: linear-gradient(180deg, #ffe08a, #ffd166);
  box-shadow: 0 4px 0 #b8860b;
  color: #3a2a00;
}
.actbtn.collect .rate {
  font-size: 8px;
  opacity: 0.7;
}
.actbtn.collect.ready {
  animation: glow 1.2s infinite;
}
@keyframes glow {
  50% {
    filter: brightness(1.25);
  }
}
.actbtn.claim {
  background: linear-gradient(180deg, #c8a6ff, #9b6dff);
  color: #160a2e;
  box-shadow: 0 4px 0 #5b2db8;
}
.iconbtn {
  background: var(--panel);
  border: 1px solid var(--bd);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 16px;
}

/* toasts */
#toasts {
  position: absolute;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  z-index: 30;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  animation: tin 0.25s ease, tout 0.4s ease forwards 3.6s;
  max-width: 80vw;
  text-align: center;
}
.toast.good {
  border-color: var(--green);
  color: var(--croak);
}
.toast.gold {
  border-color: var(--gold);
  color: var(--gold);
  font-family: var(--pixel);
  font-size: 11px;
}
.toast.bad {
  border-color: #ff5050;
  color: #ff8a8a;
}
@keyframes tin {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}
@keyframes tout {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 5, 0.72);
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(440px, 92vw);
  background: linear-gradient(180deg, var(--bg1), var(--bg0));
  border: 2px solid var(--bd);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h2 {
  font-family: var(--pixel);
  font-size: 14px;
  color: var(--green);
  margin: 0;
}
.x {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
}
.modal-sub {
  font-size: 13px;
  opacity: 0.85;
  margin: 10px 0 16px;
}
#buildList {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.build-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
}
.build-item.locked {
  opacity: 0.55;
}
.bi-info {
  flex: 1;
}
.bi-name {
  font-weight: 800;
}
.bi-sub {
  font-size: 11px;
  opacity: 0.75;
}
.bi-btn {
  font-family: var(--pixel);
  font-size: 9px;
  background: linear-gradient(180deg, #9be15d, #5be84d);
  color: #0a120c;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 #2e7d12;
}
.bi-btn:disabled {
  filter: grayscale(0.8);
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.claim-amount {
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  color: var(--gold);
  margin: 8px 0 16px;
}
.claim-unit {
  font-size: 16px;
  opacity: 0.7;
}
.bigbtn {
  display: block;
  width: 100%;
  font-family: var(--pixel);
  font-size: 12px;
  color: #0a120c;
  background: linear-gradient(180deg, #9be15d, #5be84d);
  border: none;
  border-radius: 12px;
  padding: 15px;
  cursor: pointer;
  box-shadow: 0 5px 0 #2e7d12;
}
.bigbtn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #2e7d12;
}
.bigbtn.wallet {
  background: linear-gradient(180deg, #c8a6ff, #9b6dff);
  color: #160a2e;
  box-shadow: 0 5px 0 #5b2db8;
  margin-bottom: 10px;
}
.voucher {
  margin-top: 16px;
  background: #061008;
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 12px;
  font: 11px monospace;
  word-break: break-all;
}
.voucher .vrow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}
.voucher .vk {
  color: var(--cyan);
  opacity: 0.8;
}
.voucher .copy {
  margin-top: 8px;
  width: 100%;
  background: rgba(127, 217, 255, 0.15);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}
.disclaimer {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 16px;
  line-height: 1.5;
}
.disclaimer code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}
.xlink {
  color: var(--cyan);
  text-decoration: none;
  font-weight: 700;
}
.xlink:hover {
  text-decoration: underline;
}

/* landing social row */
.logo-social {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.beta {
  font-family: var(--pixel);
  font-size: 9px;
  color: #0a120c;
  background: var(--gold);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 1px;
}
.logo-social .xlink {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bd);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
}

/* first-run */
.firstrun {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 8, 5, 0.78);
  backdrop-filter: blur(4px);
  pointer-events: auto;
  z-index: 45;
}
.fr-card {
  width: min(450px, 90vw);
  background: linear-gradient(180deg, var(--bg1), var(--bg0));
  border: 2px solid var(--bd);
  border-radius: 16px;
  padding: 22px 24px;
}
.fr-card h3 {
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--green);
  margin: 0 0 14px;
}
.fr-card ul {
  margin: 0 0 18px;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.8;
}

/* mobile */
#mobile-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
}
#joystick {
  position: absolute;
  left: 26px;
  bottom: 96px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(124, 252, 0, 0.08);
  border: 2px solid rgba(124, 252, 0, 0.35);
  pointer-events: auto;
  touch-action: none;
}
#joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #9be15d, #5be84d);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.touch-actions {
  position: absolute;
  right: 30px;
  bottom: 110px;
  pointer-events: auto;
}
.touchbtn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(124, 252, 0, 0.5);
  background: rgba(95, 240, 200, 0.25);
  font-size: 34px;
  touch-action: none;
}
.touchbtn.held {
  filter: brightness(1.5);
  transform: scale(0.94);
}

/* landing */
#landing {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 28%, #1a3a22, #060d09 70%);
}
.landing-bg {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(124, 252, 0, 0.12) 1px, transparent 1px);
  background-size: 26px 26px;
  animation: drift 28s linear infinite;
  opacity: 0.5;
}
@keyframes drift {
  to {
    background-position: 260px 260px;
  }
}
.landing-inner {
  position: relative;
  text-align: center;
  padding: 24px 20px 80px;
  max-width: 560px;
}
.logo-pepe {
  font-size: 60px;
}
.logo h1 {
  font-family: var(--pixel);
  font-size: clamp(24px, 6vw, 42px);
  margin: 8px 0 0;
  color: var(--green);
  text-shadow: 0 0 18px rgba(124, 252, 0, 0.5), 4px 4px 0 #1c4a0c;
  letter-spacing: 2px;
}
.logo-sub {
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1px;
  margin-top: 10px;
  opacity: 0.9;
}
#loadwrap {
  width: 320px;
  max-width: 86vw;
  margin: 26px auto 0;
}
.loadbar {
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--bd);
}
#loadfill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green-deep), var(--green));
  transition: width 0.2s;
}
#loadtext {
  margin-top: 10px;
  font-size: 12px;
  opacity: 0.7;
  font-family: monospace;
}
#joinform {
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--bd);
  border-radius: 16px;
  padding: 22px;
  text-align: left;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}
.field {
  display: block;
  margin-bottom: 16px;
}
.field > span {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.7;
  margin-bottom: 8px;
}
#nameInput {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid var(--bd);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}
#nameInput:focus {
  outline: none;
  border-color: var(--green);
}
#classCards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.classcard {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 4px;
  cursor: pointer;
  text-align: center;
  color: #eafff0;
  transition: transform 0.1s, border-color 0.1s;
}
.classcard:hover {
  transform: translateY(-2px);
}
.classcard.sel {
  border-color: var(--green);
  background: rgba(124, 252, 0, 0.12);
}
.cc-emoji {
  font-size: 24px;
}
.cc-name {
  font-weight: 800;
  font-size: 12px;
  margin-top: 2px;
}
.cc-perk {
  font-size: 9px;
  opacity: 0.7;
  margin-top: 3px;
  line-height: 1.3;
}
#swatches {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.1s;
}
.swatch:hover {
  transform: scale(1.12);
}
.swatch.sel {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}
.btns {
  margin-top: 6px;
}
.wallet-status {
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
  min-height: 16px;
  color: var(--cyan);
}
.credits {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  opacity: 0.45;
  padding: 0 16px;
}

@media (max-width: 760px) {
  #rightcol {
    width: 140px;
  }
  #minimap {
    width: 130px;
    height: 97px;
  }
  #playercard {
    width: 200px;
  }
  #citybar {
    width: 56vw;
  }
  .actbtn {
    font-size: 10px;
    padding: 12px 12px;
    min-height: 44px;
  }
  .bi-btn {
    font-size: 11px;
    padding: 13px 16px;
    min-height: 44px;
  }
  #actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 62vw;
  }
  #controls {
    display: none;
  }
  #chat {
    left: 50%;
    transform: translateX(-50%);
    bottom: 210px;
    width: 80vw;
    max-width: 80vw;
  }
  #classCards {
    grid-template-columns: repeat(2, 1fr);
  }
}
