/* Arcade canvas + mini-game shells (2.1) */
.arcade-shell, .mini-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  gap: .4rem;
}
.arcade-hud, .mini-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .35rem .6rem;
  flex: 0 0 auto;
}
.arcade-hud .game-status, .mini-hud .game-status { margin: 0; flex: 1 1 auto; }
.arcade-scores, .mini-scores {
  display: flex;
  gap: .7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
}
.arcade-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 14rem;
  min-width: 0;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--felt, #163024) 86%, #000), var(--felt-dark, #0c1812));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line, #c9a227) 45%, transparent);
  touch-action: none;
}
.arcade-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.arcade-stage[data-compact="1"] {
  position: relative;
  flex: 0 0 auto;
  width: min(20rem, 100%, calc(100dvh - 22rem));
  max-width: 20rem;
  max-height: min(20rem, calc(100dvh - 22rem));
  aspect-ratio: 1;
  height: auto;
  min-height: 8rem;
  margin: .35rem auto;
  align-self: center;
}
.arcade-pad, .mini-pad {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .45rem;
  flex: 0 0 auto;
  padding-bottom: max(.35rem, calc(env(safe-area-inset-bottom, 0px) + var(--host-safe-bottom, 2.6rem)));
}
.arcade-dpad {
  display: grid;
  grid-template-columns: 2.6rem 2.6rem 2.6rem;
  grid-template-rows: 2.6rem 2.6rem 2.6rem;
  gap: .2rem;
}
.arcade-dpad .btn { min-width: 0; min-height: 2.5rem; padding: 0; font-size: 1.05rem; }
.arcade-dpad [data-act="up"] { grid-column: 2; grid-row: 1; }
.arcade-dpad [data-act="left"] { grid-column: 1; grid-row: 2; }
.arcade-dpad [data-act="right"] { grid-column: 3; grid-row: 2; }
.arcade-dpad [data-act="down"] { grid-column: 2; grid-row: 3; }
.arcade-action { min-width: 4.6rem; min-height: 3.2rem; font-weight: 800; }
.mini-stage {
  flex: 1 1 auto;
  min-height: 12rem;
  min-width: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mini-grid {
  display: grid;
  gap: .28rem;
  margin: .2rem auto;
  max-width: 22rem;
  touch-action: manipulation;
}
.mini-cell, .pair-cell, .path-cell, .pop-cell, .mole-cell, .odd-cell, .flood-cell, .pipe-cell, .order-cell, .seq-pad {
  min-height: 2.4rem;
  min-width: 2.4rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--line, #c9a227) 55%, transparent);
  background: color-mix(in srgb, var(--bg-elev, #1a241c) 80%, #000);
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
.pair-cell.is-up, .pair-cell.is-got { background: #efe4c4; color: #1b1208; }
.pair-cell.is-got { outline: 2px solid #c9a227; }
.path-cell.is-end { font-weight: 900; box-shadow: inset 0 0 0 2px #fff6d0; }
.path-cell.is-path { filter: brightness(1.15); }
.arcade-veil {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem;
  background: color-mix(in srgb, #0b0f0e 62%, transparent);
  color: #fff6d0;
  z-index: 4;
  text-align: center;
  padding: 1rem;
}
body.in-game .play-wrap:has(.arcade-shell),
body.in-game .play-wrap:has(.mini-shell) {
  display: flex; flex-direction: column; overflow: hidden;
  /* Pad dock, not the wrap, reserves --host-safe-bottom (same as console). */
  padding-bottom: 0;
}
body.in-game .play-wrap:has(.arcade-shell) .game-mount,
body.in-game .play-wrap:has(.mini-shell) .game-mount {
  flex: 1 1 auto; min-height: 0; min-width: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
@media (max-width: 900px) {
  .arcade-dpad { grid-template-columns: 2.4rem 2.4rem 2.4rem; grid-template-rows: 2.4rem 2.4rem 2.4rem; }
  .mini-cell, .pair-cell, .path-cell, .pop-cell, .mole-cell, .odd-cell, .flood-cell, .pipe-cell, .order-cell, .seq-pad {
    min-height: 2.15rem; min-width: 2.15rem;
  }
}
@media (orientation: portrait) and (max-height: 700px) {
  .arcade-stage { min-height: 8rem; }
  .arcade-dpad { grid-template-columns: 2.2rem 2.2rem 2.2rem; grid-template-rows: 2.2rem 2.2rem 2.2rem; }
  .arcade-dpad .btn { min-height: 2.2rem; font-size: 1rem; }
  .arcade-stage[data-compact="1"] {
    width: min(14rem, 100%, calc(100dvh - 24rem));
    max-width: 14rem;
    max-height: min(14rem, calc(100dvh - 24rem));
    margin: .2rem auto;
  }
  /* Difficulty/level toolbar must stay one row or it eats the pad on 360×640. */
  .arcade-hud { flex-wrap: nowrap; align-items: center; }
  .arcade-hud .puzzle-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    gap: .25rem;
  }
  .arcade-hud .puzzle-toolbar .btn {
    flex: 0 0 auto;
    min-height: 2rem;
    padding-inline: .45rem;
    font-size: .75rem;
    white-space: nowrap;
  }
}
@media (max-width: 400px) {
  .arcade-hud .puzzle-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    gap: .25rem;
  }
  .arcade-hud .puzzle-toolbar .btn {
    flex: 0 0 auto;
    min-height: 2rem;
    padding-inline: .45rem;
    font-size: .75rem;
    white-space: nowrap;
  }
}

/* Shared level map + daily challenge (2.1) */
.level-map {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  padding: .2rem .1rem;
}
.level-map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  flex: 0 0 auto;
}
.level-map-head h2 { margin: 0; font-size: 1.05rem; flex: 1 1 auto; }
.level-pager { display: flex; align-items: center; gap: .35rem; }
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr));
  gap: .28rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 8rem;
  padding-bottom: max(.4rem, calc(env(safe-area-inset-bottom, 0px) + var(--host-safe-bottom, 2.6rem)));
}
.level-cell {
  min-height: 2.5rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--line, #c9a227) 55%, transparent);
  background: color-mix(in srgb, var(--bg-elev, #1a241c) 80%, #000);
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: .78rem;
  cursor: pointer;
  touch-action: manipulation;
}
.level-cell.is-cur { outline: 2px solid #f3e0a0; }
.level-cell.is-cleared { background: color-mix(in srgb, #2e8a4a 45%, #1a241c); }
.level-cell.is-locked { opacity: .45; cursor: default; }
.level-map-veil {
  position: absolute; inset: 0; z-index: 6;
  background: color-mix(in srgb, #0b0f0e 88%, transparent);
  display: flex; flex-direction: column; overflow: hidden;
  padding: .4rem;
}
