:root{
  --bg0:#07090e;
  --bg1:#0d1420;
  --bg2:#121c2b;

  --text:#f4f7ff;
  --muted:rgba(244,247,255,.58);

  --line:#000;
  --blue1:#95abff;
  --blue2:#5d79f4;

  --shadow-xl:0 30px 70px rgba(0,0,0,.54);
  --shadow-lg:0 18px 38px rgba(0,0,0,.40);
  --shadow-md:0 10px 20px rgba(0,0,0,.28);

  --r-xl:24px;
  --r-lg:18px;
  --r-md:14px;
  --r-sm:12px;
}

*{box-sizing:border-box}
html,body{height:100%}
html{
  overflow:hidden;
  -webkit-text-size-adjust:100%;
}
body{
  margin:0;
  overflow:hidden;
  font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(1000px 700px at 15% 0%, rgba(67,99,255,.10), transparent 54%),
    radial-gradient(900px 640px at 100% 100%, rgba(40,190,255,.05), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 44%, var(--bg2));
}

.bg{
  position:fixed;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(900px 520px at 50% -10%, rgba(255,255,255,.02), transparent 60%),
    radial-gradient(1000px 720px at 50% 120%, rgba(255,255,255,.015), transparent 70%);
}

.noise{
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.04;
  background-image:
    radial-gradient(1px 1px at 10% 18%, rgba(255,255,255,.24), transparent 60%),
    radial-gradient(1px 1px at 70% 32%, rgba(255,255,255,.18), transparent 60%),
    radial-gradient(1px 1px at 34% 76%, rgba(255,255,255,.15), transparent 60%);
}

button,input{
  font:inherit;
}

.pressable{
  transition:transform .14s ease, filter .14s ease, box-shadow .14s ease, background .14s ease;
  will-change:transform;
}
.pressable:hover{filter:brightness(1.05)}
.pressable:active{transform:translateY(1px) scale(.985)}

.app{
  width:min(1100px, calc(100% - 18px));
  height:100%;
  margin:8px auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.topbar{
  min-height:62px;
  display:grid;
  grid-template-columns:42px minmax(0,1fr) 42px auto;
  gap:8px;
  align-items:center;
  padding:8px 10px;
  border-radius:18px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(27,36,50,.96), rgba(18,24,36,.96));
  box-shadow:var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.05);
}

.backBtn,
.iconBtn{
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:#fff;
  text-decoration:none;
  font-weight:900;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.brandWrap{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.brandLogo{
  width:42px;
  height:42px;
  flex:0 0 42px;
  border-radius:14px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:var(--shadow-md), inset 0 1px 0 rgba(255,255,255,.05);
}
.brandLogo svg{
  width:23px;
  height:23px;
  display:block;
}

.brandTitle{
  font-size:22px;
  line-height:1;
  font-weight:1000;
}
.brandSub{
  margin-top:3px;
  font-size:10px;
  letter-spacing:1.2px;
  text-transform:uppercase;
  color:var(--muted);
  font-weight:900;
}

.dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background:#26d47b;
  box-shadow:0 0 0 3px rgba(38,212,123,.14);
}

.balancePill{
  height:42px;
  padding:0 14px;
  display:inline-flex;
  align-items:center;
  border-radius:14px;
  border:1px solid var(--line);
  background:
    radial-gradient(180px 100px at 0% 0%, rgba(95,122,255,.14), transparent 72%),
    linear-gradient(180deg, rgba(35,46,64,.98), rgba(21,29,41,.98));
  font-size:18px;
  font-weight:1000;
  white-space:nowrap;
}

.screen{
  flex:1 1 auto;
  min-height:0;
}

.card{
  height:100%;
  border-radius:24px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(20,28,42,.98), rgba(14,20,31,.98));
  box-shadow:var(--shadow-xl), inset 0 1px 0 rgba(255,255,255,.04);
  overflow:hidden;
}

.hero{
  position:relative;
  padding:12px;
  display:grid;
  grid-template-rows:auto auto 1fr auto;
  gap:10px;
}

.heroTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}

.modeRow{
  display:flex;
  gap:8px;
  flex:1 1 auto;
}

.seg{
  flex:1 1 0;
  height:42px;
  min-width:0;
  padding:0 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:#fff;
  font-weight:950;
  cursor:pointer;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.seg.active{
  background:linear-gradient(180deg, rgba(95,124,255,.34), rgba(74,103,234,.20));
  box-shadow:0 12px 24px rgba(82,108,240,.14), inset 0 1px 0 rgba(255,255,255,.06);
}

.rulePill{
  height:42px;
  padding:0 12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:#dbe4ff;
  font-weight:900;
  white-space:nowrap;
}

.statsGrid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:8px;
}

.statCard{
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  padding:10px 12px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
  text-align:center;
}

.statCard__value{
  font-size:22px;
  line-height:1;
  font-weight:1000;
}

.statCard__label{
  margin-top:5px;
  font-size:11px;
  color:var(--muted);
  font-weight:800;
}

.arenaCard{
  min-height:0;
  border-radius:18px;
  border:1px solid var(--line);
  background:
    radial-gradient(700px 240px at 40% 30%, rgba(255,255,255,.05), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.14));
  padding:10px;
  display:grid;
  grid-template-rows:auto auto 1fr;
  gap:8px;
}

.arenaTop{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}

.miniInfo{
  min-height:34px;
  padding:0 10px;
  display:inline-flex;
  align-items:center;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:#fff;
  font-size:12px;
  font-weight:900;
}

.range{
  width:100%;
  accent-color:#4c7dff;
  cursor:pointer;
}

.cubeStage{
  min-height:0;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.06);
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.04), transparent 48%),
    linear-gradient(180deg, rgba(0,0,0,.12), rgba(0,0,0,.26));
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  position:relative;
}

.cubeStage::before{
  content:"";
  position:absolute;
  inset:0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size:34px 34px;
  mask-image:radial-gradient(circle at center, #000 34%, transparent 82%);
  pointer-events:none;
}

.cubeView{
  perspective:1000px;
  transform:translateZ(0);
}

.cube{
  --rx: 0deg;
  --ry: 0deg;
  --rz: 0deg;
  position:relative;
  width:112px;
  height:112px;
  transform-style:preserve-3d;
  transform:
    rotateX(-22deg) rotateY(35deg)
    rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(var(--rz));
  transition:transform 900ms cubic-bezier(.2,.85,.2,1);
  will-change:transform;
}

.face{
  position:absolute;
  inset:0;
  border-radius:18px;
  background:
    radial-gradient(120px 90px at 30% 24%, rgba(255,255,255,.16), rgba(255,255,255,0) 55%),
    linear-gradient(180deg, rgba(29,37,58,1), rgba(10,14,24,1));
  border:1px solid rgba(255,255,255,.16);
  box-shadow:
    0 18px 30px rgba(0,0,0,.45),
    0 0 0 1px rgba(0,0,0,.35) inset;
  display:flex;
  align-items:center;
  justify-content:center;
}

.face--front  { transform: rotateY(  0deg) translateZ(56px); }
.face--back   { transform: rotateY(180deg) translateZ(56px); }
.face--right  { transform: rotateY( 90deg) translateZ(56px); }
.face--left   { transform: rotateY(-90deg) translateZ(56px); }
.face--top    { transform: rotateX( 90deg) translateZ(56px); }
.face--bottom { transform: rotateX(-90deg) translateZ(56px); }

.pips{
  width:78px;
  height:78px;
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  grid-template-rows:repeat(3, 1fr);
  gap:8px;
  padding:9px;
  border-radius:14px;
  background:rgba(0,0,0,.14);
  border:1px solid rgba(255,255,255,.08);
}

.pip{
  width:10px;
  height:10px;
  border-radius:999px;
  background:rgba(245,248,255,.98);
  box-shadow:
    0 0 0 3px rgba(245,248,255,.08),
    0 3px 8px rgba(0,0,0,.35);
  opacity:0;
  transform:scale(.9);
}
.pip.on{
  opacity:1;
  transform:scale(1);
}

.betCard{
  display:grid;
  gap:10px;
}

.chips{
  display:grid;
  grid-template-columns:repeat(6, minmax(0,1fr));
  gap:6px;
}

.chip{
  min-width:0;
  height:38px;
  padding:0 8px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:#fff;
  cursor:pointer;
  font-size:12px;
  font-weight:900;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.betRow{
  display:grid;
  grid-template-columns:44px 1fr 44px;
  gap:8px;
  align-items:center;
}

.btnSmall{
  height:42px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:#fff;
  font-weight:1000;
  font-size:20px;
  cursor:pointer;
}

.betInput{
  height:42px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--text);
  font-weight:1000;
  padding:0 12px;
  outline:none;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.actionRow{
  display:grid;
  grid-template-columns:110px 1fr;
  gap:8px;
}

.actionRow--single{
  grid-template-columns:1fr;
}

.btnPrimary{
  min-height:46px;
  padding:0 16px;
  border-radius:16px;
  font-weight:1000;
  font-size:17px;
  color:#fff;
  cursor:pointer;
  border:1px solid rgba(82,108,240,.74);
  background:linear-gradient(180deg, var(--blue1), var(--blue2));
  box-shadow:0 16px 28px rgba(82,108,240,.24), inset 0 1px 0 rgba(255,255,255,.14);
}

.btnPrimary:disabled{
  opacity:.6;
  cursor:not-allowed;
}

@media (max-width: 860px){
  html,body{
    overflow:auto;
  }

  .app{
    height:auto;
  }

  .card{
    height:auto;
  }
}

@media (max-width: 520px){
  .app{
    width:calc(100% - 12px);
    margin:6px auto 10px;
  }

  .topbar{
    grid-template-columns:40px minmax(0,1fr) 40px auto;
    gap:6px;
    min-height:58px;
    padding:8px;
  }

  .backBtn,
  .iconBtn{
    width:40px;
    height:40px;
    border-radius:12px;
  }

  .brandLogo{
    width:38px;
    height:38px;
    flex:0 0 38px;
    border-radius:12px;
  }

  .brandLogo svg{
    width:20px;
    height:20px;
  }

  .brandTitle{
    font-size:18px;
  }

  .brandSub{
    font-size:9px;
    letter-spacing:1px;
  }

  .balancePill{
    height:40px;
    padding:0 10px;
    font-size:16px;
  }

  .hero{
    padding:10px;
    gap:8px;
  }

  .seg{
    height:40px;
    font-size:14px;
  }

  .rulePill{
    height:40px;
    padding:0 10px;
    font-size:13px;
  }

  .statsGrid{
    gap:6px;
  }

  .statCard{
    padding:8px 8px;
    border-radius:14px;
  }

  .statCard__value{
    font-size:18px;
  }

  .statCard__label{
    font-size:10px;
    margin-top:4px;
  }

  .arenaCard{
    padding:8px;
    gap:6px;
  }

  .miniInfo{
    min-height:30px;
    padding:0 8px;
    border-radius:10px;
    font-size:11px;
  }

  .cubeStage{
    min-height:185px;
    border-radius:16px;
  }

  .cube{
    width:88px;
    height:88px;
  }

  .face{
    border-radius:15px;
  }

  .face--front  { transform: rotateY(  0deg) translateZ(44px); }
  .face--back   { transform: rotateY(180deg) translateZ(44px); }
  .face--right  { transform: rotateY( 90deg) translateZ(44px); }
  .face--left   { transform: rotateY(-90deg) translateZ(44px); }
  .face--top    { transform: rotateX( 90deg) translateZ(44px); }
  .face--bottom { transform: rotateX(-90deg) translateZ(44px); }

  .pips{
    width:62px;
    height:62px;
    gap:6px;
    padding:8px;
    border-radius:12px;
  }

  .pip{
    width:8px;
    height:8px;
  }

  .chips{
    grid-template-columns:repeat(6, minmax(0,1fr));
    gap:5px;
  }

  .chip{
    height:34px;
    font-size:11px;
    padding:0 4px;
  }

  .betRow{
    grid-template-columns:40px 1fr 40px;
    gap:6px;
  }

  .btnSmall,
  .betInput{
    height:40px;
    border-radius:12px;
  }

  .actionRow,
  .actionRow--single{
    grid-template-columns:1fr;
    gap:6px;
  }

  .btnPrimary{
    min-height:42px;
    border-radius:13px;
    font-size:16px;
  }
}

@media (max-width: 390px){
  .brandSub{
    display:none;
  }

  .balancePill{
    padding:0 8px;
    font-size:15px;
  }

  .rulePill{
    min-width:64px;
    justify-content:center;
  }

  .statCard__value{
    font-size:16px;
  }

  .chip{
    font-size:10px;
  }
}

@media (prefers-reduced-motion: reduce){
  .pressable,
  .cube{
    transition:none;
  }
}