:root {
  --bg: #f0f2f5;
  --buffer-bg: #e2e6ea;
  --surface: #ffffff;
  --text: #37474f;
  --text-light: #607d8b;
  --primary: #6c5ce7;
  --outline-today: yellow;
  --brdr: #333;
  --grid-gap-color: #dfe6e9;
  --grid-border: #b2bec3;
  --border-width: 0px;
  --grid-bg: white;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .12);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .1);
  --backdrop-blur: 0px;
  --radius-sm: 4px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --font-main: "Roboto", "Segoe UI", sans-serif;
  --cell-size: 38px;
  --stack-width: 194px;
  --panel-width-l: 60px;
  --panel-width-r: 60px;
  --preview-size: 60px;
  --mini-size: 14px;
  --c-I: #00cec9;
  --c-O: #ffeaa7;
  --c-T: #a29bfe;
  --c-S: #55efc4;
  --c-Z: #ff7675;
  --c-J: #74b9ff;
  --c-L: #fab1a0
}











[data-theme=dark] {
  --bg: #121212;
  --buffer-bg: #1a1a1a;
  --surface: #1e1e1e;
  --text: #e0e0e0;
  --text-light: #aaaaaa;
  --grid-gap-color: #404040;
  --grid-border: #555555;
  --grid-bg: #252525;
  --primary: #8c7ae6
}

html {
  touch-action: none
}

button {
  touch-action: manipulation;
  outline: none;
}

button:focus {
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background .3s, color .3s
}

#game-stage {
  display: flex;
  flex-direction: row;
  /* align-items: center; */
  align-items: flex-start;
  justify-content: center;
  width: 375px;
  /* height: 486px; */
  height: auto;
  box-sizing: border-box;
  gap: 10px;
  padding: 10px;
  flex-shrink: 0;
}

.col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* height: 100%; */
  height: auto;
}

.col-left {
  width: var(--panel-width-l);
  align-items: center;
  gap:8px;
  justify-content: flex-start
}

.col-right {
  width: var(--panel-width-r);
  align-items: center;
  margin-left: 8px
}

.col-center {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.panel-box {
  width: 100%;
  transition: opacity .3s;
  height: 100%;
  text-align: center;
}

.date-box,
.modal,
.btn-icon,
.ctrl-btn,
.preview-slot,
#quick-restart-btn,
#stack-container,
#pause-btn {
  background: var(--surface);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: var(--border-width) solid var(--grid-border);
  transition: transform .1s, background .2s
}

.big-btn:not(.btn-primary):hover,
.btn-icon:hover,
.ctrl-btn:hover,
#quick-restart-btn:hover,
#pause-btn:hover {
  background: var(--bg) !important
}

.btn-primary:hover {
  background: var(--primary) !important;
  filter: brightness(0.88);
}



.logo-box {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 900;
  font-size: 24px;
  letter-spacing: 4px;
  color: var(--primary);
  text-transform: uppercase;
  cursor: default;
  margin-bottom: 10px;
}

.logo-mobile {
  display: none
}

.btn-icon {
  width: 52px;
  height: 52px;
  color: var(--text-light);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  display: flex;
    flex-direction: column;
    justify-content: center;
}

.btn-icon:active {
  transform: scale(.95)
}
.btn-icon-text {
  font-size: 0.5rem;
}
.big-btn {
  background: var(--surface);
  color: var(--text);
  padding: 11px 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-transform: uppercase;
  margin-top: 10px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--brdr);
  width: 100%;
  max-width: 220px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}



.big-btn:active {
  transform: scale(.96)
}

#stack-container {
  overflow: hidden;
  position: relative;
  width: var(--stack-width);
  cursor: pointer;
  touch-action: none !important;
  user-select: none;
  -webkit-user-select: none;
  border-radius: var(--radius-sm)
}

#stack-container * {
  touch-action: none !important
}

#buffer-zone {
  height: calc((var(--cell-size) * 6) + 5px);
  background-color: var(--buffer-bg);
  width: 100%;
  position: relative
}

#grid {
  display: grid;
  grid-template-columns: repeat(5, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: 1px;
  background: var(--bg);
  border-top: 1px dotted var(--grid-gap-color)
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--surface)
}

.piece-block {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  box-sizing: border-box;
  box-shadow: inset 0 0 4px #fff6, 0 2px 4px #0000001a
}


.p-I {
  background: var(--c-I)
}

.p-O {
  background: var(--c-O)
}

.p-T {
  background: var(--c-T)
}

.p-S {
  background: var(--c-S)
}

.p-Z {
  background: var(--c-Z)
}

.p-J {
  background: var(--c-J)
}

.p-L {
  background: var(--c-L)
}

.ghost {
  background: transparent !important;
  opacity: .3;
  box-shadow: inset 0 0 0 1px var(--text-light) !important
}

.axis {
  position: absolute;
  color: var(--text-light);
  font-size: 10px;
  font-family: monospace;
  font-weight: 600;
  display: none
}

body.show-axis .axis {
  display: flex
}

.axis-y {
  flex-direction: column-reverse;
  left: 5px;
  width: 15px;
  top: calc((var(--cell-size) * 6));
  height: calc((var(--cell-size) * 8));
  margin-top: 12px
}

.axis-x {
  bottom: 5px;
  left: 25px;
  width: var(--stack-width);
  justify-content: space-around
}

#next-preview {
  width: var(--preview-size);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px
}

.preview-slot {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 60px;
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center
}

.mini {
  position: absolute;
  width: var(--mini-size);
  height: var(--mini-size);
  border: 1px solid rgba(255, 255, 255, .5)
}

.label {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase
}

.date-box {
  font-size: 11px;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  opacity: .8;
  margin-bottom: 10px;
  padding: 8px;
}

.overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #00000080;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  color: var(--text)
}

.overlay:not(.hidden) {
  opacity: 1;
  pointer-events: auto
}

.modal {
  padding: 20px;
  text-align: center;
  width: 300px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center
}

#calendar-overlay .modal {
  min-height: 374px
}

.ui-layer {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--buffer-bg);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  text-align: center;
  padding: 10px;
  opacity: .9;
  pointer-events: auto;
  transition: opacity .5s ease;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.ui-layer.hidden {
  opacity: 0;
  pointer-events: none
}

.hidden {
  display: none !important
}

.config-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--grid-gap-color);
  font-size: 14px
}

input[type=checkbox] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  cursor: pointer
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: auto;
  margin-top: auto
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  background: var(--grid-bg);
  cursor: pointer;
  position: relative;
  border: 1px solid var(--grid-gap-color)
}

.cal-tries {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 8px;
  opacity: .5
}

.cal-day.today {
  outline: 1px solid var(--outline-today) !important
}

.cal-day.win {
  background: var(--c-S);
  color: #000
}

.cal-day.fail {
  background: var(--c-Z);
  color: #000
}

.mini-cal-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 280px;
  padding: 4px 0;
  justify-content: center
}

.mini-cal-container::-webkit-scrollbar {
  display: none
}

.mini-cal-day {
  min-width: 30px;
  width: 30px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--brdr);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm)
}

.mini-cal-day.win {
  background: var(--c-S);
  color: #000
}

.mini-cal-day.fail {
  background: var(--c-Z);
  color: #000
}

.win-shimmer {
  position: relative;
  overflow: hidden
}

.win-shimmer:after {
  content: "";
  position: absolute;
  top: 0;
  left: -150%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, .6) 50%, transparent 100%);
  transform: skew(-20deg);
  animation: shimmer-move .8s cubic-bezier(.2, .8, .2, 1) forwards;
  pointer-events: none;
  z-index: 50
}

@keyframes shimmer-move {
  0% {
    left: -150%
  }

  to {
    left: 250%
  }
}

.piece-glow,
.cell-glow {
  animation: minimal-shine .3s cubic-bezier(.25, .46, .45, .94) forwards;
  z-index: 10
}

@keyframes minimal-shine {
  0% {
    filter: brightness(1);
    box-shadow: inset 0 0 #fff0
  }

  30% {
    filter: brightness(1.2);
    box-shadow: inset 0 0 0 1px #ffffffe6
  }

  to {
    filter: brightness(1)
  }
}

@media (max-width: 600px) {
  .logo-box {
    display: none
  }

  .logo-mobile {
    display: block;
    font-weight: 900;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 24px;
    letter-spacing: 4px;
    color: var(--primary)
  }

  .col-left {
    width: 50px !important;
    gap: 5px;
  }

  .col-right {
    width: 60px;
    margin-left: 8px;
    margin-right: 4px
  }

  .preview-slot {
    min-width: 60px;
    min-height: 60px
  }

  #game-stage {
    gap: unset;
    padding: 0
  }

  body {
    height: 98vh
  }

  .btn-icon {
    width: 42px;
    height: 42px;
  }
.btn-icon-text {
  display: none;
}
  .mini-cal-day {
    min-width: 30px;
    width: 30px
  }

}

button[title=Share],
button[title=About] {
  display: none !important
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0)
}

#quick-restart-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--grid-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all .2s ease;
  width: var(--preview-size);
  padding: 10px 0
}

#quick-restart-btn:hover {
  background: var(--bg)
}

body.tutorial-active #quick-restart-btn {
  display: none
}

#pause-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--grid-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  cursor: pointer;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  width: var(--preview-size);
  padding: 10px 0
}

#pause-btn:hover {
  background: var(--bg)
}

#pause-btn:focus {
  outline: none;
  background: var(--surface);
}

#pause-btn.is-paused {
  background: var(--c-Z);
  /* color: #fff; */
  border-color: var(--c-Z);
}

#pause-btn.is-paused:focus,
#pause-btn.is-paused:hover {
  background: var(--c-Z);
  opacity: 0.85;
  outline: none;
}

.confetti {
  position: absolute;
  top: -40px;
  z-index: 100;
  pointer-events: none
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0);
    opacity: 1
  }

  to {
    transform: translateY(800px) rotate(720deg);
    opacity: 0
  }
}

#next-label {
  text-align: center
}

.cal-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  font-weight: 700;
  /* color: var(--primary); */
}

.cal-legend {
  display: flex;
  gap: 15px;
  justify-content: center;
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 15px
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px
}

.legend-box {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm)
}


.cal-day.locked {
  opacity: .3;
  cursor: default
}

.config-title {
  margin-top: 5px;
  margin-bottom: 5px
}

.mini-cal-arrow {
  display: none
}

#ui-content {
  font-size: .6rem
}

.subtitle {
  font-size: .7rem
}

#message-body {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  margin-top: 8px;
  letter-spacing: 0.5px;
}

.instructions {
  margin-top: 5px
}

.controls-bar {
  display: none
}

.link-btn {
  background: none;
  border: none;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  color: var(--text-light);
  padding: 8px 10px;
  min-height: 36px;
}

.link-btn:hover {
  color: var(--text);
}









.link-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.desktop-guide,
.mobile-guide {
  font-size: .8rem;
  margin-bottom: 10px;
  color: var(--text-light);
}



/* ── LEVELS OVERLAY & GRID ───────────────────────────────────────────────── */
.levels-modal {
  width: 320px;
  max-width: 92vw;
  padding: 16px;
}

.levels-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  /* border-bottom: 1px solid var(--grid-gap-color); */
}

.lvl-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--grid-gap-color) transparent;
  padding: 2px;
}

.lvl-tile {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--grid-gap-color);
  background: var(--surface);
  transition: transform 0.1s, background 0.15s;
  user-select: none;
  gap: 1px;
}

.lvl-num {
  font-size: 12px;
  line-height: 1.1;
}

.lvl-icon {
  font-size: 11px;
  line-height: 1;
  opacity: 0.85;
}

.lvl-tile:not(.lvl-locked):active {
  transform: scale(0.91);
}

.lvl-tile:not(.lvl-locked):hover {
  background: var(--bg);
}

.lvl-locked {
  opacity: 0.8;
  cursor: default;
}

.lvl-win {
  background: var(--c-S);
  color: #000;
  border-color: var(--c-S);
}

.lvl-fail {
  background: var(--c-Z);
  color: #fff;
  border-color: var(--c-Z);
}

.lvl-current {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}