:root {
  --paper: #f7f4eb;
  --ink: #253235;
  --muted: #75807d;
  --teal: #42a89a;
  --coral: #e27a6d;
  --gold: #e2b852;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  font-family: ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
  background: #d5d7cf;
  color: var(--ink);
}
body {
  padding: 14px;
  display: grid;
  place-items: center;
}
.shell {
  position: relative;
  width: min(1500px, 100%);
  height: min(930px, calc(100vh - 28px));
  min-height: 690px;
  border-radius: 24px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 26px 80px rgba(37, 50, 53, 0.22);
  display: grid;
  grid-template-rows: 70px 1fr;
}
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 22px;
  border-bottom: 1px solid #d8d4c8;
  background: #faf8f1;
  z-index: 4;
}
.special-drop {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  min-width: 245px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px 7px 8px;
  border: 1px solid color-mix(in srgb, var(--special) 55%, #fff);
  border-radius: 15px;
  background: rgba(250, 248, 241, 0.96);
  box-shadow: 0 8px 25px rgba(37, 50, 53, 0.16);
  pointer-events: none;
}
.special-drop.hidden {
  display: none;
}
.special-drop > i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--special);
  color: #fff;
  font-style: normal;
  font-weight: 950;
}
.special-drop span,
.special-drop small,
.special-drop b,
.special-drop em {
  display: block;
}
.special-drop small {
  color: var(--special);
  font-size: 6px;
  font-weight: 950;
  letter-spacing: 0.16em;
}
.special-drop b {
  font-size: 10px;
  line-height: 1.15;
}
.special-drop em {
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
}
.choice-colours {
  display: flex;
  gap: 4px;
  margin-left: 4px;
  pointer-events: auto;
}
.choice-colours.hidden {
  display: none;
}
.choice-colours button {
  border: 0;
  border-radius: 7px;
  background: var(--choice);
  color: #fff;
  padding: 6px 7px;
  font-size: 7px;
  font-weight: 950;
  cursor: pointer;
}
.brand {
  text-decoration: none;
  color: inherit;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
}
.brand > i {
  color: var(--teal);
  font-style: normal;
}
.brand small {
  font-size: 9px;
  color: #87908c;
  margin-left: 10px;
}
.brand small b {
  color: var(--teal);
}
.stats {
  display: flex;
  height: 51px;
}
.stats span {
  min-width: 116px;
  padding: 6px 15px;
  border-left: 1px solid #ded9ce;
  text-align: center;
}
.stats span:last-child {
  border-right: 1px solid #ded9ce;
}
.stats small,
.stats b {
  display: block;
}
.stats small {
  font-size: 7px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.stats b {
  font-size: 17px;
}
.next {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 9px;
}
.next small {
  font-size: 7px;
  letter-spacing: 0.13em;
  color: var(--muted);
  font-weight: 850;
}
.next i {
  width: 38px;
  height: 34px;
  display: block;
  border-radius: 52% 48% 43% 57%/58% 42% 58% 42%;
  background: #42a89a;
  box-shadow: 5px 5px 0 -4px #bde9e2;
  color: #fff;
  font-style: normal;
  font-weight: 950;
  line-height: 34px;
  text-align: center;
}
.play-area {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, 270px) minmax(420px, 720px) minmax(
      190px,
      250px
    );
  justify-content: center;
  gap: 22px;
  padding: 18px 22px;
  background: radial-gradient(circle at 50% 20%, #fdfcf7, #ece9df);
}
.side-panel,
.score-panel {
  align-self: center;
}
.eyebrow {
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--teal);
  font-weight: 900;
}
.side-panel h1 {
  font-size: 31px;
  line-height: 1;
  margin: 7px 0 14px;
  letter-spacing: -0.04em;
}
.side-panel h1 em {
  font-style: normal;
  color: var(--teal);
}
.side-panel > p,
.tip {
  font-size: 11px;
  line-height: 1.55;
  color: #737d79;
}
.side-panel ol {
  list-style: none;
  padding: 0;
  margin: 22px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.side-panel li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 8px;
  color: #6d7773;
}
.side-panel li i {
  width: 22px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 3px 3px 0 -2px var(--a);
}
button {
  font: inherit;
}
.outline {
  border: 1px solid #d2cdc2;
  background: #faf8f1;
  border-radius: 18px;
  padding: 9px 12px;
  color: #59625f;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.outline b {
  color: var(--teal);
}
.chamber-wrap {
  position: relative;
  align-self: stretch;
  min-height: 570px;
  max-height: 806px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(150deg, #e9f1ef, #cbd9d6);
  box-shadow:
    inset 0 0 0 1px rgba(55, 77, 77, 0.13),
    0 18px 50px rgba(44, 61, 60, 0.16);
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.chamber-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 3px solid rgba(255, 255, 255, 0.58);
  border-top: 0;
  border-radius: 0 0 32px 32px;
  box-shadow:
    inset 24px 0 35px rgba(255, 255, 255, 0.15),
    inset -22px 0 33px rgba(31, 56, 56, 0.07);
}
.danger-label {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 17.4%;
  border-top: 1px dashed rgba(196, 83, 77, 0.5);
  font-size: 6px;
  letter-spacing: 0.16em;
  color: #b55d58;
  text-align: right;
  padding: 4px 10px;
  pointer-events: none;
}
.drop-hint {
  position: absolute;
  left: 50%;
  top: 13px;
  transform: translateX(-50%);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: rgba(37, 50, 53, 0.45);
  pointer-events: none;
}
.grace-badge {
  position: absolute;
  z-index: 18;
  top: 36px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(37, 50, 53, 0.88);
  box-shadow: 0 5px 18px rgba(37, 50, 53, 0.18);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
}
.grace-badge b {
  color: #f0c96b;
}
.stage-controls {
  position: absolute;
  z-index: 20;
  right: 10px;
  top: 9px;
  display: flex;
  gap: 6px;
}
.stage-controls button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(37, 50, 53, 0.16);
  border-radius: 50%;
  background: rgba(250, 248, 241, 0.83);
  color: #253235;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(5px);
}
.stage-controls button.active {
  background: #253235;
  color: #fff;
}
.score-panel {
  padding: 18px;
  border-radius: 18px;
  background: rgba(250, 248, 241, 0.76);
  border: 1px solid rgba(37, 50, 53, 0.1);
}
.big-score {
  margin: 11px 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #ddd8cd;
}
.big-score b,
.big-score small {
  display: block;
}
.big-score b {
  font-size: 42px;
  letter-spacing: -0.05em;
}
.big-score small,
.combo small {
  font-size: 7px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.combo {
  position: relative;
  padding-bottom: 13px;
}
.combo b {
  display: block;
  font-size: 21px;
  color: #c28d22;
}
.combo i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 3px;
  border-radius: 4px;
  background: var(--gold);
  transition: width 0.1s;
}
.score-panel h3 {
  font-size: 11px;
  margin: 23px 0 8px;
}
.recent {
  display: grid;
  gap: 5px;
  min-height: 90px;
}
.recent div {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  background: #fff;
}
.recent i {
  width: 20px;
  height: 18px;
  border-radius: 50%;
  background: var(--c);
}
.recent b {
  font-size: 8px;
}
.recent em {
  font-style: normal;
  color: #c28d22;
  font-size: 8px;
  font-weight: 800;
}
.recent p {
  font-size: 9px;
  color: var(--muted);
}
.tip {
  margin: 18px 0 0;
}
.tip b {
  display: block;
  font-size: 7px;
  letter-spacing: 0.13em;
  color: var(--teal);
}
.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  background: rgba(244, 242, 233, 0.91);
  backdrop-filter: blur(7px);
}
.overlay.hidden,
.hidden {
  display: none !important;
}
.logo {
  position: relative;
  width: 170px;
  height: 125px;
}
.logo i {
  position: absolute;
  width: 95px;
  height: 82px;
  border-radius: 52% 48% 43% 57%/58% 42% 58% 42%;
  background: #42a89a;
  left: 20px;
  top: 20px;
  transform: rotate(-9deg);
}
.logo i:nth-child(2) {
  background: #e2b852;
  left: 70px;
  top: 32px;
  transform: rotate(10deg);
}
.logo b {
  position: absolute;
  z-index: 2;
  left: 42px;
  top: 38px;
  color: #fff;
  font-size: 27px;
  line-height: 0.77;
  transform: rotate(-4deg);
}
.logo em {
  font-style: normal;
}
.overlay > small {
  font-size: 7px;
  letter-spacing: 0.17em;
  color: var(--teal);
  font-weight: 900;
}
.overlay h2 {
  font-size: 31px;
  margin: 5px 0;
}
.overlay p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 18px;
}
.overlay > button {
  border: 0;
  border-radius: 22px;
  padding: 12px 22px;
  background: #253235;
  color: white;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(37, 50, 53, 0.2);
}
.overlay > button.second-chance {
  min-width: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 9px;
  padding: 10px 16px;
  border: 2px solid #d2a939;
  background: linear-gradient(135deg, #20180d, #4b3410);
}
.second-chance img {
  width: 82px;
  height: auto;
  object-fit: contain;
}
.second-chance span,
.second-chance b,
.second-chance small {
  display: block;
  text-align: left;
}
.second-chance b {
  color: #ffe98d;
  font-size: 10px;
}
.second-chance small {
  margin-top: 2px;
  color: #fff;
  font-size: 7px;
  font-weight: 700;
}
.second-chance:disabled {
  display: none;
}
.overlay > span {
  font-size: 9px;
  color: var(--muted);
  margin-top: 13px;
}
.result > div {
  display: flex;
  gap: 9px;
  margin: 12px 0 18px;
}
.result > div span {
  min-width: 105px;
  padding: 11px;
  border-radius: 12px;
  background: #fff;
}
.result > div small,
.result > div b {
  display: block;
}
.result > div small {
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
.result > div b {
  font-size: 16px;
}
.toast {
  position: absolute;
  z-index: 25;
  left: 50%;
  top: 20%;
  transform: translate(-50%, -15px);
  opacity: 0;
  padding: 8px 13px;
  border-radius: 18px;
  background: #253235;
  color: white;
  font-size: 10px;
  font-weight: 800;
  transition: 0.25s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
dialog {
  width: min(700px, calc(100% - 28px));
  max-height: 85vh;
  border: 0;
  border-radius: 22px;
  padding: 25px;
  background: #faf8f1;
  color: #253235;
  box-shadow: 0 25px 90px rgba(37, 50, 53, 0.4);
}
dialog::backdrop {
  background: rgba(37, 50, 53, 0.58);
  backdrop-filter: blur(4px);
}
dialog > small {
  font-size: 8px;
  letter-spacing: 0.17em;
  color: var(--teal);
  font-weight: 900;
}
dialog h2 {
  font-size: 29px;
  margin: 4px 0 16px;
}
.close {
  position: absolute;
  right: 14px;
  top: 9px;
  border: 0;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}
.achievement-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.achievement {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #ddd8cd;
  border-radius: 12px;
  padding: 9px;
}
.achievement.locked {
  opacity: 0.35;
}
.achievement > i {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e2b852;
  color: #fff;
  font-style: normal;
}
.achievement b,
.achievement span {
  display: block;
}
.achievement b {
  font-size: 10px;
}
.achievement span {
  font-size: 8px;
  color: var(--muted);
}
.achievement em {
  font-size: 6px;
  font-style: normal;
  font-weight: 900;
  color: var(--teal);
}
.spreadsheet {
  position: absolute;
  z-index: 12;
  inset: 0;
  background: #f5f5f2;
  color: #26322f;
  font-family: Arial, sans-serif;
}
.spreadsheet header {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 15px;
  background: #217346;
  color: white;
  font-size: 10px;
}
.spreadsheet header i {
  margin-left: auto;
  font-style: normal;
}
.formula {
  height: 35px;
  display: grid;
  grid-template-columns: 55px 35px 1fr;
  align-items: center;
  border-bottom: 1px solid #c8cdc9;
  background: #fff;
  font-size: 10px;
}
.formula > * {
  padding: 0 9px;
}
.formula span {
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  font-style: italic;
}
.formula code {
  font-family: Arial;
}
.sheet-grid {
  display: grid;
  grid-template-columns: 35px 1.25fr repeat(3, 1fr);
  grid-auto-rows: 39px;
  margin: 15px;
  box-shadow: 0 0 0 1px #ccd0cd;
}
.sheet-grid > * {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-right: 1px solid #d7dad8;
  border-bottom: 1px solid #d7dad8;
  font-size: 9px;
  background: white;
}
.sheet-grid > b {
  justify-content: center;
  background: #e8ebe9;
  color: #66706c;
}
.sheet-grid strong {
  grid-column: 2/6;
  background: #dbeee3;
  color: #217346;
}
.spreadsheet footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 35px;
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 0 14px;
  background: #e6e9e7;
  font-size: 9px;
}
.spreadsheet footer span:first-child {
  padding: 9px;
  border-bottom: 3px solid #217346;
}
.spreadsheet footer i {
  margin-left: auto;
  font-style: normal;
}
.paused canvas {
  filter: saturate(0.65);
}
.power-bank {
  margin: 16px 0 8px;
  padding: 12px;
  border: 1px solid #d9d4c9;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.power-bank > div {
  grid-column: 1/3;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.power-bank > div small {
  font-size: 7px;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 900;
}
.power-bank > div b {
  font-size: 10px;
  color: var(--teal);
}
.power-bank > i {
  grid-column: 1/3;
  height: 6px;
  background: #dedbd2;
  border-radius: 8px;
  overflow: hidden;
}
.power-bank > i span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 0.2s;
}
.power-bank button {
  border: 1px solid #d8d3c7;
  border-radius: 10px;
  background: #faf8f1;
  padding: 7px 5px;
  cursor: pointer;
  color: var(--ink);
  min-height: 48px;
}
.power-bank button:disabled {
  opacity: 0.35;
  cursor: default;
}
.power-bank button:not(:disabled):hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}
.power-bank button.armed {
  color: #9f3939;
  border-color: #c44a46;
  background: #fff0ed;
  box-shadow: 0 0 0 3px rgba(196, 74, 70, 0.12);
}
.power-bank #gravityPower.armed {
  color: #5640a5;
  border-color: #7559c7;
  background: #f1edff;
  box-shadow: 0 0 0 3px rgba(117, 89, 199, 0.13);
}
.power-bank #shrinkPower.armed {
  color: #27735f;
  border-color: #389178;
  background: #eaf8f3;
  box-shadow: 0 0 0 3px rgba(56, 145, 120, 0.13);
}
.chamber-wrap:has(.merge-canvas) {
  cursor: default;
}
.chamber-wrap.tactical-removal {
  cursor: crosshair;
}
.chamber-wrap.gravity-targeting {
  cursor: crosshair;
}
.chamber-wrap.shrink-targeting {
  cursor: crosshair;
}
.power-bank button b,
.power-bank button small {
  display: block;
}
.power-bank button b {
  font-size: 7px;
}
.power-bank button small {
  font-size: 7px;
  line-height: 1.25;
  color: var(--muted);
  margin-top: 2px;
}
.chamber-wrap.shaking {
  animation: bigShake 0.09s linear infinite;
}
.chamber-wrap.tumbling {
  animation: bigTumble 0.16s ease-in-out infinite;
  transform-origin: 50% 58%;
}
@keyframes bigShake {
  0% {
    transform: translate(-4px, 2px) rotate(-0.25deg);
  }
  50% {
    transform: translate(4px, -2px) rotate(0.25deg);
  }
  100% {
    transform: translate(-2px, -1px);
  }
}
@keyframes bigTumble {
  0% {
    transform: translate(-7px, 3px) rotate(-1.1deg) scale(0.995);
  }
  50% {
    transform: translate(7px, -4px) rotate(1.1deg) scale(1.005);
  }
  100% {
    transform: translate(-5px, -1px) rotate(-0.7deg) scale(0.998);
  }
}
@media (max-width: 1050px) {
  .play-area {
    grid-template-columns: minmax(170px, 220px) minmax(420px, 690px);
  }
  .score-panel {
    display: none;
  }
}
@media (max-width: 760px) {
  body {
    padding: 0;
  }
  .shell {
    height: 100vh;
    min-height: 650px;
    border-radius: 0;
  }
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 0 10px;
  }
  .stats span {
    min-width: 72px;
    padding: 7px;
  }
  .stats span:last-child {
    display: none;
  }
  .next {
    display: none;
  }
  .play-area {
    display: block;
    padding: 0;
  }
  .side-panel {
    display: none;
  }
  .chamber-wrap {
    height: calc(100vh - 70px);
    max-height: none;
    border-radius: 0;
  }
  .achievement-list {
    grid-template-columns: 1fr;
  }
  .stage-controls {
    top: 11px;
  }
  .result > div span {
    min-width: 88px;
  }
}
@media (max-height: 760px) and (min-width: 761px) {
  .play-area {
    padding: 8px 18px;
  }
  .chamber-wrap {
    min-height: 570px;
  }
  .side-panel h1 {
    font-size: 25px;
  }
  .side-panel ol {
    margin: 12px 0;
  }
}
.mode-starts {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: min(420px, 100%);
}
.mode-starts button { flex: 1; }
.mode-starts .rush-start {
  background: linear-gradient(135deg, #7257c6, #d15f91);
}
.rush-note {
  max-width: 390px;
  margin-top: 8px;
  line-height: 1.4;
  color: #687370;
}
.mode-badge {
  position: absolute;
  z-index: 9;
  top: 76px;
  left: 82px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(32, 49, 51, .9);
  color: #fff;
  box-shadow: 0 5px 16px rgba(18, 34, 36, .16);
}
.mode-badge small { font-size: 9px; letter-spacing: .18em; }
.mode-badge b { font-size: 18px; font-variant-numeric: tabular-nums; }
#modeSwitchBtn {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}
