/* MergeTown UI. Blocky, chunky, MineTown-adjacent. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #3b3a32;
  --panel: #f7f4ec;
  --accent: #edc22e;
  --accent-d: #c79a1f;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #7ec0ee;
  font-family: "Trebuchet MS", Verdana, system-ui, sans-serif;
  color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

#topbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px;
}
.stat {
  background: rgba(59,58,50,.82); color: #fff;
  padding: 6px 14px; border-radius: 8px; text-align: center; min-width: 72px;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.stat .label { display: block; font-size: 10px; letter-spacing: 1px; opacity: .75; }
.stat span:last-child { font-size: 20px; font-weight: bold; }

#leaderboard {
  position: absolute; top: 12px; right: 12px;
  background: rgba(247,244,236,.92); border-radius: 10px; padding: 10px 12px;
  min-width: 160px; box-shadow: 0 3px 0 rgba(0,0,0,.2); font-size: 13px;
}
.lb-title { font-weight: bold; margin-bottom: 6px; }
#lb-list { list-style: none; }
#lb-list li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
#lb-list li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
#lb-list li.me { color: var(--accent-d); font-weight: bold; }

.ui-btn {
  position: absolute; bottom: 14px;
  background: var(--accent); color: var(--ink); border: none;
  padding: 10px 16px; border-radius: 10px; font-weight: bold; font-size: 14px;
  cursor: pointer; box-shadow: 0 4px 0 var(--accent-d);
}
.ui-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-d); }
#btn-reset { right: 14px; }
#btn-mute { right: 150px; padding: 10px 12px; }

/* ---- Touch controls ---- */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#touch.hidden { display: none; }
#dpad {
  position: absolute; left: 18px; bottom: 24px;
  display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px);
  gap: 6px; pointer-events: auto;
}
#dpad .dbtn { font-size: 22px; }
#dpad [data-dir="N"] { grid-column: 2; grid-row: 1; }
#dpad [data-dir="W"] { grid-column: 1; grid-row: 2; }
#dpad [data-dir="E"] { grid-column: 3; grid-row: 2; }
#dpad [data-dir="S"] { grid-column: 2; grid-row: 2; }
.dbtn, .cbtn {
  background: rgba(59,58,50,.55); color: #fff; border: 2px solid rgba(255,255,255,.35);
  border-radius: 12px; font-weight: bold; cursor: pointer;
}
.dbtn:active, .cbtn:active { background: rgba(237,194,46,.85); color: var(--ink); }
#cam-controls {
  position: absolute; right: 18px; bottom: 96px; display: flex; gap: 8px; pointer-events: auto;
}
#cam-controls .cbtn { width: 52px; height: 52px; font-size: 22px; }

/* ---- Overlays ---- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30,40,55,.55); backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }
.panel {
  background: var(--panel); border-radius: 16px; padding: 26px 30px;
  width: min(90vw, 380px); text-align: center; box-shadow: 0 10px 0 rgba(0,0,0,.25);
}
.panel h1 { font-size: 40px; color: var(--accent-d); letter-spacing: 1px; margin-bottom: 6px; }
.panel h2 { font-size: 26px; margin-bottom: 12px; color: var(--accent-d); }
.tag { margin-bottom: 18px; line-height: 1.5; }
.hint { margin-top: 14px; font-size: 12px; opacity: .7; }
#name-input {
  width: 100%; padding: 12px; font-size: 16px; text-align: center;
  border: 3px solid #d8d2c2; border-radius: 10px; margin-bottom: 14px; outline: none;
}
#name-input:focus { border-color: var(--accent); }
.big-btn {
  background: var(--accent); color: var(--ink); border: none;
  padding: 14px 40px; border-radius: 12px; font-size: 20px; font-weight: bold;
  cursor: pointer; box-shadow: 0 5px 0 var(--accent-d);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-d); }
#whatsnew-body { text-align: left; line-height: 1.6; margin-bottom: 18px; font-size: 14px; }
#whatsnew-body ul { margin-left: 18px; }

#conn {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: #c0392b; color: #fff; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; z-index: 30;
}
#conn.hidden { display: none; }

@media (max-width: 640px) {
  #leaderboard { font-size: 11px; min-width: 130px; padding: 8px; }
  #btn-mute { right: auto; left: 14px; top: 64px; bottom: auto; }
  #btn-reset { bottom: auto; top: 64px; right: 14px; }
  .panel h1 { font-size: 34px; }
}
