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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0b0e1a;
  color: #e8eaf2;
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: #0b0e1a; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.hidden { display: none !important; }
.dim { opacity: .55; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }

#top {
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  text-align: center;
  letter-spacing: .18em;
  font-size: 12px;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
#cubeinfo { font-weight: 600; }
#progresswrap {
  margin: 7px auto 5px; width: min(360px, 70vw); height: 4px;
  background: rgba(255,255,255,.14); border-radius: 2px; overflow: hidden;
}
#progress { height: 100%; width: 0%; background: #ffd94f; border-radius: 2px; transition: width .3s; }
#statsline { font-size: 10px; opacity: .75; letter-spacing: .12em; }

#bottom {
  pointer-events: auto;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: linear-gradient(transparent, rgba(5,7,14,.85) 40%);
}
#wallet { font-size: 16px; font-weight: 700; letter-spacing: .06em; min-width: 90px; text-align: center; }
#wallet .dim { font-size: 10px; font-weight: 400; letter-spacing: .18em; }

#tools { display: flex; gap: 6px; }
.tool {
  min-width: 46px; height: 46px; padding: 0 6px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 9px;
  background: rgba(255,255,255,.06); color: #e8eaf2;
  font-size: 17px; position: relative; cursor: pointer;
}
.tool.sel { border-color: #ffd94f; background: rgba(255,217,79,.16); box-shadow: 0 0 10px rgba(255,217,79,.35); }
.tool .badge {
  position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px;
  border-radius: 9px; background: #ffd94f; color: #14172a;
  font-size: 10px; font-weight: 700; line-height: 17px; padding: 0 4px;
}
.tool .badge.time { background: #8ecdf7; }
.shopitem .info .left { color: #8ecdf7; }
.tool:disabled { opacity: .35; }

#btns { display: flex; gap: 6px; }
.hbtn {
  height: 40px; padding: 0 14px;
  border: 1px solid rgba(255,255,255,.25); border-radius: 9px;
  background: rgba(255,255,255,.08); color: #e8eaf2;
  font-size: 12px; letter-spacing: .14em; font-weight: 600; cursor: pointer;
}
.hbtn:active { background: rgba(255,255,255,.2); }
.hbtn.wide { width: 100%; height: 46px; margin-top: 14px; }

/* ---------- combo ---------- */
#combo {
  position: fixed; right: 16px; top: 38%;
  font-size: 34px; font-weight: 800; color: #ffd94f;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  pointer-events: none; letter-spacing: .04em;
}

/* ---------- zoom slider ---------- */
#zslider {
  position: fixed; right: 6px; top: 50%; transform: translateY(-50%);
  height: 40vh; width: 44px; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  touch-action: none;
}
#zslider.show { opacity: 1; pointer-events: auto; }
#ztrack {
  width: 5px; height: 100%; border-radius: 3px;
  background: rgba(255,255,255,.18); position: relative;
}
#zthumb {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: #ffd94f; box-shadow: 0 2px 10px rgba(0,0,0,.55);
}
#ztrack::before, #ztrack::after {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: rgba(255,255,255,.6);
}
#ztrack::before { content: "+"; top: -22px; }
#ztrack::after { content: "−"; bottom: -22px; }

/* ---------- dev panel ---------- */
#devbar {
  position: fixed; left: 8px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 20;
}
#devbar .hbtn { height: 30px; font-size: 10px; padding: 0 8px; background: rgba(120,40,160,.35); }

/* ---------- face chat ---------- */
#chatwrap {
  position: fixed; left: 10px; bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 18; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  max-width: min(320px, 78vw);
}
#chattoggle { position: relative; }
#chatunread {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px;
  border-radius: 9px; background: #5fd8c9; color: #14172a;
  font-size: 10px; font-weight: 700; line-height: 18px; padding: 0 5px;
}
#chatpanel {
  width: min(320px, 78vw);
  background: rgba(19, 26, 45, 0.94); border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px; padding: 10px; backdrop-filter: blur(4px);
}
#chathead { display: flex; gap: 6px; padding: 0 0 8px; }
.ctab {
  flex: 1; height: 28px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,.15); background: transparent; color: #8b96b8;
  font-size: 10px; letter-spacing: .2em; font-weight: 700; cursor: pointer;
}
.ctab.sel { border-color: #ffd94f; color: #ffd94f; background: rgba(255,217,79,.1); }
#chatlist {
  max-height: 30vh; min-height: 60px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 5px; padding: 0 4px;
  font-size: 13px; line-height: 1.45; overscroll-behavior: contain;
}
.cmsg { word-break: break-word; }
.cmsg .cn { font-weight: 700; letter-spacing: .04em; color: #ffd94f; margin-right: 6px; font-size: 11px; }
.cmsg.mine .cn { color: #5fd8c9; }
.cmsg .cx { opacity: .92; }
.cempty { opacity: .45; font-size: 12px; font-style: italic; padding: 8px 0; }
#chatrow { display: flex; gap: 6px; margin-top: 9px; }
#chatinput {
  flex: 1; height: 38px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06); color: #e8eaf2; padding: 0 10px; font-size: 16px;
}
#chatsend {
  width: 42px; height: 38px; border-radius: 8px; border: 1px solid #ffd94f;
  background: rgba(255,217,79,.14); color: #ffd94f; font-size: 15px; cursor: pointer;
}

/* ---------- connection ---------- */
#conn {
  position: fixed; top: calc(46px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: rgba(200,40,40,.9); padding: 6px 16px; border-radius: 20px;
  font-size: 11px; letter-spacing: .2em; z-index: 30;
}

/* ---------- splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(5,7,14,.55); backdrop-filter: blur(3px);
  font-size: clamp(22px, 5vw, 44px); font-weight: 800; letter-spacing: .2em;
  text-shadow: 0 3px 20px rgba(0,0,0,.8); padding: 20px; pointer-events: none;
  white-space: pre-line; line-height: 1.6;
}

/* ---------- modal / shop ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(5,7,14,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modalbox {
  width: min(440px, 100%); max-height: 86vh; overflow-y: auto;
  background: #151a2e; border: 1px solid rgba(255,255,255,.15); border-radius: 14px;
  padding: 20px;
}
.modalbox h2 { letter-spacing: .3em; font-size: 16px; text-align: center; margin-bottom: 14px; }

.shopitem {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.shopitem .icon { font-size: 24px; width: 34px; text-align: center; }
.shopitem .info { flex: 1; }
.shopitem .info b { font-size: 12px; letter-spacing: .12em; display: block; }
.shopitem .info span { font-size: 11px; opacity: .6; }
.shopitem button {
  min-width: 86px; height: 34px; border-radius: 8px; border: 1px solid #ffd94f;
  background: rgba(255,217,79,.12); color: #ffd94f; font-weight: 700; font-size: 11px; cursor: pointer;
}
.shopitem button:disabled { opacity: .35; border-color: rgba(255,255,255,.3); color: #aaa; }
.shopitem button.owned { border-color: #6f6; color: #6f6; }

.namerow { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.namerow label { font-size: 10px; letter-spacing: .2em; opacity: .6; }
.namerow input {
  flex: 1; height: 36px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06); color: #e8eaf2; padding: 0 10px; font-size: 14px;
}

/* ---------- regen / war report ---------- */
#regenrate { color: #5fd8c9; }
.hbtn.gold { background: rgba(255,217,79,.15); border-color: #ffd94f; color: #ffd94f; }

.hallh { margin-top: 22px; }
.corerow {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 9px 6px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.corerow .cn { font-weight: 800; letter-spacing: .12em; color: #ffd94f; text-transform: uppercase; font-size: 13px; }
.corerow .cd { font-size: 11px; opacity: .6; letter-spacing: .06em; }

.ruleslist {
  margin: 0 0 18px 18px; font-size: 13px; line-height: 2; color: #c9d2ea;
}
.ruleslist li::marker { color: #5fd8c9; }
.cmsg.sys .cx { color: #5fd8c9; font-style: italic; }

.cubevoice {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; color: #5fd8c9; text-align: center; margin-bottom: 14px;
}
.ranksmsg.linkish { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.credit { margin-top: 20px; font-size: 10px; opacity: .4; line-height: 1.8; letter-spacing: .04em; }

#graveyard { margin-top: 20px; }
.gy-line {
  font-size: 10px; letter-spacing: .18em; opacity: .55; line-height: 2;
  text-transform: uppercase;
}
.gy-line.standing { color: #5fd8c9; opacity: .9; }

/* ---------- leaderboard ---------- */
.rankrow {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.rankrow .rk { width: 30px; text-align: center; opacity: .8; }
.rankrow .nm { flex: 1; letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rankrow .sc { font-weight: 700; color: #ffd94f; font-variant-numeric: tabular-nums; }
.rankrow.me { background: rgba(255,217,79,.1); border-radius: 6px; }
.ranksmsg { text-align: center; padding: 12px; font-size: 12px; opacity: .65; letter-spacing: .08em; }

/* ---------- ads: GDPR consent bar + desktop side rails ---------- */
.consent-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(10,13,26,.97);
  border-top: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  font-size: 12px; color: #c9d2ea;
}
.consent-txt { max-width: 560px; line-height: 1.5; }
.consent-bar a { color: #8ecdf7; }
.consent-btns { display: flex; gap: 8px; }
.consent-btn {
  font-family: inherit; font-weight: 700; font-size: 12px; cursor: pointer;
  border-radius: 8px; padding: 9px 14px; border: 1px solid rgba(255,255,255,.3);
  background: transparent; color: #aab6d8; white-space: nowrap;
}
.consent-btn.ok { background: #ffd94f; border: none; color: #14172a; }

.ad-rail { position: fixed; top: 0; bottom: 0; width: 160px; display: none; align-items: center; justify-content: center; z-index: 5; pointer-events: none; }
.ad-rail > * { pointer-events: auto; }
.ad-rail-left { left: 0; }
.ad-rail-right { right: 0; }
.ad-ph {
  width: 160px; height: 600px; border: 1px dashed rgba(255,255,255,.2); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.3); font-size: 11px; letter-spacing: .3em;
}

/* ---------- intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(ellipse at 50% 40%, #1a2140 0%, #0b0e1a 70%);
  display: flex; align-items: center; justify-content: center; text-align: center;
  overflow-y: auto;
}
#introbox { padding: 24px; max-width: 460px; }
#introbox h1 { font-size: clamp(26px, 6.5vw, 44px); letter-spacing: .3em; margin: 16px 0 4px; text-indent: .3em; line-height: 1.35; }
#introbox .tag { letter-spacing: .5em; font-size: 12px; opacity: .7; text-indent: .5em; }
#introbox .sub { margin-top: 18px; font-size: 13px; line-height: 1.8; opacity: .75; }
#introtitle { display: block; margin: 0 auto 6px; cursor: crosshair; touch-action: none; max-width: 100%; }
#introtaunt {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; color: #7a87ab; margin-top: 14px; min-height: 18px;
}
#introtaunt b { color: #5fd8c9; font-weight: 400; }

/* ---------- the war (tug bar + log) ---------- */
.tugwrap { margin: 6px 0 4px; }
.tuglabels {
  display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: .25em; margin-bottom: 7px;
}
.tuglabels .you { color: #ffd94f; }
.tuglabels .cube { color: #5fd8c9; }
.tugbar {
  height: 12px; border-radius: 6px; overflow: hidden; position: relative;
  background: rgba(95, 216, 201, 0.3);
}
#tugfill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: #ffd94f; border-radius: 6px 0 0 6px; transition: width .4s;
}
.tugread {
  margin-top: 7px; display: flex; justify-content: space-between;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; font-size: 11px; opacity: .75;
}
#tugpct { color: #ffd94f; }
#tugregen { color: #5fd8c9; }
#warlog {
  margin-top: 12px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 11px; line-height: 2; color: #7a87ab;
}
#warlog .re { color: #5fd8c9; }
#warlog .ch { color: #ffd94f; }
