/* DeepCore Mining — UI styles. Industrial dark theme with safety-amber accents. */
:root {
  --bg: #16120e; --bg2: rgba(26, 21, 16, .92); --card: #241d16; --line: #3b3027; --text: #f1ebe3; --mut: #a8998a;
  --amber: #f2b23a; --amber2: #ffcf5a; --green: #4cc38a; --red: #ef5b50; --blue: #59a8f5;
  --r: 12px; --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
[hidden] { display: none !important; }
svg { flex: none; }
a { color: var(--amber2); }

/* ---------- auth ---------- */
#auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow: auto; }
.auth-bg { position: fixed; inset: 0; background:
  radial-gradient(ellipse at 50% 120%, #6b3f14 0%, transparent 60%),
  repeating-linear-gradient(170deg, #2a2119 0 38px, #241c15 38px 76px, #2e241b 76px 110px), #1a140f; }
.auth-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.2), rgba(0,0,0,.65)); }
.auth-card { position: relative; width: min(400px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.5); backdrop-filter: blur(8px); }
.auth-card h1 { margin: 8px 0 2px; font-size: 30px; letter-spacing: .5px; text-transform: uppercase; font-weight: 900; }
.auth-card h1 span { color: var(--amber); }
.tag { color: var(--mut); margin: 0 0 18px; }
.auth-tabs { display: flex; background: #120e0a; border-radius: 10px; padding: 4px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 8px; color: var(--mut); font-weight: 600; }
.auth-tabs button.on { background: var(--card); color: var(--text); }
#authForm input { width: 100%; margin: 5px 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: #120e0a; }
#authForm input:focus { outline: 2px solid var(--amber); border-color: transparent; }
.err { color: var(--red); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.motd { color: var(--mut); font-size: 13px; margin: 14px 0 0; }

/* ---------- buttons ---------- */
.buy { border: 0; border-radius: 9px; padding: 8px 14px; background: linear-gradient(180deg, var(--amber2), var(--amber)); color: #2a1a05; font-weight: 800; white-space: nowrap; box-shadow: 0 2px 0 #a86f12; }
.buy:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.buy.wide { width: 100%; padding: 12px; margin-top: 8px; font-size: 16px; }
.btn2 { border: 1px solid var(--line); background: #2d241b; border-radius: 9px; padding: 8px 12px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
.btn2:hover:not(:disabled) { border-color: var(--amber); }
.btn2.danger { color: #ffb3ad; border-color: #5a2a25; }
.sm { padding: 5px 10px !important; font-size: 13px; }
.btn2 svg { width: 18px; height: 18px; }

/* ---------- game layout ---------- */
#game { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; touch-action: none; }
#scene canvas { display: block; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.plabel { position: absolute; left: 0; top: 0; padding: 2px 8px; background: rgba(0,0,0,.6); border-radius: 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.plabel.me { background: rgba(242,178,58,.85); color: #241605; }
.floater { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 16px; text-shadow: 0 2px 4px #000, 0 0 2px #000; white-space: nowrap; }

#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 10px; align-items: stretch; pointer-events: none; }
#hud > * { pointer-events: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(6px); }
.hud-co { display: flex; align-items: center; gap: 9px; padding: 7px 12px 7px 8px; min-width: 0; }
.hud-co b { display: block; font-size: 15px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-co small { color: var(--mut); font-size: 12px; }
.rolebadge { color: var(--blue); }
.hud-stats { display: flex; padding: 6px 4px; }
.hud-stats > div { padding: 0 12px; border-left: 1px solid var(--line); min-width: 84px; }
.hud-stats > div:first-child { border: 0; }
.hud-stats small { display: block; color: var(--mut); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.hud-stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
#hudCash { color: var(--amber2); }
.hud-store i { display: block; height: 4px; border-radius: 3px; background: #3a2f25; margin-top: 3px; overflow: hidden; }
.hud-store em { display: block; height: 100%; width: 0; background: var(--green); transition: width .4s; }
.hud-store em.full { background: var(--red); }
#hudWarn { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); background: #5a1f19; border: 1px solid var(--red); color: #ffd7d3; padding: 7px 14px; border-radius: 20px; font-weight: 700; font-size: 14px; animation: pulse 1.6s infinite; white-space: nowrap; z-index: 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(239,91,80,.15); } }

#nav { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, var(--safe-b)); display: flex; gap: 2px; padding: 5px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(6px); z-index: 5; }
#nav button { position: relative; border: 0; background: none; color: var(--mut); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 9px; border-radius: 11px; font-size: 11px; font-weight: 600; min-width: 58px; }
#nav button:hover { color: var(--text); background: #2a2119; }
#nav button.on { color: #241605; background: var(--amber); }
#nav .sh { display: none; }
#nav .dot { position: absolute; top: 4px; right: 12px; width: 9px; height: 9px; background: var(--red); border-radius: 50%; border: 2px solid var(--bg); }

#fab { position: absolute; right: 16px; bottom: calc(var(--nav-h) + 26px); display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 4; transition: right .25s; }
#mineBtn { width: 78px; height: 78px; border-radius: 50%; border: 3px solid #a86f12; background: radial-gradient(circle at 35% 30%, #ffe08a, var(--amber) 60%, #c78516); color: #2a1a05; font-weight: 900; box-shadow: 0 6px 18px rgba(0,0,0,.5), inset 0 -4px 0 rgba(0,0,0,.15); display: flex; flex-direction: column; align-items: center; justify-content: center; user-select: none; }
#mineBtn span { font-size: 30px; line-height: 1; }
#mineBtn small { font-size: 11px; letter-spacing: 1px; }
#mineBtn:active { transform: scale(.93); }
.fab-s { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg2); color: var(--text); display: grid; place-items: center; }

#panel { position: absolute; top: 78px; right: 10px; bottom: calc(var(--nav-h) + 22px); width: 410px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; z-index: 6; backdrop-filter: blur(8px); box-shadow: 0 20px 50px rgba(0,0,0,.4); animation: slidein .2s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } }
body.panel-open #fab { right: 436px; }
.panel-head { display: flex; align-items: center; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; flex: 1; font-size: 18px; }
.panel-head button, .chat-head > button { border: 0; background: #2d241b; width: 32px; height: 32px; border-radius: 8px; }
#panelBody { overflow-y: auto; padding: 12px 16px 20px; flex: 1; -webkit-overflow-scrolling: touch; }
#panelBody h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--amber); }
#panelBody h5 { margin: 12px 0 6px; color: var(--mut); font-size: 12px; text-transform: uppercase; }
.sub { color: var(--mut); margin: 0 0 10px; font-size: 14px; }
.note { color: var(--mut); font-size: 13px; display: block; margin: 6px 0; }
.hint { background: #2a2116; border-left: 3px solid var(--amber); padding: 8px 12px; border-radius: 6px; font-size: 14px; margin: 10px 0; }
.pos { color: var(--green); } .neg { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.stat span { display: block; font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat small { display: block; color: var(--mut); font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px; margin-bottom: 9px; }
.card.locked { opacity: .55; }
.row { display: flex; align-items: center; gap: 10px; }
.row.gap { gap: 8px; margin-top: 8px; flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.grow b { display: block; } .grow small { display: block; color: var(--mut); font-size: 13px; margin-top: 2px; }
.count { color: var(--amber2); font-weight: 800; margin-left: 4px; }
.ic { width: 46px; height: 46px; border-radius: 10px; background: #1a140f; display: grid; place-items: center; color: #d9cbb8; flex: none; }
.ic svg { width: 30px; height: 30px; }
.tags i { display: inline-block; font-style: normal; background: #1a140f; border-radius: 6px; padding: 1px 7px; margin: 4px 4px 0 0; font-size: 12px; }
.tags i.lock { background: #4a2a1a; color: #ffc6a8; }
.pips { display: flex; gap: 4px; margin-top: 6px; }
.pips i { width: 18px; height: 6px; border-radius: 3px; background: #3a2f25; }
.pips i.on { background: var(--amber); }
.maxed { color: var(--green); font-weight: 900; }
.mlist .mrow { display: grid; grid-template-columns: 12px 74px 1fr 48px 62px; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }
.mrow > i, .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.mrow em { font-style: normal; text-align: right; color: var(--mut); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 4px; background: #1a140f; overflow: hidden; } .bar b { display: block; height: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--mut); font-weight: 600; padding: 5px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px 4px; border-bottom: 1px solid #2c241c; vertical-align: middle; }
.tbl tr.me td { background: #2e2416; }
.tbl select { background: #1a140f; border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.online { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; margin-right: 6px; } .online.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ownbar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: #1a140f; } .ownbar b { display: block; height: 100%; }
.frm { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; align-items: center; }
.frm input:not([type=radio]):not([type=color]), .frm select { flex: 1; min-width: 90px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #1a140f; }
.frm label { display: flex; gap: 8px; align-items: center; flex: 1; }
.frm input[type=color] { width: 44px; height: 32px; border: 0; background: none; padding: 0; }
.offer { display: flex; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px; margin-bottom: 6px; font-size: 14px; }
.offer small { display: block; color: var(--mut); font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 5px 12px; font-size: 13px; } .chip.on { border-color: var(--amber); color: var(--amber2); } .chip small { color: var(--mut); }
.help ol { padding-left: 20px; } .help li { margin: 6px 0; }

/* exchange */
.mkts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.mkt { display: flex; justify-content: space-between; border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 8px; font-size: 12px; text-align: left; }
.mkt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .mkt em { font-style: normal; color: var(--mut); }
.mkt.on { border-color: var(--amber); background: #33281a; }
.bookhead { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px; } .bookhead h4 { margin-bottom: 0 !important; }
.bookhead small { color: var(--mut); }
.spark { width: 100%; height: 60px; display: block; margin-top: 8px; background: #1a140f; border-radius: 8px; }
.sparkl { display: flex; justify-content: space-between; font-size: 11px; color: var(--mut); margin-top: 2px; }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.lvl { position: relative; display: flex; justify-content: space-between; font-size: 12px; padding: 3px 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.lvl b { position: absolute; top: 0; bottom: 0; right: 0; opacity: .18; } .lvl span { position: relative; }
.lvl.ask b { background: var(--red); } .lvl.ask span:first-of-type { color: #ff8e85; }
.lvl.bid b { background: var(--green); } .lvl.bid span:first-of-type { color: #7fe0b0; }
.lvl.empty { color: var(--mut); cursor: default; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: none; } .seg input { display: none; }
.seg span { display: block; padding: 7px 14px; font-weight: 700; color: var(--mut); cursor: pointer; }
.seg input:checked + span { background: #33281a; color: var(--amber2); }

/* chat */
#chat { position: absolute; left: 10px; bottom: calc(var(--nav-h) + 22px); width: 360px; height: 300px; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; display: none; flex-direction: column; z-index: 5; backdrop-filter: blur(6px); }
#chat.open { display: flex; }
.chat-head { display: flex; align-items: center; padding: 6px 6px 6px 8px; border-bottom: 1px solid var(--line); }
.ctabs { flex: 1; display: flex; gap: 4px; }
.ctabs button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; color: var(--mut); font-weight: 700; font-size: 13px; } .ctabs button.on { background: #33281a; color: var(--amber2); }
#chatList { flex: 1; overflow-y: auto; padding: 6px 10px; font-size: 13.5px; }
.msg { padding: 3px 0; line-height: 1.35; word-wrap: break-word; position: relative; }
.msg .t { color: #776a5c; font-size: 11px; margin-right: 6px; }
.msg b { color: var(--amber2); } .msg.admin b { color: #ff8e85; } .msg.mod b { color: #7fc8ff; }
.msg.sys { color: #c6b8a4; font-style: italic; }
.msg .tag { font-style: normal; font-size: 9px; background: #5a1f19; color: #fff; padding: 0 4px; border-radius: 3px; vertical-align: 1px; }
.msg.mod .tag { background: #1f3f5a; }
.msg .rep { display: none; position: absolute; right: 0; top: 2px; border: 0; background: #3a2f25; border-radius: 4px; font-size: 11px; color: var(--mut); }
.msg:hover .rep { display: block; }
#chatForm { display: flex; gap: 6px; padding: 7px; border-top: 1px solid var(--line); }
#chatForm input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #1a140f; }
#chatForm button { border: 0; border-radius: 8px; background: var(--amber); color: #241605; font-weight: 800; padding: 0 14px; }

#toasts { position: absolute; top: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 20; pointer-events: none; width: min(92vw, 440px); }
.toast { background: #2d241b; border: 1px solid var(--line); padding: 9px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: tin .25s; transition: opacity .4s, transform .4s; text-align: center; }
.toast.ok { border-color: #2f6b4b; } .toast.err { border-color: var(--red); background: #3a1d19; } .toast.info { border-color: var(--blue); background: #1d2a3a; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes tin { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  :root { --nav-h: 58px; }
  #hud { left: 6px; right: 6px; top: max(6px, env(safe-area-inset-top)); flex-direction: column; gap: 5px; }
  .hud-co { padding: 5px 10px 5px 6px; align-self: flex-start; } .hud-co img { width: 24px; height: 24px; }
  .hud-co b { font-size: 14px; max-width: 60vw; }
  .hud-stats { padding: 5px 0; } .hud-stats > div { padding: 0 8px; min-width: 0; flex: 1; }
  .hud-stats b { font-size: 14px; } .hide-sm { display: none; }
  #hudWarn { font-size: 12px; max-width: 94vw; white-space: normal; text-align: center; }
  #nav { left: 0; right: 0; transform: none; bottom: 0; border-radius: 14px 14px 0 0; padding: 4px 2px calc(4px + var(--safe-b)); justify-content: space-between; overflow-x: auto; }
  #nav button { min-width: 0; flex: 1; padding: 5px 0; font-size: 9px; }
  #nav button svg { width: 21px; height: 21px; }
  #nav .dot { right: 6px; }
  #nav .lg { display: none; } #nav .sh { display: block; }
  #hudWarn { top: 128px; }
  #toasts { top: 160px; } .toast { font-size: 13px; padding: 7px 12px; }
  #panel, #chat { left: 0; right: 0; width: auto; top: auto; height: 58vh; bottom: calc(var(--nav-h) + var(--safe-b)); border-radius: 16px 16px 0 0; border-bottom: 0; animation: slideup .22s ease-out; }
  @keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
  body.panel-open #fab, body.chat-open #fab { right: 12px; opacity: 0; pointer-events: none; }
  #fab { right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); }
  #mineBtn { width: 70px; height: 70px; }
  .mlist .mrow { grid-template-columns: 12px 64px 1fr 44px 56px; gap: 6px; font-size: 12px; }
}
@media (max-width: 760px) and (orientation: landscape) { #panel, #chat { height: 70vh; } }
