/* ================= VoxelCraft Lite — Dark Mode UI ================= */
:root {
  /* dark palette */
  --bg-0: #0c0d11;          /* deepest */
  --bg-1: #14161c;          /* panel bg */
  --bg-2: #1c1f27;          /* raised */
  --bg-3: #262a34;          /* slot / input */
  --line: #2e333f;          /* hairline borders */
  --line-soft: #3a4150;
  --txt: #e7e9ee;           /* primary text */
  --txt-dim: #99a0ad;       /* secondary text */
  --txt-faint: #6b7280;
  --accent: #4f8cff;        /* electric blue */
  --accent-hover: #6ea0ff;
  --accent-deep: #2f6bdc;
  --good: #46c46b;
  --bad: #ff5b6e;
  --gold: #ffcf4d;
  --font-pixel: 'Silkscreen', monospace;   /* logos / pixel headings */
  --font-body: 'Figtree', system-ui, sans-serif;  /* everything else */
}
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-0); color: var(--txt);
  font-family: var(--font-body); font-weight: 500;
  color-scheme: dark;
}

.hidden { display: none !important; }
.hidden-input { display: none; }
.screen { position: absolute; inset: 0; }
.link-btn {
  background: none; border: none; color: var(--accent); font-family: var(--font-body);
  font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline;
}
.link-btn:hover { color: var(--accent-hover); }

/* ---------------- Buttons ---------------- */
.mc-btn {
  display: block; width: 100%; padding: 12px 22px;
  font-family: var(--font-body); font-weight: 600; font-size: 15px; letter-spacing: .2px;
  color: var(--txt); background: var(--bg-3);
  border: 1px solid var(--line-soft); border-radius: 10px;
  cursor: pointer; transition: background .14s, transform .05s, border-color .14s;
}
.mc-btn:hover:not(:disabled) { background: #313643; border-color: #49515f; }
.mc-btn:active:not(:disabled) { transform: translateY(1px); }
.mc-btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff; border-color: transparent; font-weight: 700;
  box-shadow: 0 4px 14px #2f6bdc44;
}
.mc-btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--accent-hover), var(--accent)); }
.mc-btn-disabled, .mc-btn:disabled { opacity: .4; cursor: not-allowed; }
.mc-btn.small { padding: 8px 14px; font-size: 13px; width: auto; display: inline-block; }
.toggle-group { display: flex; gap: 8px; }
.toggle-btn { width: auto; flex: 1; background: var(--bg-2); opacity: .8; }
.toggle-btn.active { opacity: 1; border-color: var(--accent); background: #1f2a40; color: #fff; }

.badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 6px;
  font-size: 11px; font-weight: 700; color: #fff; background: var(--bad);
  border-radius: 9px; vertical-align: middle;
}

/* ---------------- Logo ---------------- */
.logo-wrap { text-align: center; position: relative; }
.game-logo {
  font-family: var(--font-pixel); font-weight: 700; font-size: clamp(38px, 7vw, 78px);
  color: #fff; letter-spacing: 3px;
  text-shadow: 0 0 24px #4f8cff55, 3px 4px 0 #0a0c14;
}
.logo-sub {
  font-family: var(--font-pixel); font-size: clamp(15px, 2.2vw, 24px); color: var(--accent);
  letter-spacing: 12px; text-shadow: 0 0 16px #4f8cff66;
}
.splash-text {
  position: absolute; right: -54px; bottom: 2px;
  font-family: var(--font-pixel); font-size: 13px; color: var(--gold);
  text-shadow: 0 0 10px #ffcf4d55; transform: rotate(-11deg);
  animation: splashPulse 1.5s ease-in-out infinite;
}
@keyframes splashPulse { 0%,100% { transform: rotate(-11deg) scale(1);} 50% { transform: rotate(-11deg) scale(1.1);} }
@keyframes menuFade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------- Main menu ---------------- */
#menu-screen { overflow: hidden; }
#panorama-canvas { position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(2px) brightness(.5) saturate(.85); }
#menu-screen::after { content: ""; position: absolute; inset: 0; background:
  radial-gradient(120% 90% at 30% 40%, #0c0d1100 0%, #0c0d11cc 78%); z-index: 1; }
.menu-overlay {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 34px;
  padding-left: 9vw;
  animation: menuFade .6s ease both;
}
.menu-buttons { width: min(360px, 80vw); display: flex; flex-direction: column; gap: 10px; }
.menu-buttons .mc-btn { animation: menuFade .5s ease both; text-align: left; }
.menu-buttons .mc-btn:nth-child(1) { animation-delay: .06s; }
.menu-buttons .mc-btn:nth-child(2) { animation-delay: .12s; }
.menu-buttons .mc-btn:nth-child(3) { animation-delay: .18s; }
.menu-buttons .mc-btn:nth-child(4) { animation-delay: .24s; }
.menu-footer {
  position: absolute; bottom: 12px; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px; padding: 0 18px;
  font-size: 11px; color: var(--txt-faint); z-index: 3;
}
.menu-footer #menu-user { color: var(--txt-dim); font-weight: 600; }
.menu-footer span:last-child { margin-left: auto; }

/* Character preview — moved to upper-right-center (raised) */
.player-preview-panel {
  position: absolute; right: 6vw; top: 42%; transform: translateY(-50%); z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  animation: menuFade .7s .3s ease both;
}
#preview-canvas { width: 240px; height: 315px; }
.preview-caption { display: flex; flex-direction: column; align-items: center; font-size: 15px; font-weight: 700; }
.preview-cape { color: var(--gold); font-size: 11px; font-weight: 600; }

/* ---------------- Panels ---------------- */
.panel-bg { position: absolute; inset: 0; background:
  radial-gradient(120% 100% at 50% 0%, #1a1d27 0%, var(--bg-0) 70%); }
.mc-panel {
  position: relative; z-index: 2; width: min(520px, 92vw);
  margin: 7vh auto 0; padding: 26px 30px 30px;
  background: var(--bg-1);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 20px 60px #0009, inset 0 1px 0 #ffffff0a;
  display: flex; flex-direction: column; gap: 16px;
  animation: menuFade .3s ease both;
}
.wide-panel { width: min(720px, 94vw); max-height: 88vh; overflow-y: auto; }
.panel-title { font-family: var(--font-pixel); color: #fff; font-size: 22px; text-align: center; letter-spacing: 1px; }
.sub-head { font-size: 13px; font-weight: 700; color: var(--txt-dim); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.form-row label { display: block; font-size: 13px; font-weight: 600; color: var(--txt-dim); margin-bottom: 7px; }
.hint-inline { color: var(--txt-faint); font-weight: 500; }
.mc-input {
  width: 100%; padding: 11px 13px; font-family: var(--font-body); font-size: 15px; font-weight: 500;
  background: var(--bg-3); color: var(--txt); border: 1px solid var(--line-soft); border-radius: 9px;
  outline: none; transition: border-color .14s, box-shadow .14s;
}
.mc-input::placeholder { color: var(--txt-faint); }
.mc-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #4f8cff33; }
.mc-input:disabled { opacity: .6; cursor: not-allowed; }
.hint { font-size: 13px; color: var(--txt-dim); margin-top: 6px; line-height: 1.5; }
.panel-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 22px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.auth-msg { font-size: 13px; min-height: 18px; color: var(--bad); font-weight: 600; }
.auth-msg.ok { color: var(--good); }

/* ---------------- Auth screen ---------------- */
#auth-bg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(3px) brightness(.45) saturate(.8); }
#auth-screen::after { content: ""; position: absolute; inset: 0; background:
  radial-gradient(100% 80% at 50% 30%, #0c0d1100, #0c0d11ee); z-index: 1; }
.auth-wrap {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  animation: menuFade .5s ease both;
}
.auth-logo { transform: scale(.92); }
.auth-panel { margin: 0; width: min(420px, 92vw); }
.auth-tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 11px; }
.auth-tab {
  flex: 1; padding: 10px; border: none; border-radius: 8px; cursor: pointer;
  font-family: var(--font-body); font-weight: 700; font-size: 14px; color: var(--txt-dim); background: transparent;
}
.auth-tab.active { background: var(--bg-3); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { margin-top: 4px; }
.auth-offline { text-align: center; color: var(--gold); }

/* ---------------- Play tabs / lists ---------------- */
.play-tabs { display: flex; gap: 6px; flex-wrap: wrap; background: var(--bg-2); padding: 5px; border-radius: 11px; }
.play-tab {
  flex: 1; min-width: 110px; padding: 9px; border: none; border-radius: 8px; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: 13px; color: var(--txt-dim); background: transparent;
}
.play-tab.active { background: var(--bg-3); color: #fff; }
.play-pane { display: flex; flex-direction: column; gap: 16px; }
.list-scroll { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px;
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 700; font-size: 15px; }
.list-item .li-sub { font-size: 12px; color: var(--txt-dim); margin-top: 2px; }
.list-item .li-actions { display: flex; gap: 6px; }
.li-actions .mc-btn { padding: 7px 12px; font-size: 12px; }
.mono { font-family: var(--font-pixel); font-size: 11px; color: var(--accent); }

/* ---------------- Friends ---------------- */
.add-friend-row { display: flex; gap: 8px; align-items: stretch; }
.add-friend-row .mc-input { flex: 1; }
.add-friend-row .mc-btn { white-space: nowrap; }
.friends-section { display: flex; flex-direction: column; }
.friends-section + .friends-section { margin-top: 6px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 40; background: #0008; display: flex; align-items: center; justify-content: center; }
.modal .mc-panel { margin: 0; width: min(440px, 92vw); }

/* ---------------- HUD ---------------- */
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-pixel); font-size: 22px; color: #fff; mix-blend-mode: difference;
}
#hotbar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0; background: #0a0c11cc; padding: 4px; border: 1px solid #00000088; border-radius: 10px;
}
.hotbar-slot { width: 52px; height: 52px; position: relative; background: #ffffff10; border: 1px solid #ffffff14; margin: 1px; border-radius: 6px; }
.hotbar-slot.selected { border: 2px solid #fff; box-shadow: 0 0 0 2px #0008; }
.slot-canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.slot-count { position: absolute; right: 3px; bottom: 1px; font-family: var(--font-pixel); font-size: 13px; color: #fff; text-shadow: 2px 2px 0 #000; }
#status-bars { position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%); width: 460px; display: flex; justify-content: space-between; }
.bar-row { display: flex; gap: 1px; }
.bar-icon { width: 18px; height: 18px; image-rendering: pixelated; }
#debug-info {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-pixel); font-size: 11px; color: #fff;
  background: #0a0c11cc; padding: 8px 10px; line-height: 1.7; white-space: pre; border-radius: 8px;
}
#action-toast {
  position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-body); font-weight: 700; font-size: 14px; color: var(--gold);
  text-shadow: 0 2px 6px #000; opacity: 0; transition: opacity .4s;
}
#action-toast.show { opacity: 1; }

/* Chat */
#chat-box { position: absolute; left: 10px; bottom: 60px; width: min(480px, 60vw); pointer-events: none; }
#chat-messages { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; max-height: 40vh; overflow: hidden; }
.chat-msg {
  font-family: var(--font-body); font-size: 14px; color: #fff;
  background: #0a0c11aa; padding: 4px 9px; border-radius: 7px; width: fit-content;
  opacity: 0; transition: opacity .6s;
}
.chat-msg b { color: var(--accent-hover); font-weight: 700; }
.chat-msg.system { color: var(--gold); font-style: italic; }
.chat-msg.fresh { opacity: 1; }
#chat-box.open .chat-msg { opacity: 1; }
#chat-box.open #chat-messages { overflow-y: auto; pointer-events: auto; }
#chat-input { pointer-events: auto; }

#player-list {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  background: #0a0c11dd; border: 1px solid var(--line); border-radius: 10px; padding: 12px 26px;
  font-size: 14px; color: #fff; text-align: center; line-height: 1.9;
}
#player-list h4 { color: var(--accent-hover); margin-bottom: 6px; font-family: var(--font-pixel); font-size: 12px; }

/* ---------------- Profile ---------------- */
.profile-layout { position: relative; z-index: 2; display: flex; gap: 30px; justify-content: center; align-items: flex-start; padding-top: 5vh; }
.profile-panel { margin: 0; max-height: 86vh; overflow-y: auto; }
.profile-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 20px; }
#profile-preview-canvas { width: 280px; height: 373px; }
.cape-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cape-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
}
.cape-cell:hover { background: var(--bg-3); }
.cape-cell canvas { width: 40px; height: 64px; image-rendering: pixelated; background: #00000033; border-radius: 3px; }
.cape-cell span { font-size: 11px; font-weight: 600; }
.cape-cell.active { border-color: var(--accent); box-shadow: 0 0 0 2px #4f8cff44; }

/* ---------------- Inventory ---------------- */
#inventory-screen { position: absolute; inset: 0; z-index: 10; background: #0008; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.inv-panel {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 60px #000a; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px;
}
.inv-panel h3 { font-family: var(--font-pixel); font-size: 13px; color: var(--txt-dim); }
.inv-grid { display: grid; grid-template-columns: repeat(9, 46px); gap: 4px; }
.inv-slot { width: 46px; height: 46px; position: relative; background: var(--bg-3); border: 1px solid var(--line-soft); border-radius: 6px; cursor: pointer; }
.inv-slot:hover { background: #313643; }
#creative-palette { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
#drag-ghost { position: fixed; width: 44px; height: 44px; pointer-events: none; z-index: 20; }
#drag-ghost canvas { width: 100%; height: 100%; image-rendering: pixelated; }
#drag-ghost .slot-count { font-size: 12px; }
#item-tooltip {
  position: fixed; z-index: 21; pointer-events: none;
  background: var(--bg-0); border: 1px solid var(--accent); border-radius: 7px;
  color: #fff; font-size: 13px; font-weight: 600; padding: 6px 10px;
}

/* ---------------- Pause / death ---------------- */
#pause-screen { position: absolute; inset: 0; z-index: 12; background: #0009; backdrop-filter: blur(3px); }
.pause-panel { width: min(380px, 90vw); margin-top: 16vh; gap: 10px; }
#death-screen { position: absolute; inset: 0; z-index: 13; background: radial-gradient(circle, #4a0008cc, #1a0003ee); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
#death-screen h1 { font-family: var(--font-pixel); font-size: 48px; color: #fff; text-shadow: 0 0 24px #ff5b6e66; }
#death-screen p { color: #ffd6da; font-size: 15px; font-weight: 600; }
#death-screen .mc-btn { width: 300px; }
#game-canvas.hurt-flash { filter: saturate(1.4) sepia(.4) hue-rotate(-40deg) brightness(.92); }

/* ---------------- Loading ---------------- */
#loading-overlay { position: fixed; inset: 0; z-index: 30; background: var(--bg-0); display: flex; align-items: center; justify-content: center; }
.loading-inner { text-align: center; }
.loading-block {
  width: 46px; height: 46px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent) 50%, var(--accent-deep) 50%);
  border-radius: 8px; animation: spinBlock 1.1s linear infinite;
}
@keyframes spinBlock { to { transform: rotate(360deg); } }
#loading-text { font-family: var(--font-body); font-weight: 600; color: var(--txt); font-size: 15px; }

@media (max-width: 900px) {
  .player-preview-panel { display: none; }
  .menu-overlay { align-items: center; padding-left: 0; }
  .menu-buttons .mc-btn { text-align: center; }
  #status-bars { width: 90vw; }
  .profile-layout { flex-direction: column; align-items: center; }
  .form-grid { grid-template-columns: 1fr; }
}
