:root {
  color-scheme: dark;
  --page: #241f38;
  --board: #1a1830;
  --border: #4a4478;
  --label: #cfc9ea;
  --soft-white: #f2f0fa;
  --yellow: #ffd166;
  --one: #ef476f;
  --two: #f78c6b;
  --three: #9b5de5;
  --four: #06d6a0;
  --five: #118ab2;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow-x: hidden;
  isolation: isolate;
  color: #fff;
  background: var(--page);
  font-family: "Segoe UI", system-ui, sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

body::before {
  background: url("assets/monobriks-game-world.webp") center / cover no-repeat;
}

body::after {
  background:
    linear-gradient(90deg, rgba(36, 31, 56, 0.9) 0%, rgba(36, 31, 56, 0.58) 47%, rgba(36, 31, 56, 0.38) 100%),
    linear-gradient(180deg, rgba(26, 24, 48, 0.34), transparent 24%, rgba(26, 24, 48, 0.7));
}

.site-header,
.hero,
footer {
  width: min(1120px, calc(100% - 64px));
  margin-inline: auto;
}

.site-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  color: #fff;
  font-family: "Russo One", sans-serif;
  font-size: 24px;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--label);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--four);
  box-shadow: 0 0 0 5px rgba(6, 214, 160, 0.12);
}

main {
  display: grid;
  align-items: center;
  padding-block: 48px 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(370px, 0.72fr);
  align-items: center;
  gap: clamp(60px, 10vw, 140px);
}

.hero-copy {
  position: relative;
  z-index: 2;
  transform: translateY(-96px);
}

.eyebrow {
  margin: 0 0 22px;
  color: var(--label);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: "Russo One", sans-serif;
  font-size: clamp(56px, 6.6vw, 88px);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

h1 span {
  color: var(--yellow);
}

.intro {
  max-width: 510px;
  margin: 28px 0 0;
  color: var(--label);
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.7;
}

.coming-soon {
  width: fit-content;
  margin-top: 36px;
  padding: 14px 30px;
  border: 3px solid #000;
  color: var(--board);
  background: var(--yellow);
  box-shadow: 5px 5px 0 #000;
  font-family: "Courier New", monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-1deg);
}

.game-preview {
  position: relative;
  width: min(100%, 390px);
  min-height: 646px;
  justify-self: center;
  perspective: 1200px;
}

.phone {
  position: relative;
  left: 50%;
  width: 370px;
  height: 800px;
  padding: 9px;
  border: 2px solid #575362;
  border-radius: 56px;
  background: linear-gradient(145deg, #302d35, #08080b 28%, #1d1b22 72%, #070709);
  box-shadow:
    0 34px 70px rgba(5, 4, 12, 0.48),
    0 0 0 1px #0b0a0d,
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transform: translateX(-50%) scale(0.8) rotate(1.2deg);
  transform-origin: top center;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 46px;
  background: var(--page);
}

.phone-screen::after {
  content: "";
  position: absolute;
  z-index: 30;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(112deg, rgba(255, 255, 255, 0.06), transparent 24%, transparent 72%, rgba(255, 255, 255, 0.025));
}

.dynamic-island {
  position: absolute;
  z-index: 20;
  top: 12px;
  left: 50%;
  width: 92px;
  height: 25px;
  border-radius: 999px;
  background: #050507;
  transform: translateX(-50%);
}

.dynamic-island::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #11152b;
  box-shadow: inset 0 0 2px #283667;
}

.phone-button {
  position: absolute;
  width: 4px;
  border: 1px solid #5b5860;
  background: #151419;
}

.phone-button-silent {
  top: 112px;
  left: -5px;
  height: 28px;
  border-radius: 3px 0 0 3px;
}

.phone-button-volume-up,
.phone-button-volume-down {
  left: -5px;
  height: 58px;
  border-radius: 4px 0 0 4px;
}

.phone-button-volume-up { top: 160px; }
.phone-button-volume-down { top: 228px; }

.phone-button-power {
  top: 180px;
  right: -5px;
  height: 82px;
  border-radius: 0 4px 4px 0;
}

.game-header {
  position: absolute;
  z-index: 5;
  top: 49px;
  right: 31px;
  left: 31px;
  height: 40px;
  display: flex;
  align-items: center;
}

.game-header strong {
  position: absolute;
  right: 0;
  left: 0;
  text-align: center;
  color: var(--label);
  font-size: 15px;
  font-weight: 700;
}

.round-control {
  appearance: none;
  padding: 0;
  border: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--border);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.game-hud {
  position: absolute;
  z-index: 5;
  top: 101px;
  right: 31px;
  left: 31px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board {
  position: absolute;
  top: 151px;
  left: 50%;
  width: 290px;
  height: 514px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 5px solid var(--border);
  border-radius: 12px;
  background: var(--board);
  transform: translateX(-50%);
}

.cell {
  border: 1px solid var(--border);
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  font-size: 27px;
  font-weight: 700;
}

.dot-grid {
  width: 70%;
  height: 70%;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
}

.dot {
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
}

.tile-one { background: var(--one); }
.tile-two { background: var(--two); }
.tile-three { background: var(--three); }
.tile-four { background: var(--four); }
.tile-five { background: var(--five); }

.tile-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tile-layer .tile {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 6px;
  left: calc(var(--col) * 56px + 1px);
  top: calc(var(--row) * 56px + 1px);
  transition:
    top 500ms cubic-bezier(0.2, 0.8, 0.3, 1.18),
    left 120ms ease-out,
    opacity 180ms ease,
    transform 180ms ease;
}

.tile-layer .falling-tile {
  z-index: 6;
  transition: none;
  box-shadow: 0 0 0 3px var(--soft-white), 0 0 12px 4px rgba(242, 240, 250, 0.5);
}

.tile-layer .match-ghost {
  z-index: 7;
  box-shadow: none;
}

.tile-layer .tile.dimmed {
  opacity: 0.08;
}

.tile-layer .tile.exiting {
  opacity: 0;
  transform: scale(0.4);
}

.tile-layer .tile.gold {
  color: #4a3100;
  border: 2px solid #fff0a8;
  background: #f6c945;
  box-shadow: 0 0 10px 2px rgba(246, 201, 69, 0.45);
}

.tile-layer .tile.gold .dot {
  background: #4a3100;
}

.tile-layer .tile.gold.mystery {
  font-size: 30px;
  font-weight: 800;
}

.next-piece {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.next-piece .tile {
  width: 42px;
  height: 42px;
  border-radius: 5px;
  font-size: 20px;
}

.score {
  position: absolute;
  right: 9px;
  top: 8px;
  font-family: "Jersey 10", "Courier New", monospace;
  font-size: 24px;
}

.controls {
  position: absolute;
  right: 31px;
  bottom: 42px;
  left: 31px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.controls button {
  appearance: none;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 0;
  color: #fff;
  background: var(--border);
  font-size: 20px;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.controls button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.controls button:disabled {
  opacity: 1;
  cursor: default;
}

.controls .gold-control {
  position: absolute;
  left: 0;
  color: #4a3100;
  border: 2px solid #fff0a8;
  background: #f6c945;
  box-shadow: 0 0 10px 2px rgba(246, 201, 69, 0.45);
  font-weight: 800;
}

.controls:has(.gold-control:not([hidden])) {
  transform: translateX(36px);
}

.game-over {
  position: absolute;
  z-index: 15;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-over[hidden],
.gold-control[hidden] {
  display: none;
}

.game-over {
  flex-direction: column;
  gap: 20px;
  background: rgba(10, 8, 20, 0.88);
}

.game-over strong {
  color: var(--one);
  font-family: "Courier New", monospace;
  font-size: 26px;
  letter-spacing: 4px;
  text-shadow: 3px 3px 0 #000;
  text-transform: uppercase;
}

.retry-visual {
  display: inline-block;
  padding: 10px 22px;
  border: 3px solid #000;
  color: var(--board);
  background: var(--yellow);
  box-shadow: 4px 4px 0 #000;
  font-family: "Courier New", monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.home-indicator {
  position: absolute;
  z-index: 20;
  bottom: 11px;
  left: 50%;
  width: 116px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(-50%);
}

footer {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(207, 201, 234, 0.14);
  color: #8a86a8;
  font-size: 12px;
}

@keyframes match-flash {
  from { background: #2ecc71; }
  to { background: transparent; }
}

.board.match-flash .cell {
  animation: match-flash 500ms ease-out;
  animation-delay: calc(var(--flash-order, 0) * 15ms);
}

.score-popup {
  position: absolute;
  z-index: 12;
  width: 56px;
  color: #2ecc71;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  animation: score-pop 890ms ease-out forwards;
}

@keyframes score-pop {
  0% { opacity: 0; transform: translateY(0) scale(0.6); }
  16% { opacity: 1; transform: translateY(-10px) scale(1); }
  65% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-48px) scale(1); }
}

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

@media (max-width: 800px) {
  body::before {
    background-position: 54% center;
  }

  body::after {
    background: rgba(36, 31, 56, 0.68);
  }

  .site-header,
  .hero,
  footer {
    width: min(100% - 36px, 600px);
  }

  .site-header {
    min-height: 80px;
  }

  main {
    padding-block: 56px 64px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 72px;
  }

  .hero-copy {
    text-align: center;
    transform: none;
  }

  .intro,
  .coming-soon {
    margin-inline: auto;
  }

  .game-preview {
    width: min(100%, 390px);
  }
}

@media (max-width: 420px) {
  .status {
    font-size: 0;
  }

  .eyebrow {
    font-size: 10px;
  }

  h1 {
    font-size: clamp(47px, 13.8vw, 58px);
  }

  .intro {
    font-size: 16px;
  }

  .game-preview {
    min-height: 582px;
  }

  .phone {
    transform: translateX(-50%) scale(0.72);
  }

  footer {
    min-height: 100px;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    text-align: center;
  }

  footer p {
    margin: 0;
  }
}

@media (max-width: 350px) {
  .game-preview {
    min-height: 494px;
  }

  .phone {
    transform: translateX(-50%) scale(0.608);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-layer .tile {
    transition: none;
  }
}
