html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(255, 79, 216, 0.20) 0%, rgba(0,0,0,0) 60%),
    radial-gradient(900px 650px at 80% 25%, rgba(55, 214, 255, 0.16) 0%, rgba(0,0,0,0) 60%),
    radial-gradient(1100px 750px at 45% 90%, rgba(61, 255, 154, 0.12) 0%, rgba(0,0,0,0) 65%),
    linear-gradient(160deg, #2a1158 0%, #114f78 100%);
}

:root{
  --panel: rgba(255,255,255,.12);
  --stroke: rgba(255,255,255,.20);
  --text: #ffffff;
  --p1: #ff4fd8;
  --p2: #7c5cff;
  --p3: #37d6ff;
  --p4: #3dff9a;
  --p5: #ffd84a;
}

#wrap {
  position: fixed;
  inset: 0;
}

/* Animated background canvas (stars + clouds) */
#bg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  z-index:0;
  pointer-events:none;
}

/* subtle vignette + grain */
#wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 120% at 50% 25%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.35) 65%, rgba(0,0,0,0.65) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, rgba(0,0,0,0) 2px, rgba(0,0,0,0) 6px);
  mix-blend-mode: overlay;
  opacity: 0.55;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: transparent;
  position: relative;
  z-index: 1;
}

#hud {
  position: fixed;
  left: 12px;
  /* Leave space for the separate crystals widget */
  top: calc(12px + env(safe-area-inset-top) + 52px);
  z-index: 20;
  color: #e8e8e8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  user-select: none;
  background: rgba(255, 255, 255, 0.10);
  padding: 8px 10px;
  border-radius: 14px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* Separate crystals widget (badge + "+") */
.crystals-widget{
  position: fixed;
  left: calc(12px + env(safe-area-inset-left));
  top: calc(12px + env(safe-area-inset-top));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  user-select: none;
}

.crystals-widget .crystal-badge{ margin: 0; }

#hud .row { line-height: 1.35; }
#hud .row-inline{ display:flex; align-items:center; gap:8px; }
#hud .row-crystals{ gap: 10px; }
#hud b { font-size: 16px; }

.icon-btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: #e8e8e8;
  border-radius: 10px;
  padding: 6px 8px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}
.icon-btn:active{ transform: translateY(1px); }

/* Big pause button: separated from the HUD block and very noticeable */
.pause-float{
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 28;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.22);
  background: linear-gradient(180deg, rgba(255,216,74,0.90), rgba(255,79,216,0.75));
  color: #0b0b12;
  font-size: 26px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 16px 0 rgba(0,0,0,0.16), 0 18px 32px rgba(0,0,0,0.25);
  user-select: none;
}
.pause-float:active{
  transform: translateY(6px);
  box-shadow: 0 10px 0 rgba(0,0,0,0.16), 0 14px 26px rgba(0,0,0,0.22);
}

@media (max-width: 520px){
  .pause-float{ width: 58px; height: 58px; border-radius: 16px; font-size: 24px; }
}

.hud-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,0.10);
}

.hud-right .label {
  font-size: 12px;
  opacity: 0.85;
  letter-spacing: 0.2px;
}

#next {
  width: 86px;
  height: 86px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #e8e8e8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(900px 520px at 20% 20%, rgba(255,79,216,0.22), rgba(0,0,0,0) 60%),
    radial-gradient(900px 520px at 80% 30%, rgba(55,214,255,0.18), rgba(0,0,0,0) 60%),
    radial-gradient(900px 520px at 45% 85%, rgba(61,255,154,0.14), rgba(0,0,0,0) 65%),
    rgba(0, 0, 0, 0.58);
  user-select: none;
}

/* When overlay is open: hide in-game UI and slightly soften the scene */
body.overlay-open #hud,
body.overlay-open #phaseSide,
body.overlay-open #pauseBtn,
body.overlay-open #crystalsWidget,
body.overlay-open #touch,
body.overlay-open #zoom{
  opacity: 0;
  pointer-events: none;
}
body.overlay-open #game{
  filter: blur(2px) saturate(0.85) brightness(0.9);
}

#panel {
  max-width: 520px;
  width: 100%;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 26px;
  padding: 20px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

/* Custom modal dialog (no native confirm/prompt) */
.modal{
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #e8e8e8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.62);
}
.modal-card{
  position: relative;
  width: 100%;
  max-width: 520px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 26px;
  padding: 20px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}
.modal-card h2{
  margin: 4px 0 10px;
  font-size: 26px;
  font-weight: 950;
  text-align: center;
}
.modal-card p{ text-align:center; }
.modal-actions{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

/* New menu typography */
.logo{
  margin: 4px 0 14px;
  font-size: 34px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.4px;
  text-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

/* Tetris-like title (light animation + "falling" blocks) */
.tetris-logo{
  position: relative;
  padding: 12px 12px 10px;
  border-radius: 22px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.16);
  overflow: hidden;
}
.tetris-title{
  display:flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: titleFloat 2.8s ease-in-out infinite;
}
.tetris-word{
  display:block;
  font-size: 40px;
  font-weight: 950;
  letter-spacing: 2.6px;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.35),
    0 10px 24px rgba(0,0,0,0.35);
}
.tetris-word2{
  font-size: 26px;
  letter-spacing: 6px;
  opacity: 0.95;
}

.tetris-blocks{
  position:absolute;
  inset: 0;
  pointer-events:none;
  opacity: 0.85;
}
.tblock{
  position:absolute;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.14);
  box-shadow: 0 10px 18px rgba(0,0,0,0.25);
  transform: translateY(-60px);
  animation: blockDrop 1.6s cubic-bezier(.2,.9,.2,1) infinite;
}
.tblock.b1{ left: 14px; top: 8px; animation-delay: 0.0s; }
.tblock.b2{ left: 36px; top: 8px; animation-delay: 0.15s; }
.tblock.b3{ right: 16px; top: 10px; animation-delay: 0.30s; }
.tblock.b4{ right: 38px; top: 10px; animation-delay: 0.45s; }
.tblock.b5{ left: 24px; bottom: 10px; animation-delay: 0.60s; }
.tblock.b6{ right: 24px; bottom: 10px; animation-delay: 0.75s; }
.tblock.b7{ left: 50%; top: 0px; margin-left: -9px; animation-delay: 0.9s; }

@keyframes titleFloat{
  0%{ transform: translateY(0); }
  50%{ transform: translateY(-4px); }
  100%{ transform: translateY(0); }
}

@keyframes blockDrop{
  0%{ transform: translateY(-70px); opacity: 0; }
  25%{ opacity: 1; }
  55%{ transform: translateY(0px); opacity: 1; }
  100%{ transform: translateY(0px); opacity: 0; }
}
.title{
  margin: 4px 0 14px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 6px 18px rgba(0,0,0,0.30);
}
.screen h1{
  margin: 4px 0 14px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 6px 18px rgba(0,0,0,0.30);
}
.tiny-hint{
  margin-top: 14px;
  text-align: center;
  font-weight: 800;
  opacity: 0.85;
}

#panel p {
  margin: 8px 0;
  opacity: 0.92;
  line-height: 1.35;
}

#panel .small {
  opacity: 0.75;
  font-size: 13px;
}

/* Buttons: big, bouncy, kid-friendly */
.btn{
  appearance:none;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 900;
  cursor: pointer;
  color: #0b0b12;
  box-shadow: 0 12px 0 rgba(0,0,0,0.18);
  transform: translateY(0);
  transition: transform .08s ease, filter .12s ease;
  user-select:none;
}

/* Menu icons */
.btn .btn-ico{
  display:inline-grid;
  place-items:center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  margin-right: 10px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 0 rgba(0,0,0,0.14);
}

/* Smaller icon buttons (pause toggles) */
.btn-mini{
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14px;
  box-shadow: none;
}
.btn-mini .btn-ico{
  width: 28px;
  height: 28px;
  border-radius: 10px;
  box-shadow: none;
  margin-right: 8px;
}

.btn-mini.off{ opacity: 0.72; }

.pause-controls{
  display:flex;
  gap: 10px;
  justify-content:center;
  margin: 10px 0 8px;
}

/* Pause screen: make button sizes consistent on desktop */
#screenPause .pause-controls{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  justify-content: stretch;
  margin: 12px 0 10px;
}
#screenPause .pause-controls .btn{
  width: 100%;
  justify-content: center;
}

#screenPause .buttons{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

#screenPause .buttons .btn{
  min-width: 0;
  width: 100%;
}

#screenPause .btn{ min-height: 56px; }
#screenPause .btn-mini{ min-height: 48px; }

@media (max-width: 640px){
  #screenPause .buttons{ grid-template-columns: 1fr; }
}

/* Locked choice in mode picker */
.choice.locked{
  opacity: 0.55;
  position: relative;
}
.choice.locked::after{
  content: "🔒";
  position:absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.9;
}
.mode-hint.pulse{
  animation: hintPulse 420ms ease-out;
}
@keyframes hintPulse{
  0%{ transform: translateY(0); }
  30%{ transform: translateY(-2px); }
  60%{ transform: translateY(0); }
  100%{ transform: translateY(0); }
}

.menu-picker{ margin: 8px 0 14px; }
.btn .btn-txt{ vertical-align: middle; }
.btn:active{
  transform: translateY(6px);
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
}

.btn + .btn{ margin-top: 12px; }

.btn-xl{ font-size: 24px; padding: 18px 16px; }
.btn-lg{ font-size: 20px; }

.btn-primary{
  background: linear-gradient(90deg, rgba(255,79,216,1), rgba(124,92,255,1));
  color: #ffffff;
}
.btn-secondary{
  background: linear-gradient(90deg, rgba(255,216,74,1), rgba(55,214,255,1));
}
.btn-ghost{
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: none;
}

.btn-danger{
  background: linear-gradient(90deg, rgba(255,84,84,1), rgba(255,170,72,1));
  color: #ffffff;
}

#panel .buttons {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#panel .buttons .btn{
  width: auto;
  flex: 1;
  min-width: 160px;
}

.toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  font-weight: 900;
}
.toggle input{ width: 20px; height: 20px; }

.screen{ display:block; }

/* Level select */
.lvl-top{
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  margin-bottom: 10px;
  opacity: 0.92;
}
.lvl-progress{ font-size: 13px; opacity: 0.9; }

.level-grid{
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  padding-right: 4px;
}

.lvl-btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  color: #e8e8e8;
  padding: 10px 8px;
  font-weight: 900;
  cursor: pointer;
  position: relative;
}
.lvl-num{
  font-size: 15px;
  line-height: 1;
}
.lvl-try{
  margin-top: 6px;
  font-size: 10px;
  font-weight: 800;
  opacity: 0.78;
  line-height: 1.1;
  display:flex;
  align-items:center;
  gap: 6px;
}

.try-ico{
  width: 14px;
  height: 14px;
  display:inline-block;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
  /* cute loop-arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M12 5a7 7 0 1 1-6.22 10.2.9.9 0 1 1 1.58-.86A5.2 5.2 0 1 0 12 6.8c-1.2 0-2.31.4-3.21 1.08l1.1 1.1a.9.9 0 0 1-.64 1.54H5.8a.9.9 0 0 1-.9-.9V6.99a.9.9 0 0 1 1.54-.64l.9.9A7 7 0 0 1 12 5Z'/%3E%3C/svg%3E");
}

.lvl-legend{
  margin-top: 10px;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.82;
  display:flex;
  align-items:center;
  gap: 8px;
}

/* Tutorial */
.tut-step{
  display:flex;
  align-items:flex-start;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  margin-top: 12px;
}
.tut-ico{
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display:grid;
  place-items:center;
  font-size: 24px;
  background: linear-gradient(90deg, rgba(255,79,216,0.40), rgba(124,92,255,0.30));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 0 rgba(0,0,0,0.14);
}
.tut-h{
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 4px;
}
.tut-dots{
  display:flex;
  justify-content:center;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 6px;
}
.tut-dots .dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
}
.tut-dots .dot.on{
  background: rgba(255,255,255,0.86);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}
.lvl-btn:active{ transform: translateY(1px); }
.lvl-btn.done{
  background: rgba(255,255,255,0.10);
  border-color: rgba(170,220,255,0.28);
}
.lvl-btn.done::after{
  content: "✓";
  position:absolute;
  right: 8px;
  top: 6px;
  font-size: 12px;
  opacity: 0.85;
}
.lvl-btn.locked{
  opacity: 0.35;
  cursor: default;
}
.lvl-btn.open{
  box-shadow: 0 0 0 1px rgba(160,220,255,0.25) inset, 0 0 16px rgba(120,200,255,0.16);
  border-color: rgba(170,220,255,0.38);
}

.lvl-nav{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.lvl-page{ opacity: 0.8; font-weight: 800; }

.btn.smallbtn{
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

/* Cylinder size picker */
.picker{
  margin-top: 12px;
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
}
.picker-title{
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2px;
  opacity: 0.92;
  margin-bottom: 8px;
}
.choices{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px;
}
.choice{
  appearance:none;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  color: #e8e8e8;
  padding: 10px 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.choice.active{
  background: rgba(255,255,255,0.12);
  border-color: rgba(170,220,255,0.40);
  box-shadow: 0 0 0 1px rgba(160,220,255,0.25) inset, 0 0 16px rgba(120,200,255,0.18);
}
.choice:active{ transform: translateY(1px); }

#touch {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 68px;
  grid-template-rows: 68px 68px;
  gap: 10px;
  user-select: none;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(0,0,0,0.18));
  color: #e8e8e8;
  font-size: 18px;
  font-weight: 800;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 0 rgba(0,0,0,0.14), 0 18px 30px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.touch-btn:active {
  transform: translateY(6px);
  box-shadow: 0 8px 0 rgba(0,0,0,0.14), 0 12px 22px rgba(0,0,0,0.20);
}

#zoom {
  position: fixed;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  user-select: none;
}

.zoom-btn {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(0,0,0,0.18));
  color: #e8e8e8;
  font-size: 22px;
  font-weight: 900;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 0 rgba(0,0,0,0.14), 0 16px 26px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.zoom-btn:active {
  transform: translateY(6px);
  box-shadow: 0 7px 0 rgba(0,0,0,0.14), 0 10px 18px rgba(0,0,0,0.20);
}

/* SVG icons inside mobile buttons */
.ui-ico{
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35));
}

#zoom .ui-ico{ width: 26px; height: 26px; }

@media (min-width: 900px) {
  #touch { display: none; }
  #zoom { display: none; }
}


/* Crystals */
.crystal-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
}
.crystal-icon{
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2064%2064%22%3E%0A%3Cdefs%3E%0A%3ClinearGradient%20id%3D%22a%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%221%22%20y2%3D%221%22%3E%0A%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23c9ffff%22/%3E%0A%3Cstop%20offset%3D%221%22%20stop-color%3D%22%235aa6ff%22/%3E%0A%3C/linearGradient%3E%0A%3ClinearGradient%20id%3D%22b%22%20x1%3D%220%22%20y1%3D%221%22%20x2%3D%221%22%20y2%3D%220%22%3E%0A%3Cstop%20offset%3D%220%22%20stop-color%3D%22%232e62ff%22%20stop-opacity%3D%220.90%22/%3E%0A%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23ffffff%22%20stop-opacity%3D%220.85%22/%3E%0A%3C/linearGradient%3E%0A%3C/defs%3E%0A%3Cpath%20d%3D%22M32%202%2054%2016%2062%2032%2054%2048%2032%2062%2010%2048%202%2032%2010%2016Z%22%20fill%3D%22url%28%23a%29%22%20stroke%3D%22rgba%28255%2C255%2C255%2C0.55%29%22%20stroke-width%3D%222%22/%3E%0A%3Cpath%20d%3D%22M32%202%2054%2016%2032%2032%2010%2016Z%22%20fill%3D%22rgba%28255%2C255%2C255%2C0.35%29%22/%3E%0A%3Cpath%20d%3D%22M54%2016%2062%2032%2032%2032Z%22%20fill%3D%22rgba%28255%2C255%2C255%2C0.12%29%22/%3E%0A%3Cpath%20d%3D%22M10%2016%2032%2032%202%2032Z%22%20fill%3D%22rgba%280%2C0%2C0%2C0.10%29%22/%3E%0A%3Cpath%20d%3D%22M2%2032%2010%2048%2032%2032Z%22%20fill%3D%22rgba%280%2C0%2C0%2C0.05%29%22/%3E%0A%3Cpath%20d%3D%22M62%2032%2032%2032%2054%2048Z%22%20fill%3D%22rgba%28255%2C255%2C255%2C0.08%29%22/%3E%0A%3Cpath%20d%3D%22M10%2048%2032%2062%2054%2048%2032%2032Z%22%20fill%3D%22url%28%23b%29%22%20opacity%3D%220.60%22/%3E%0A%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 0 10px rgba(140,210,255,0.45));
}

.crystal-icon.small{ width: 14px; height: 14px; }

.crystals-plus{
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #f4fbff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0,0,0,0.18);
}
.crystals-plus .cp-ico{ font-weight: 1000; font-size: 18px; line-height: 1; }
.crystals-plus:active{ transform: translateY(1px); }

/* Shop */
.shop-card{
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
}
.shop-item{
  display: flex;
  align-items: center;
  gap: 12px;
}
.shop-main{ flex: 1; }
.shop-title{ font-weight: 1000; letter-spacing: 0.2px; }
.shop-status{ margin-top: 10px; opacity: 0.85; text-align: center; min-height: 18px; }
.crystal-icon.shop{ width: 22px; height: 22px; }

/* Buy phase button */
.buy-phase{
  appearance:none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: #eef7ff;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}
.buy-phase .bp-ico{ opacity: 0.95; display:inline-flex; align-items:center; gap: 6px; }
.buy-phase .bp-cost{ opacity: 0.95; }
.buy-phase:active{ transform: translateY(1px); }
.buy-phase:disabled{
  opacity: 0.45;
  cursor: default;
}
.buy-phase.ready{
  background: rgba(170,255,255,0.12);
  border-color: rgba(180,255,255,0.22);
}
.buy-phase.armed{
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.24);
}

#fx{
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 10;
}

.crystal-fx{
  position: fixed;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2064%2064%22%3E%0A%3Cdefs%3E%0A%3ClinearGradient%20id%3D%22a%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%221%22%20y2%3D%221%22%3E%0A%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23c9ffff%22/%3E%0A%3Cstop%20offset%3D%221%22%20stop-color%3D%22%235aa6ff%22/%3E%0A%3C/linearGradient%3E%0A%3ClinearGradient%20id%3D%22b%22%20x1%3D%220%22%20y1%3D%221%22%20x2%3D%221%22%20y2%3D%220%22%3E%0A%3Cstop%20offset%3D%220%22%20stop-color%3D%22%232e62ff%22%20stop-opacity%3D%220.90%22/%3E%0A%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23ffffff%22%20stop-opacity%3D%220.85%22/%3E%0A%3C/linearGradient%3E%0A%3C/defs%3E%0A%3Cpath%20d%3D%22M32%202%2054%2016%2062%2032%2054%2048%2032%2062%2010%2048%202%2032%2010%2016Z%22%20fill%3D%22url%28%23a%29%22%20stroke%3D%22rgba%28255%2C255%2C255%2C0.55%29%22%20stroke-width%3D%222%22/%3E%0A%3Cpath%20d%3D%22M32%202%2054%2016%2032%2032%2010%2016Z%22%20fill%3D%22rgba%28255%2C255%2C255%2C0.35%29%22/%3E%0A%3Cpath%20d%3D%22M54%2016%2062%2032%2032%2032Z%22%20fill%3D%22rgba%28255%2C255%2C255%2C0.12%29%22/%3E%0A%3Cpath%20d%3D%22M10%2016%2032%2032%202%2032Z%22%20fill%3D%22rgba%280%2C0%2C0%2C0.10%29%22/%3E%0A%3Cpath%20d%3D%22M2%2032%2010%2048%2032%2032Z%22%20fill%3D%22rgba%280%2C0%2C0%2C0.05%29%22/%3E%0A%3Cpath%20d%3D%22M62%2032%2032%2032%2054%2048Z%22%20fill%3D%22rgba%28255%2C255%2C255%2C0.08%29%22/%3E%0A%3Cpath%20d%3D%22M10%2048%2032%2062%2054%2048%2032%2032Z%22%20fill%3D%22url%28%23b%29%22%20opacity%3D%220.60%22/%3E%0A%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 0 12px rgba(150,220,255,0.55));
  will-change: transform, opacity;
}

/* Side action button placement */
#phaseSide{
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Make the "Линия" button slightly different */
.buy-line{
  background: linear-gradient(180deg, rgba(55,214,255,0.20), rgba(255,216,74,0.12));
  border-color: rgba(255,255,255,0.24);
}

/* "Линия" icon: cube + "4" */
.cube-ico{ width: 18px; height: 18px; flex: 0 0 auto; }
.bp-ico-line .line-num{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 18px;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 13px;
  font-weight: 1000;
  line-height: 1;
}

.tut-ico.tut-ico-line{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 6px;
}
.tut-ico.tut-ico-line .cube-ico{ width: 20px; height: 20px; }
.tut-ico.tut-ico-line .line-num{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 22px;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 16px;
  font-weight: 1000;
  line-height: 1;
}

.buy-phase.buy-phase-side{
  max-width: 220px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: 0 14px 30px rgba(0,0,0,0.22);
}

.buy-phase.buy-phase-side .bp-text{
  font-weight: 900;
}

@media (max-width: 820px){
  /* On mobile: move the buy buttons under the big pause button (top-right),
     so they don't overlap the cylinder in the middle. */
  #phaseSide{
    right: calc(12px + env(safe-area-inset-right));
    top: calc(12px + env(safe-area-inset-top) + 64px + 10px);
    transform: none;
    gap: 10px;
    align-items: flex-end;
  }
  .buy-phase.buy-phase-side{ max-width: 200px; padding: 10px 12px; border-radius: 16px; }
  .buy-phase.buy-phase-side .bp-text{ font-size: 13px; }
}

@media (max-width: 520px){
  /* a bit tighter on very small screens */
  .buy-phase.buy-phase-side{ max-width: 190px; }
}

.crystal-badge.pulse{
  animation: crystalPulse 260ms ease-out;
}
@keyframes crystalPulse{
  0%{ transform: scale(1); }
  45%{ transform: scale(1.14); }
  100%{ transform: scale(1); }
}


/* Desktop controls hint */
.controls-hint{
  position:fixed;
  left:16px;
  bottom:16px;
  z-index:20;
  padding:10px 12px;
  border-radius:14px;
  background:rgba(20,24,40,0.55);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border:1px solid rgba(255,255,255,0.10);
  color:rgba(255,255,255,0.92);
  font-size:13px;
  line-height:1.25;
  font-weight:700;
  letter-spacing:0.2px;
  max-width:260px;
  display:none;
  pointer-events:none;
}

@media (hover:hover) and (pointer:fine){
  .controls-hint{ display:block; }
}

body.overlay-open .controls-hint{ display:none !important; }


/* Leaderboard */
.lb-list{
  margin-top: 12px;
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height: 52vh;
  overflow:auto;
  padding-right: 4px;
}
.lb-row{
  display:grid;
  grid-template-columns: 56px 1fr 96px;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.07);
  border:1px solid rgba(255,255,255,0.10);
}
.lb-rank{
  font-weight:900;
  opacity:0.85;
}
.lb-name{
  font-weight:800;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.lb-score{
  text-align:right;
  font-weight:900;
}
.lb-row.me{
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.10);
}
