@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
  --mc-dark: #1a1a1a;
  --mc-panel: #2b2b2b;
  --mc-border: #555;
  --mc-btn: #5a5a5a;
  --mc-btn-hover: #6e6e6e;
  --mc-green: #4a7c35;
  --mc-green-hover: #5a9c40;
  --mc-red: #8b2020;
  --mc-red-hover: #a83030;
  --mc-text: #ffffffcc;
  --mc-gold: #ffaa00;
  --mc-sky: #4a9eda;
}

html, body {
  width: 100%; height: 100%;
  background: #000;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--mc-text);
  overflow: hidden;
  user-select: none;
}

/* ── SCREENS ─────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.screen.active { opacity: 1; pointer-events: all; }

/* ── SPLASH ───────────────────────────────────────────────── */
#screen-splash {
  background: radial-gradient(ellipse at center, #1a3a5c 0%, #000 100%);
  flex-direction: column; gap: 20px;
}
.splash-logo {
  font-size: 48px; color: var(--mc-gold);
  text-shadow: 4px 4px 0 #7a4f00, 8px 8px 0 #3a2500;
  letter-spacing: 4px;
}
.splash-sub { font-size: 10px; color: #aaa; }

/* ── LOADING BAR ──────────────────────────────────────────── */
.loading-bar-wrap {
  width: 300px; height: 16px;
  border: 2px solid #555;
  background: #111;
}
.loading-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #4a7c35, #83c44a);
  transition: width 0.1s;
}

/* ── PANELS ───────────────────────────────────────────────── */
.mc-panel {
  background: var(--mc-panel);
  border: 2px solid var(--mc-border);
  padding: 28px 32px;
  display: flex; flex-direction: column; gap: 14px;
  min-width: 320px;
  box-shadow: 6px 6px 0 #111;
}
.panel-title {
  font-size: 14px; color: #fff;
  text-shadow: 2px 2px 0 #000;
  text-align: center; margin-bottom: 8px;
}

/* ── INPUTS ───────────────────────────────────────────────── */
.mc-input {
  width: 100%; padding: 10px 12px;
  background: #111; border: 2px solid #444;
  color: #fff; font-family: inherit; font-size: 10px;
  outline: none;
}
.mc-input:focus { border-color: var(--mc-gold); }
.mc-select {
  width: 100%; padding: 8px 10px;
  background: #111; border: 2px solid #444;
  color: #fff; font-family: inherit; font-size: 9px;
  outline: none; cursor: pointer;
}
.mc-error { color: #ff6b6b; font-size: 8px; min-height: 14px; text-align: center; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.mc-btn {
  padding: 12px 18px;
  background: var(--mc-btn);
  border: none; border-bottom: 3px solid #333; border-right: 3px solid #333;
  color: #fff; font-family: inherit; font-size: 10px;
  cursor: pointer; text-align: center;
  transition: filter 0.1s;
}
.mc-btn:hover { filter: brightness(1.25); }
.mc-btn:active { border-bottom-width: 1px; border-right-width: 1px; }
.mc-btn.green { background: var(--mc-green); }
.mc-btn.green:hover { background: var(--mc-green-hover); }
.mc-btn.red { background: var(--mc-red); }
.mc-btn.red:hover { background: var(--mc-red-hover); }
.mc-btn.small { font-size: 8px; padding: 8px 12px; }

/* ── SIGN IN ──────────────────────────────────────────────── */
#screen-signin, #screen-register {
  background: radial-gradient(ellipse at 50% 30%, #0d2a4a 0%, #000 100%);
}
.signin-panel { width: 360px; }

/* ── MAIN MENU ────────────────────────────────────────────── */
#screen-main {
  background: #000;
  flex-direction: row;
  align-items: stretch;
}
.main-bg {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, #1a3a5c 0%, #0a1a2a 50%, #1a2a1a 100%);
  z-index: 0;
}
.main-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='40' height='40' fill='none' stroke='%23ffffff08' stroke-width='1'/%3E%3C/svg%3E");
}

/* sidebar */
.sidebar {
  position: relative; z-index: 1;
  width: 180px; min-width: 180px;
  background: rgba(0,0,0,0.7);
  border-right: 2px solid #333;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  padding: 20px 10px;
}
.sidebar-avatar-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin-bottom: 12px;
}
.sidebar-username {
  font-size: 8px; color: var(--mc-gold);
  word-break: break-all; text-align: center;
}
.sidebar-btn {
  width: 100%; padding: 10px 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid #444;
  color: #ccc; font-family: inherit; font-size: 8px;
  cursor: pointer; text-align: left;
  transition: background 0.15s;
}
.sidebar-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* main content */
.main-content {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 30px 20px 20px;
  gap: 20px; overflow-y: auto;
}
.main-logo {
  font-size: 52px; color: var(--mc-gold);
  text-shadow: 4px 4px 0 #7a4f00, 8px 8px 0 #3a2500;
  letter-spacing: 6px;
}
.main-tabs {
  display: flex; gap: 4px;
}
.main-tab {
  padding: 10px 20px;
  background: rgba(0,0,0,0.5);
  border: 2px solid #444; border-bottom: none;
  color: #888; font-family: inherit; font-size: 9px;
  cursor: pointer;
}
.main-tab.active { background: rgba(255,255,255,0.1); color: #fff; border-color: #666; }
.main-tab-content { display: none; width: 100%; max-width: 700px; }
.main-tab-content.active { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.big-play-btn { font-size: 16px; padding: 20px 60px; background: var(--mc-green); }
.big-play-btn:hover { background: var(--mc-green-hover); }
.hint-text { font-size: 8px; color: #666; }

/* marketplace */
.marketplace-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; width: 100%;
}
.mp-card {
  background: rgba(0,0,0,0.4); border: 2px solid #444;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.mp-card:hover { border-color: var(--mc-gold); }
.mp-thumb { height: 80px; }
.mp-name { font-size: 8px; color: #fff; }
.mp-price { font-size: 7px; color: #4aff4a; }

/* news */
.news-item {
  width: 100%; background: rgba(0,0,0,0.4); border: 2px solid #444;
  padding: 14px;
}
.news-date { font-size: 7px; color: #888; margin-bottom: 4px; }
.news-title { font-size: 10px; color: var(--mc-gold); margin-bottom: 6px; }
.news-body { font-size: 8px; color: #ccc; line-height: 1.6; font-family: sans-serif; }

/* ── DRESSING ROOM ────────────────────────────────────────── */
#screen-dressing {
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #000 100%);
  align-items: stretch;
}
.dressing-layout { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 0; }
.dressing-header {
  display: flex; align-items: center; gap: 20px;
  padding: 16px 20px;
  background: rgba(0,0,0,0.5); border-bottom: 2px solid #444;
}
.dressing-body {
  display: flex; flex: 1; gap: 0;
}
.dressing-preview {
  width: 260px; min-width: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 30px 20px;
  background: rgba(0,0,0,0.3); border-right: 2px solid #333;
}
.dressing-char-switch { display: flex; gap: 8px; }
.dressing-options {
  flex: 1; padding: 20px; overflow-y: auto;
}
.dressing-section-title { font-size: 10px; color: var(--mc-gold); margin-bottom: 12px; }
.outfit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.outfit-card {
  background: rgba(255,255,255,0.05); border: 2px solid #444;
  padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.outfit-card:hover, .outfit-card.selected { border-color: var(--mc-gold); }
.outfit-preview { width: 48px; height: 72px; image-rendering: pixelated; }
.outfit-name { font-size: 7px; color: #ccc; text-align: center; }

/* ── SOUND PICKER ─────────────────────────────────────────── */
#screen-sounds {
  background: radial-gradient(ellipse at center, #0a1a0a 0%, #000 100%);
  align-items: stretch;
}
.sounds-layout { width: 100%; max-width: 800px; display: flex; flex-direction: column; }
.sounds-header {
  display: flex; align-items: center; gap: 20px;
  padding: 16px 20px; background: rgba(0,0,0,0.5); border-bottom: 2px solid #444;
}
.sounds-body { padding: 20px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.sound-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.sound-card {
  background: rgba(255,255,255,0.05); border: 2px solid #444;
  padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer; transition: border-color 0.15s;
}
.sound-card:hover { border-color: #888; }
.sound-card.selected { border-color: var(--mc-gold); background: rgba(255,170,0,0.1); }
.sound-card.none-card { border-style: dashed; }
.sound-icon { font-size: 32px; }
.sound-card-name { font-size: 8px; color: #ccc; text-align: center; }
.sound-controls {
  background: rgba(0,0,0,0.4); border: 2px solid #444;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.sound-ctrl-title { font-size: 11px; color: var(--mc-gold); }
.sound-ctrl-row {
  display: flex; align-items: center; gap: 12px;
}
.sound-ctrl-row label { font-size: 8px; min-width: 100px; }
.sound-ctrl-row input[type=range] { flex: 1; }
.sound-ctrl-row span { font-size: 8px; min-width: 36px; }
.sound-ctrl-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.current-sound-display { font-size: 9px; color: #888; text-align: center; }
.current-sound-display span { color: var(--mc-gold); }

/* ── WORLD SELECT ─────────────────────────────────────────── */
#screen-worlds {
  background: radial-gradient(ellipse at center, #1a2a1a 0%, #000 100%);
  align-items: stretch;
}
.worlds-layout { width: 100%; max-width: 700px; display: flex; flex-direction: column; }
.worlds-header {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; background: rgba(0,0,0,0.5); border-bottom: 2px solid #444;
}
.worlds-header .panel-title { flex: 1; }
.worlds-list { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.world-item {
  display: flex; align-items: center; gap: 16px;
  background: rgba(255,255,255,0.05); border: 2px solid #444;
  padding: 14px; cursor: pointer; transition: border-color 0.15s;
}
.world-item:hover { border-color: #888; }
.world-icon { width: 56px; height: 56px; image-rendering: pixelated; }
.world-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.world-name { font-size: 11px; color: #fff; }
.world-meta { font-size: 7px; color: #888; }
.world-actions { display: flex; gap: 6px; }
.worlds-empty {
  display: none; flex: 1;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 40px;
}
.worlds-empty.visible { display: flex; }
.worlds-empty-icon { font-size: 64px; }
.worlds-empty-title { font-size: 14px; color: #fff; }
.worlds-empty-sub { font-size: 8px; color: #888; text-align: center; line-height: 1.8; font-family: sans-serif; }

/* ── WORLD CREATE ─────────────────────────────────────────── */
#screen-create {
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #000 100%);
  align-items: stretch;
}
.create-layout { width: 100%; max-width: 900px; display: flex; flex-direction: column; height: 100%; }
.create-header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; background: rgba(0,0,0,0.5); border-bottom: 2px solid #444;
}
.create-header .panel-title { flex: 1; }
.create-body { display: flex; flex: 1; overflow: hidden; }
.create-nav {
  width: 180px; min-width: 180px;
  background: rgba(0,0,0,0.4); border-right: 2px solid #333;
  display: flex; flex-direction: column; padding: 10px 0;
}
.create-nav-btn {
  padding: 12px 14px;
  background: none; border: none; border-left: 3px solid transparent;
  color: #888; font-family: inherit; font-size: 8px;
  cursor: pointer; text-align: left;
}
.create-nav-btn:hover { color: #ccc; background: rgba(255,255,255,0.05); }
.create-nav-btn.active { color: #fff; border-left-color: var(--mc-gold); background: rgba(255,255,255,0.08); }
.create-tabs { flex: 1; overflow-y: auto; padding: 20px; }
.create-tab { display: none; flex-direction: column; gap: 16px; }
.create-tab.active { display: flex; }

/* settings rows */
.setting-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid #333;
}
.setting-label { font-size: 9px; color: #ccc; min-width: 160px; }
.setting-val { font-size: 9px; color: var(--mc-gold); }
.setting-desc { font-size: 8px; color: #666; line-height: 1.6; font-family: sans-serif; }
.toggle-group { display: flex; gap: 2px; flex-wrap: wrap; }
.toggle-btn {
  padding: 8px 12px;
  background: #333; border: 1px solid #555;
  color: #888; font-family: inherit; font-size: 8px;
  cursor: pointer;
}
.toggle-btn.active { background: var(--mc-green); border-color: var(--mc-green-hover); color: #fff; }
.toggle-btn:hover:not(.active) { background: #444; color: #ccc; }
input[type=range] { accent-color: var(--mc-gold); }

/* packs */
.pack-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px; background: rgba(255,255,255,0.04); border: 1px solid #444;
  margin-bottom: 8px;
}
.pack-item.active-pack { border-color: var(--mc-green); }
.pack-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.pack-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.pack-name { font-size: 9px; color: #fff; }
.pack-desc { font-size: 7px; color: #888; font-family: sans-serif; }
.pack-badge { font-size: 7px; color: var(--mc-green); }

/* info boxes */
.info-box {
  padding: 12px; background: rgba(255,255,255,0.05);
  border-left: 3px solid #666;
  font-size: 8px; color: #999; line-height: 1.8; font-family: sans-serif;
}
.info-box.warning { border-left-color: #c6a227; }

/* ── LOADING SCREEN ───────────────────────────────────────── */
#screen-loading {
  background: #000; flex-direction: column; gap: 20px;
}
.loading-world-name { font-size: 14px; color: #fff; }
.loading-tip { font-size: 8px; color: #888; max-width: 400px; text-align: center; font-family: sans-serif; line-height: 1.6; }

/* ── GAME ─────────────────────────────────────────────────── */
#screen-game { background: #000; padding: 0; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; }
#hud-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 12px; gap: 12px;
}
#hud-coords, #hud-biome, #hud-time {
  font-size: 8px; color: #fff; text-shadow: 1px 1px 2px #000;
  background: rgba(0,0,0,0.4); padding: 4px 8px;
}
#hud-center { flex: 1; display: flex; align-items: center; justify-content: center; }
#crosshair { font-size: 24px; color: rgba(255,255,255,0.8); text-shadow: 0 0 4px #000; }
#hud-bottom { padding: 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* hotbar */
#hotbar { display: flex; gap: 4px; }
.hotbar-slot {
  width: 44px; height: 44px;
  background: rgba(0,0,0,0.6); border: 2px solid #666;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.hotbar-slot.active { border-color: #fff; background: rgba(255,255,255,0.1); }

/* health/hunger bars */
#hud-health-bar, #hud-hunger-bar {
  display: flex; gap: 3px;
}
.heart { font-size: 14px; }
.hunger-icon { font-size: 14px; }

/* pause */
#pause-menu {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.pause-panel { min-width: 280px; gap: 12px; }

/* ── TOUCH CONTROLS ───────────────────────────────────────── */
#touch-controls {
  position: absolute; inset: 0; pointer-events: none;
  display: none;
}
#touch-controls.visible { display: block; }

#joystick-zone {
  position: absolute; left: 20px; bottom: 80px;
  width: 130px; height: 130px;
  pointer-events: all;
}
#joystick-base {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
}
#joystick-stick {
  width: 50px; height: 50px; border-radius: 50%;
  background: rgba(255,255,255,0.4); border: 2px solid rgba(255,255,255,0.6);
  transition: transform 0.05s;
}

#touch-buttons {
  position: absolute; right: 16px; bottom: 20px;
  display: flex; flex-direction: column; gap: 8px;
  align-items: flex-end; pointer-events: all;
}
.touch-btn {
  width: 56px; height: 56px; border-radius: 8px;
  background: rgba(0,0,0,0.5); border: 2px solid rgba(255,255,255,0.3);
  color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.touch-btn:active { background: rgba(255,255,255,0.2); }

/* ── INVENTORY ────────────────────────────────────────────── */
#inventory-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.inv-panel { min-width: 400px; }
#inv-grid {
  display: grid; grid-template-columns: repeat(9, 40px);
  gap: 4px; margin: 8px 0;
}
.inv-slot {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.08); border: 2px solid #555;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; position: relative;
}
.inv-slot:hover { border-color: #fff; }
.inv-count {
  position: absolute; bottom: 2px; right: 3px;
  font-size: 7px; color: #fff; text-shadow: 1px 1px 1px #000;
}

/* ── RESPONSIVE / MOBILE ──────────────────────────────────── */
@media (max-width: 600px) {
  .main-logo { font-size: 32px; }
  .sidebar { width: 140px; min-width: 140px; }
  .marketplace-grid { grid-template-columns: repeat(2, 1fr); }
  .create-nav { width: 140px; min-width: 140px; }
  .create-nav-btn { font-size: 7px; padding: 10px 8px; }
  .setting-label { min-width: 120px; font-size: 8px; }
  .worlds-layout { max-width: 100%; }
  .create-layout { max-width: 100%; }
}
