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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #1a2838;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: #e8f0f8;
  touch-action: none;
}

#stage { position: fixed; inset: 0; }

#game {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 20, 32, 0.72);
  backdrop-filter: blur(6px);
  padding: 16px;
}

.panel {
  background: linear-gradient(145deg, #243448, #1a2838);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
}

.logo { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.04em; }
.logo.sm { font-size: 1.25rem; }
.sub { opacity: 0.7; font-size: 0.9rem; margin-top: 4px; }
.intro { margin: 16px 0; line-height: 1.55; font-size: 0.92rem; opacity: 0.85; }

.menu-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn {
  border: none; border-radius: 10px; padding: 10px 18px;
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.btn.primary { background: #3cb878; color: #0a1810; }
.btn.primary:hover { background: #4fd08a; }
.btn.ghost { background: rgba(255,255,255,0.08); color: #e8f0f8; border: 1px solid rgba(255,255,255,0.15); }
.btn.ghost:hover { background: rgba(255,255,255,0.14); }

.help-body p { margin: 10px 0; line-height: 1.5; font-size: 0.9rem; }

#topbar {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  pointer-events: none; z-index: 10;
}
#topbar span {
  background: rgba(10,20,32,0.65);
  padding: 6px 12px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600;
  border: 1px solid rgba(255,255,255,0.1);
}
.hud-btn { pointer-events: auto; padding: 6px 12px; font-size: 0.8rem; }

#tip {
  position: absolute; bottom: 88px; left: 50%; transform: translateX(-50%);
  background: rgba(10,20,32,0.75); padding: 8px 16px; border-radius: 8px;
  font-size: 0.85rem; pointer-events: none; z-index: 10;
  border: 1px solid rgba(255,255,255,0.12);
  max-width: 90vw; text-align: center;
}

#hotbar {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 10;
  background: rgba(10,20,32,0.7);
  padding: 8px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
}
.slot {
  width: 44px; height: 44px;
  background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.slot.filled { border-color: #3cb878; background: rgba(60,184,120,0.15); }
.slot.active { border-color: #ffe066; box-shadow: 0 0 8px rgba(255,224,102,0.5); background: rgba(255,224,102,0.12); }

#touch-ui {
  position: absolute; bottom: 80px; right: 16px; z-index: 15;
}
#btn-interact {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(60,184,120,0.85); border: 2px solid rgba(255,255,255,0.3);
  color: #0a1810; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}

.overlay[hidden] { display: none !important; pointer-events: none !important; }
.submit-row input {
  flex: 1; padding: 10px 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.3); color: #e8f0f8;
}
.board { margin: 12px 0; max-height: 180px; overflow-y: auto; font-size: 0.82rem; }
.board-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.board-rank { opacity: 0.6; width: 28px; }
.board-name { font-weight: 600; }
.board-meta { opacity: 0.55; font-size: 0.75rem; }
.board-score { margin-left: auto; font-weight: 700; color: #3cb878; }
.board-empty { opacity: 0.6; font-size: 0.85rem; padding: 8px 0; }

#submit-status { font-size: 0.85rem; opacity: 0.8; min-height: 1.2em; }
.submit-row { display: flex; gap: 8px; margin: 12px 0; }

#quest-bar {
  position: absolute; top: 52px; left: 12px; right: 12px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  pointer-events: none; z-index: 10;
}
.ms {
  background: rgba(10,20,32,0.6); padding: 4px 10px; border-radius: 6px;
  font-size: 0.75rem; border: 1px solid rgba(255,255,255,0.12); opacity: 0.7;
}
.ms.done { opacity: 1; border-color: #3cb878; color: #a8f0c0; }
.ver { margin-left: auto; opacity: 0.45; font-size: 0.7rem; background: none; border: none; }
.save-tag { font-size: 0.72rem !important; opacity: 0.75; }

#minimap-wrap {
  position: absolute; top: 52px; right: 12px; z-index: 11;
  pointer-events: none;
}
#minimap {
  display: block; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.map-legend {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
  margin-top: 4px; font-size: 0.62rem; opacity: 0.75;
  background: rgba(10,20,32,0.65); padding: 3px 6px; border-radius: 6px;
}

#craft-bar {
  position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 12; flex-wrap: wrap; justify-content: center;
  max-width: 96vw;
}
#craft-bar button {
  padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(20,40,30,0.85); color: #e8f0f8; font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
}
#craft-bar button:active { background: rgba(60,184,120,0.35); }

#touch-move {
  position: absolute; bottom: 88px; left: 16px; z-index: 15;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
#touch-move button {
  width: 52px; height: 52px; border-radius: 12px;
  background: rgba(10,20,32,0.65); border: 1px solid rgba(255,255,255,0.2);
  color: #e8f0f8; font-size: 1.1rem; cursor: pointer;
}
#touch-move .touch-row { display: flex; gap: 4px; }

#float-ui { position: absolute; inset: 0; pointer-events: none; z-index: 11; overflow: hidden; }
.pop {
  position: absolute; font-weight: 800; font-size: 0.9rem; color: #ffe066;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  animation: popUp 0.9s ease-out forwards;
}
@keyframes popUp {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-28px); }
}

@media (max-width: 600px) {
  .panel { padding: 20px; }
  #tip { bottom: 148px; font-size: 0.8rem; max-width: 88vw; }
  #hotbar { bottom: 12px; }
  #craft-bar { bottom: 68px; }
  #topbar span { font-size: 0.75rem; padding: 5px 8px; }
  #minimap-wrap { top: 48px; right: 8px; }
  #minimap { width: 96px; height: 96px; }
  .map-legend { font-size: 0.58rem; }
  #btn-interact { width: 64px; height: 64px; }
}
