:root {
  --ink: #44372c;
  --cream: #fff7df;
  --pop: #ffca3a;
  --berry: #ff5c8a;
  --mint: #51d6a3;
  --sky: #7ed6ff;
  --shadow: 0 16px 40px rgba(91, 66, 28, .18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 202, 58, .5), transparent 26%),
    radial-gradient(circle at 86% 18%, rgba(81, 214, 163, .42), transparent 24%),
    linear-gradient(160deg, #fff2bd 0%, #fef8ee 44%, #d9f5ff 100%);
}

button {
  color: inherit;
  font: inherit;
}

.shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.hidden {
  display: none !important;
}

.home-screen,
.level-complete,
.final-screen {
  min-height: calc(100vh - 46px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  text-align: center;
}

.eyebrow,
.stage-kicker,
.label {
  margin: 0;
  color: #8c5e18;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 680px;
  color: #2f6957;
  font-size: clamp(2.4rem, 11vw, 5.8rem);
  line-height: .9;
}

h2 {
  font-size: clamp(1.15rem, 5vw, 2rem);
  line-height: 1.12;
}

.intro {
  max-width: 520px;
  font-size: 1.05rem;
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.hint-button,
.sound-button,
.icon-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  box-shadow: var(--shadow);
  transition: transform .16s ease, filter .16s ease;
}

.primary-button {
  min-width: 168px;
  padding: 14px 24px;
  background: var(--berry);
  color: #fff;
}

.secondary-button {
  min-width: 138px;
  padding: 14px 20px;
  background: #fff;
  color: #2f6957;
}

.hint-button {
  padding: 10px 14px;
  background: #fff;
}

.sound-button {
  width: 42px;
  height: 42px;
  background: #fff;
}

.icon-button {
  width: 44px;
  height: 44px;
  background: #fff;
  font-size: 1.45rem;
}

button:active {
  transform: translateY(2px) scale(.98);
}

.logo-scene {
  height: 180px;
  display: grid;
  place-items: center;
}

.brand-logo {
  width: min(220px, 58vw);
  height: auto;
  display: block;
  filter: drop-shadow(0 16px 26px rgba(91, 66, 28, .18));
}

.popcorn-mascot {
  position: relative;
  width: 96px;
  height: 106px;
  border: 5px solid #d9394f;
  border-radius: 18px 18px 26px 26px;
  background: repeating-linear-gradient(90deg, #fff 0 16px, #ff6677 16px 32px);
  box-shadow: var(--shadow);
}

.kernel {
  position: absolute;
  top: -28px;
  width: 42px;
  height: 38px;
  border: 4px solid #eab21d;
  border-radius: 50%;
  background: #ffe27a;
}

.k1 { left: -6px; transform: rotate(-18deg); }
.k2 { left: 27px; top: -42px; }
.k3 { right: -6px; transform: rotate(18deg); }

.face::before,
.face::after {
  content: "";
  position: absolute;
  top: 48px;
  width: 9px;
  height: 13px;
  border-radius: 999px;
  background: #3b3027;
}

.face::before { left: 28px; }
.face::after { right: 28px; }

.face {
  position: absolute;
  inset: 0;
}

.face:after {
  box-shadow: 0 22px 0 -2px #3b3027;
}

.game-screen {
  display: grid;
  gap: 12px;
}

.home-actions,
.top-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar,
.progress-strip {
  display: grid;
  align-items: center;
  gap: 10px;
  grid-template-columns: auto 1fr auto;
  padding: 12px;
  border: 3px solid rgba(255, 255, 255, .75);
  border-radius: 22px;
  background: rgba(255, 255, 255, .62);
  box-shadow: var(--shadow);
}

.progress-strip {
  grid-template-columns: repeat(5, 1fr);
  text-align: center;
}

.progress-strip strong {
  display: block;
  font-size: 1.35rem;
}

.boards {
  display: grid;
  gap: 12px;
}

.picture-panel {
  position: relative;
  width: 100%;
  padding: 30px 0 0;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 18px;
  background: #fffdf4;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}

.picture-panel > span {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 2;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  font-size: .82rem;
  font-weight: 900;
}

.scene {
  display: block;
  width: 100%;
  aspect-ratio: 360 / 260;
}

.found-ring {
  fill: rgba(81, 214, 163, .16);
  stroke: #14a76c;
  stroke-width: 5;
  vector-effect: non-scaling-stroke;
  animation: pop .32s ease both;
}

.hint-ring {
  fill: rgba(255, 202, 58, .16);
  stroke: #ffbd00;
  stroke-width: 6;
  vector-effect: non-scaling-stroke;
  animation: pulse 1s ease both;
}

.wrong-tap {
  position: fixed;
  width: 30px;
  height: 30px;
  pointer-events: none;
  border: 4px solid #ff5c8a;
  border-radius: 50%;
  animation: miss .42s ease forwards;
  z-index: 20;
}

.star-row {
  min-height: 62px;
  font-size: 3rem;
  letter-spacing: 8px;
}

.dashboard,
.result-stats {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dashboard > div,
.result-stats > div,
.scoreboard-panel,
.gallery-panel {
  padding: 12px;
  border: 3px solid rgba(255, 255, 255, .76);
  border-radius: 18px;
  background: rgba(255, 255, 255, .64);
  box-shadow: var(--shadow);
}

.dashboard strong,
.result-stats strong {
  display: block;
  font-size: 1.25rem;
}

.home-panels {
  width: min(100%, 780px);
  display: grid;
  gap: 12px;
}

.scoreboard-panel h2,
.gallery-panel h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

.scoreboard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.scoreboard-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
  font-weight: 800;
}

.scoreboard-list span {
  color: #8c5e18;
  font-size: .82rem;
  font-weight: 900;
}

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

.special-card {
  min-height: 114px;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 8px;
  border-radius: 14px;
  background: #fff;
  color: #2f6957;
  font-weight: 900;
}

.special-card.locked {
  color: #8c7b68;
  filter: grayscale(.4);
}

.special-art {
  width: 76px;
  height: 58px;
}

.unlock-message {
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff2a1;
  color: #8c5e18;
  font-weight: 900;
}

.dance-popcorn {
  position: relative;
  width: 132px;
  height: 164px;
  animation: dance .74s ease-in-out infinite alternate;
}

.dance-popcorn .body {
  position: absolute;
  inset: 45px 18px 0;
  border: 5px solid #d9394f;
  border-radius: 18px 18px 28px 28px;
  background: repeating-linear-gradient(90deg, #fff 0 18px, #ff6677 18px 36px);
}

.dance-popcorn .crown {
  position: absolute;
  top: 4px;
  left: 45px;
  width: 44px;
  height: 34px;
  clip-path: polygon(0 100%, 0 28%, 26% 58%, 50% 0, 74% 58%, 100% 28%, 100% 100%);
  background: #ffca3a;
}

.arm {
  position: absolute;
  top: 84px;
  width: 52px;
  height: 8px;
  border-radius: 999px;
  background: #44372c;
}

.arm.left {
  left: 0;
  transform: rotate(-28deg);
}

.arm.right {
  right: 0;
  transform: rotate(28deg);
}

@keyframes pop {
  from { transform: scale(.55); opacity: .2; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 0; transform: scale(.55); }
  35%, 72% { opacity: 1; transform: scale(1.18); }
}

@keyframes miss {
  to { transform: scale(1.8); opacity: 0; }
}

@keyframes dance {
  from { transform: rotate(-4deg) translateY(0); }
  to { transform: rotate(4deg) translateY(-8px); }
}

@media (min-width: 780px) {
  .shell {
    padding: 24px;
  }

  .boards {
    grid-template-columns: 1fr 1fr;
  }

  .home-panels {
    grid-template-columns: 1fr 1fr;
  }

  .picture-panel {
    padding-top: 34px;
  }
}

@media (max-width: 520px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .top-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .top-actions .hint-button {
    flex: 1;
  }

  .progress-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard,
  .result-stats {
    grid-template-columns: 1fr;
  }

  .gallery-list {
    grid-template-columns: 1fr;
  }
}

.game-screen.has-pair .boards {
  grid-template-columns: 1fr;
}

.game-screen.has-pair .picture-panel {
  max-width: 1120px;
  margin: 0 auto;
}

@media (min-width: 1120px) {
  .game-screen.has-pair .boards {
    grid-template-columns: 1fr 1fr;
  }

  .game-screen.has-pair .picture-panel {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 8px 7px 18px;
  }

  .game-screen {
    gap: 8px;
  }

  .topbar {
    grid-template-columns: 44px 1fr auto;
    gap: 8px;
    padding: 8px;
    border-width: 2px;
    border-radius: 18px;
  }

  .topbar h2 {
    font-size: 1.45rem;
    line-height: 1.02;
  }

  .stage-kicker,
  .label {
    font-size: .7rem;
  }

  .top-actions {
    grid-column: auto;
    justify-content: end;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .icon-button,
  .sound-button {
    width: 42px;
    height: 42px;
    box-shadow: none;
  }

  .hint-button {
    min-width: 72px;
    height: 42px;
    padding: 6px 12px;
    box-shadow: none;
    white-space: nowrap;
  }

  .progress-strip {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px 6px;
    border-width: 2px;
    border-radius: 16px;
  }

  .progress-strip strong {
    font-size: 1rem;
    line-height: 1.05;
  }

  .boards {
    gap: 8px;
  }

  .picture-panel {
    padding-top: 26px;
    border-width: 3px;
    border-radius: 14px;
  }

  .picture-panel > span {
    top: 5px;
    left: 8px;
    padding: 2px 9px;
    font-size: .76rem;
  }

  .game-screen.has-pair .picture-panel {
    max-width: none;
  }
}

@media (max-width: 390px) {
  .topbar h2 {
    font-size: 1.22rem;
  }

  .hint-button {
    min-width: 62px;
    padding-inline: 9px;
  }

  .progress-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}


.game-screen.focus-mode {
  min-height: 100dvh;
  margin: -18px -14px -28px;
  padding: 8px;
  gap: 6px;
  background: linear-gradient(160deg, #fff2bd 0%, #fef8ee 46%, #d9f5ff 100%);
  position: relative;
  z-index: 30;
}

.game-screen.focus-mode .topbar {
  position: sticky;
  top: 6px;
  z-index: 10;
  grid-template-columns: auto 1fr auto;
  padding: 6px;
  border-width: 2px;
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(91, 66, 28, .12);
}

.game-screen.focus-mode .topbar h2 {
  font-size: 1rem;
}

.game-screen.focus-mode .stage-kicker {
  display: none;
}

.game-screen.focus-mode .progress-strip {
  display: none;
}

.game-screen.focus-mode .boards {
  gap: 6px;
}

.game-screen.focus-mode .picture-panel {
  max-width: none;
  padding-top: 22px;
  border-width: 2px;
  border-radius: 12px;
  box-shadow: none;
}

.game-screen.focus-mode .picture-panel > span {
  top: 3px;
  left: 6px;
  font-size: .7rem;
}

@media (max-width: 640px) {
  .game-screen.focus-mode {
    margin: -8px -7px -18px;
  }

  .game-screen.focus-mode .icon-button,
  .game-screen.focus-mode .sound-button,
  .game-screen.focus-mode .hint-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0 8px;
  }

  .game-screen.focus-mode .hint-button {
    width: auto;
    min-width: 58px;
  }
}


/* Mobile play mode v2 */
@media (max-width: 640px) {
  body {
    background: linear-gradient(160deg, #fff0ae 0%, #f8f2de 38%, #dff5ff 100%);
  }

  .shell {
    padding: 6px 6px 14px;
  }

  .game-screen {
    gap: 6px;
  }

  .topbar {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 6px;
    border-width: 2px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 8px 18px rgba(91, 66, 28, .1);
  }

  .topbar h2 {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0;
    line-height: 1;
  }

  .topbar h2::after {
    content: attr(data-mobile-title);
    display: block;
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 950;
  }

  .stage-kicker {
    display: none;
  }

  .icon-button,
  .sound-button {
    width: 38px;
    height: 38px;
    box-shadow: none;
    font-size: 1.1rem;
  }

  .top-actions {
    grid-column: auto;
    justify-content: end;
    flex-wrap: nowrap;
    gap: 5px;
  }

  .hint-button {
    height: 38px;
    min-width: 64px;
    padding: 5px 10px;
    box-shadow: none;
    white-space: nowrap;
  }

  .progress-strip {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
    border-width: 2px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .62);
    box-shadow: 0 8px 18px rgba(91, 66, 28, .08);
  }

  .progress-strip > div:nth-child(3),
  .progress-strip > div:nth-child(5) {
    display: none;
  }

  .label {
    font-size: .64rem;
    letter-spacing: 0;
  }

  .progress-strip strong {
    font-size: .98rem;
    line-height: 1;
  }

  .boards {
    gap: 6px;
  }

  .picture-panel {
    padding-top: 22px;
    border-width: 2px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(91, 66, 28, .1);
  }

  .picture-panel > span {
    top: 3px;
    left: 6px;
    padding: 1px 8px;
    font-size: .68rem;
  }

  .game-screen.has-pair .picture-panel {
    max-width: none;
  }
}

@media (max-width: 380px) {
  .topbar h2::after {
    font-size: 1.12rem;
  }

  .icon-button,
  .sound-button,
  .hint-button {
    height: 34px;
  }

  .icon-button,
  .sound-button {
    width: 34px;
  }

  .hint-button {
    min-width: 56px;
    padding-inline: 8px;
  }
}
