* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #87ceeb;
  color: #fff;
  user-select: none;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* HUD (top-left) */
#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  z-index: 5;
  max-height: calc(100vh - 180px);
}
#ore {
  background: rgba(0, 0, 0, 0.55);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#ore-count { color: #ffe66d; }
#hint {
  background: rgba(0, 0, 0, 0.45);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  opacity: 0.85;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Leaderboard (top-right, below online-pill) */
#leaderboard {
  position: absolute;
  top: 42px;             /* below online-pill */
  right: 12px;
  min-width: 180px;
  max-width: 220px;
  max-height: 38vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
}
#leaderboard h3 {
  font-size: 10px;
  margin-bottom: 5px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#leaderboard ul { list-style: none; }
#leaderboard li {
  font-size: 11px;
  padding: 3px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.3;
}
#leaderboard li:last-child { border-bottom: none; }
#leaderboard li span:last-child { color: #ffe66d; font-weight: 700; }
#leaderboard .you { color: #ffe66d; }
#leaderboard .you span:last-child { color: #ffe66d; }
#leaderboard .agent { opacity: 0.75; font-style: italic; }

/* Players-online counter pill (above the leaderboard) */
#online-pill {
  position: absolute;
  top: 12px;
  right: 12px;
  /* leaderboard repositions itself via top below this */
  background: rgba(102, 224, 255, 0.18);
  border: 1px solid rgba(102, 224, 255, 0.5);
  color: #66e0ff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 6;
}
#online-pill .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: #66e0ff;
  margin-right: 5px;
  animation: online-pulse 1.6s ease-in-out infinite;
}
@keyframes online-pulse { 50% { opacity: 0.35; } }

/* Status (bottom-left) */
#status {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 10px;
  opacity: 0.7;
}
#status.ok { color: #b6f5b6; }
#status.err { color: #ff8a8a; }

/* Login modal */
#login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Soft vignette so the orbiting island scene shows through behind the panel */
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.75) 70%);
  z-index: 10;
  pointer-events: auto;
}
#login.hidden { display: none; }
#login .panel {
  background: rgba(10, 18, 28, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 36px 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
#login h1 { font-size: 28px; margin-bottom: 10px; }
#login p { opacity: 0.85; margin-bottom: 18px; font-size: 14px; line-height: 1.4; }
#login p.small { font-size: 11px; opacity: 0.55; margin-top: 14px; margin-bottom: 0; }
#login input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}
#login input:focus { border-color: #ffe66d; }
#login button {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #ffe66d;
  color: #1a1a1a;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
#login button:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255, 230, 109, 0.3); }
#login button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Floating world labels */
.label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.label.agent-label { color: #ffb3b3; }
.label.player-label { color: #b3e0ff; }
.label.you-label { color: #ffe66d; }

/* Mine prompt */
.mine-prompt {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 10px;
  background: rgba(255, 230, 109, 0.95);
  color: #1a1a1a;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  animation: bob 1s ease-in-out infinite alternate;
}
@keyframes bob {
  from { transform: translate(-50%, -100%) translateY(0); }
  to   { transform: translate(-50%, -100%) translateY(-4px); }
}

/* HP bar above damaged crystals */
.hp-bar {
  position: absolute;
  width: 56px;
  height: 7px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff5252 0%, #ffb347 50%, #b9ff66 100%);
  transition: width 0.12s ease-out;
  border-radius: 3px;
}

/* Auto-mine toggle button */
#auto-mine-btn {
  pointer-events: auto;
  align-self: flex-start;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.2s;
  font-family: inherit;
}
#auto-mine-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.4);
}
#auto-mine-btn:active { transform: translateY(0); }
#auto-mine-btn.on {
  background: #ffe66d;
  color: #1a1a1a;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(255, 230, 109, 0.4);
}
#auto-mine-btn.on::before {
  content: '● ';
  color: #2e7d32;
}

/* ---------- Chat ---------- */
#chat {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 280px;
  max-width: 32vw;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  z-index: 3;
}
#chat-log {
  max-height: 140px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  line-height: 1.4;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
#chat-log::-webkit-scrollbar { width: 6px; }
#chat-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 3px; }
#chat-log:empty { display: none; }
#chat-log .msg { margin: 1px 0; word-wrap: break-word; }
#chat-log .from { color: #ffe66d; font-weight: 700; margin-right: 3px; }
#chat-log .msg.system { color: #b3e0ff; font-style: italic; opacity: 0.8; }
#chat-log .msg.system .from { color: #b3e0ff; }

#chat-input {
  display: none;
  pointer-events: auto;
  padding: 6px 10px;
  font-size: 11px;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#chat-input.open { display: block; }
#chat-input:focus { border-color: #ffe66d; background: rgba(0, 0, 0, 0.8); }

/* ---------- Minimap ---------- */
#minimap-wrap {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#minimap {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 0 24px rgba(0, 0, 0, 0.4);
}
#minimap-legend {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  gap: 10px;
  align-items: center;
}
#minimap-legend .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}
#minimap-legend .dot.you   { background: #ffe66d; }
#minimap-legend .dot.other { background: #4fc3f7; }
#minimap-legend .dot.bot   { background: #ff7043; }
#minimap-legend .dot.ore   { background: #b15bff; }

/* ---------- Stats panel ---------- */
#stats {
  margin-top: 4px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 10px;
  min-width: 180px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
#stats[hidden] { display: none; }
#stats-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  margin-bottom: 5px;
  opacity: 0.85;
}
#stat-trait {
  color: #ffe66d;
  letter-spacing: 1px;
}
#stats .stat-row {
  display: grid;
  grid-template-columns: 14px 28px 1fr 32px 22px;
  align-items: center;
  gap: 5px;
  margin: 3px 0;
}
#stats .stat-icon { font-size: 11px; line-height: 1; }
#stats .stat-name { font-size: 9px; opacity: 0.65; letter-spacing: 0.4px; }
#stats .stat-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
#stats .stat-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffe66d, #ff9800);
  border-radius: 2px;
  transition: width 0.4s ease-out;
}
#bar-str { background: linear-gradient(90deg, #ff8a80, #c62828) !important; }
#bar-spd { background: linear-gradient(90deg, #b9f6ca, #2e7d32) !important; }
#bar-lck { background: linear-gradient(90deg, #fff59d, #f9a825) !important; }
#bar-mr  { background: linear-gradient(90deg, #b3e5fc, #1565c0) !important; }
#stats .stat-val {
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#leaderboard .trait {
  font-size: 11px;
  font-style: normal;
  opacity: 0.6;
  font-weight: 400;
  margin-left: 2px;
}
#leaderboard .you .trait { opacity: 0.8; color: #ffe66d; }

/* ---------- Wallet section in login modal ---------- */
#wallet-section {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  text-align: left;
}
.wallet-line {
  font-size: 12px;
  margin-bottom: 8px;
  word-break: break-all;
}
.wallet-line.muted { opacity: 0.7; }
.wallet-line.ok    { color: #b9f6ca; }
.wallet-line.warn  { color: #ffcc80; }
.wallet-line.err   { color: #ff8a80; }

#wallet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
#wallet-actions button {
  flex: 1;
  min-width: 130px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  font-family: inherit;
}
#wallet-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.4);
}
#wallet-actions button:disabled { opacity: 0.5; cursor: default; }
#wallet-mint-btn {
  background: linear-gradient(135deg, #ffe66d, #ff9800) !important;
  color: #1a1a1a !important;
  border: none !important;
}

/* Holder badge in leaderboard */
#leaderboard .holder { color: #ffe66d; }
#leaderboard li .holder-mark { margin-right: 2px; }

/* Locked name input (NFT holder identity) */
#name-input.locked {
  background: rgba(255, 215, 100, 0.10);
  border-color: rgba(255, 215, 100, 0.45);
  color: #ffe66d;
  cursor: not-allowed;
  font-weight: 700;
}
#name-input.locked::after { content: ' 🔒'; }

/* ---------- Login: logo + X link ---------- */
#logo {
  display: block;
  width: 280px;
  max-width: 100%;
  height: auto;
  margin: -8px auto 14px;
  /* Subtle drop shadow so it lifts off the panel */
  filter: drop-shadow(0 6px 18px rgba(102, 224, 255, 0.18));
  /* Slight idle float */
  animation: logo-float 4.5s ease-in-out infinite;
}
@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

#x-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.18s ease;
}
#x-link:hover {
  color: #fff;
  border-color: rgba(102, 224, 255, 0.55);
  background: rgba(102, 224, 255, 0.08);
  transform: translateY(-1px);
}
#x-link svg { display: block; }

/* Make the bold-button label match the new shorter panel since we removed the h1 */
#login p.small { margin-top: 12px; }

/* ---------- Holder label above head (gold tint) ---------- */
.label.holder {
  color: #ffe66d;
  text-shadow: 0 0 6px rgba(255, 215, 100, 0.6), 0 1px 2px rgba(0,0,0,0.85);
}

/* ---------- Offline players in leaderboard ---------- */
#leaderboard li.offline {
  opacity: 0.55;
  font-style: italic;
}
#leaderboard li.offline:hover { opacity: 0.9; }
#leaderboard li .offline-mark { margin-right: 3px; opacity: 0.8; }

/* ---------- Level / XP / progression UI ---------- */
#level-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  background: linear-gradient(135deg, #ffe66d, #ff9800);
  color: #1a1a1a;
  border-radius: 999px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.5px;
}
#xp-row {
  display: block;
  margin: 6px 0 8px;
  width: 100%;
}
#xp-bar {
  display: block;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}
#xp-row[hidden] { display: none; }
#xp-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #66e0ff, #ffe66d);
  transition: width 0.3s ease;
}
#xp-text {
  font-size: 10px;
  opacity: 0.7;
  text-align: right;
}
#unspent-row {
  margin: 4px 0 8px;
  padding: 6px 10px;
  background: rgba(255, 215, 100, 0.18);
  border: 1px solid rgba(255, 215, 100, 0.5);
  border-radius: 6px;
  font-size: 12px;
  color: #ffe66d;
  font-weight: 600;
  animation: unspent-pulse 1.4s ease-in-out infinite;
}
@keyframes unspent-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 100, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(255, 215, 100, 0.18); }
}

.alloc-btn {
  width: 24px;
  height: 22px;
  padding: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #ffe66d, #ff9800);
  color: #1a1a1a;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.1s;
  justify-self: end;
}
.alloc-btn:hover { transform: scale(1.1); }
.alloc-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  transform: none;
}
/* When hidden, still occupy the grid cell so widths don't reflow */
.alloc-btn[hidden] { visibility: hidden; display: block; }

/* The parent #ui has pointer-events: none so clicks pass through to the 3D
   scene; we have to re-enable it explicitly for the alloc buttons (and the
   stats panel surrounding them) so clicks reach the buttons. */
#stats { pointer-events: auto; }
.alloc-btn { pointer-events: auto; }

/* ---------- Level-up toast ---------- */
#levelup-toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  z-index: 50;
  padding: 22px 36px;
  background: linear-gradient(135deg, rgba(255, 215, 100, 0.95), rgba(255, 152, 0, 0.95));
  color: #1a1a1a;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(255, 152, 0, 0.5), 0 0 0 4px rgba(255, 215, 100, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#levelup-toast.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
#levelup-toast .lu-burst {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
  animation: lu-spin 1.6s ease-out;
}
@keyframes lu-spin {
  from { transform: rotate(-30deg) scale(0.5); }
  to   { transform: rotate(0deg) scale(1); }
}
#levelup-toast .lu-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 4px;
}
#levelup-toast .lu-sub {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}

/* Leaderboard level prefix */
#leaderboard li .lvl {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  background: linear-gradient(135deg, #ffe66d, #ff9800);
  color: #1a1a1a;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
}

/* Sound toggle button */
#sound-btn {
  pointer-events: auto;
  font-size: 14px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
#sound-btn:hover { background: rgba(0, 0, 0, 0.75); border-color: rgba(255, 255, 255, 0.4); }
#sound-btn.muted { opacity: 0.55; }

/* ---------- Emote bubble above player ---------- */
.emote-bubble {
  position: fixed;
  pointer-events: none;
  font-size: 32px;
  line-height: 1;
  transform: translate(-50%, -50%) scale(1);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 4;
  user-select: none;
}

/* ---------- Mobile touch controls ---------- */
#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: none;            /* shown only when touch device detected */
  /* On touch devices we want to capture touches across the screen so the
     dynamic joystick can spawn anywhere on the left half. The action buttons
     and emote popout re-enable themselves with auto. */
  pointer-events: none;
}
#touch-controls.active { display: block; pointer-events: auto; }

/* Left-side joystick (positioned dynamically by JS on touch) */
#joystick {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 60px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;     /* no direct interaction — joystick is purely visual */
  touch-action: none;
  display: none;
}
#joystick-knob {
  position: absolute;
  left: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 25px;
  background: rgba(255, 230, 109, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.6);
  transition: none;
  pointer-events: none;
}

/* Right-side action buttons */
#touch-actions {
  position: absolute;
  right: 24px;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}
.touch-btn {
  width: 70px;
  height: 70px;
  border-radius: 35px;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  font-family: inherit;
  touch-action: manipulation;
}
.touch-btn.mine    { background: rgba(255, 110, 65, 0.85); border-color: rgba(255, 255, 255, 0.55); font-size: 22px; }
.touch-btn.auto    { background: rgba(0, 0, 0, 0.55); }
.touch-btn.emote   { background: rgba(102, 224, 255, 0.55); font-size: 18px; }
.touch-btn:active  { transform: scale(0.92); }

/* Emote popout when emote button is tapped */
#emote-popout {
  position: absolute;
  right: 110px;
  bottom: 30px;
  display: none;
  flex-direction: row;
  gap: 8px;
  pointer-events: auto;
}
#emote-popout.open { display: flex; }
#emote-popout .touch-btn {
  width: 56px;
  height: 56px;
  border-radius: 28px;
  font-size: 24px;
}

/* Hide auto-mine + sound buttons on mobile (replaced by touch buttons) */
@media (pointer: coarse), (max-width: 760px) {
  #hint { display: none; }
}

/* ---------- Event log (right side, below leaderboard) ---------- */
#event-log {
  position: absolute;
  right: 12px;
  /* Compute top from leaderboard height: roughly leaderboard top + max-height + gap.
     Using calc keeps it spaced even when leaderboard isn't at full height. */
  top: calc(42px + 38vh + 10px);
  min-width: 180px;
  max-width: 220px;
  max-height: 25vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 10px;
  pointer-events: auto;
}
#event-log h3 {
  font-size: 9px;
  margin-bottom: 4px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
#event-list { list-style: none; }
#event-list li {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  line-height: 1.35;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
#event-list li:last-child { border-bottom: none; }
#event-list li.fresh { animation: ev-flash 1.4s ease-out; }
#event-list .ev-time { color: rgba(255, 255, 255, 0.4); font-size: 9px; flex-shrink: 0; min-width: 28px; }
#event-list .ev-text { flex: 1; word-wrap: break-word; }
#event-list .ev-rare      { color: #ffe66d; }
#event-list .ev-rare-claim { color: #ffe66d; opacity: 0.8; }
#event-list .ev-levelup   { color: #b9f6ca; }
#event-list .ev-mint      { color: #66e0ff; }
#event-list .ev-join      { color: rgba(255,255,255,0.7); }
#event-list .ev-leave     { color: rgba(255,255,255,0.45); }
#event-list .ev-mine      { color: rgba(255,255,255,0.85); }
#event-list .ev-mine-bot  { color: rgba(255,255,255,0.45); font-style: italic; }
@keyframes ev-flash {
  0%   { background: rgba(255, 230, 109, 0.25); }
  100% { background: transparent; }
}

/* On narrow screens, hide event log to keep mobile clean */
@media (max-width: 760px) {
  #event-log { display: none; }
}

/* ---------- Tutorial coachmark overlay ---------- */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: auto;
  display: none;
}
#tutorial-overlay.active { display: block; }
#tutorial-mask {
  position: absolute;
  inset: 0;
  /* The 'hole' is positioned via inline style at runtime via box-shadow trick */
  background: transparent;
  pointer-events: auto;
}
.tutorial-spotlight {
  position: absolute;
  border-radius: 12px;
  /* Big shadow OUTSIDE the box = darken everything except the hole */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 230, 109, 0.7);
  transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  animation: tut-pulse 1.6s ease-in-out infinite;
}
@keyframes tut-pulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.70), 0 0 0 0 rgba(255, 230, 109, 0.4); }
  50%      { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.70), 0 0 0 12px rgba(255, 230, 109, 0); }
}
.tutorial-tooltip {
  position: absolute;
  max-width: 320px;
  background: linear-gradient(135deg, #ffe66d, #ff9800);
  color: #1a1a1a;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  z-index: 101;
  transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.tutorial-tooltip h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.65;
  margin-bottom: 6px;
  font-weight: 700;
}
.tutorial-tooltip .tut-body { font-weight: 600; }
.tutorial-tooltip .tut-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.tutorial-tooltip .tut-step {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.6;
}
.tutorial-tooltip .tut-btn {
  background: #1a1a1a;
  color: #ffe66d;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.tutorial-tooltip .tut-btn.skip {
  background: transparent;
  color: rgba(0, 0, 0, 0.6);
  font-weight: 500;
}
.tutorial-tooltip .tut-btn:hover { transform: translateY(-1px); }

/* ---------- Event banner (top center) ---------- */
#event-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(255, 230, 109, 0.95), rgba(255, 152, 0, 0.95));
  color: #1a1a1a;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 18px rgba(255, 152, 0, 0.35);
  z-index: 8;
  display: none;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  max-width: 90vw;
}
#event-banner.show { display: inline-flex; animation: eb-slide-in 0.4s ease-out; }
@keyframes eb-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#event-banner a { color: #1a1a1a; text-decoration: underline; }
#event-banner .eb-close {
  background: rgba(0, 0, 0, 0.15);
  border: none;
  color: #1a1a1a;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
}
#event-banner .eb-close:hover { background: rgba(0, 0, 0, 0.3); }

/* ---------- Mobile responsive polish ---------- */
@media (max-width: 760px) {
  /* Login modal: full-width, larger touch targets */
  #login .login-card {
    max-width: 92vw !important;
    padding: 18px !important;
  }
  #login input[type="text"] {
    font-size: 16px !important;       /* prevents iOS auto-zoom */
    padding: 12px 14px !important;
    min-height: 44px;
  }
  #login button {
    min-height: 48px;
    font-size: 14px;
  }
  /* Bigger touch buttons */
  .touch-btn {
    width: 78px;
    height: 78px;
    font-size: 14px;
  }
  .touch-btn.mine    { font-size: 26px; }
  .touch-btn.emote   { font-size: 22px; }
  /* Hide chat input by default (chat icon could re-open it later) */
  #chat { width: 65vw; max-width: 280px; }
  /* Hide event log entirely on phones (already done) and shrink leaderboard */
  #leaderboard { max-width: 160px; font-size: 10px; padding: 6px 8px; }
  #leaderboard h3 { font-size: 9px; }
  #leaderboard li { font-size: 10px; }
  /* Banner shrinks */
  #event-banner { font-size: 10px; padding: 5px 10px; max-width: 86vw; }
}
