/* Brick Shuffle. Snack Quests palette: plum, purple, aqua, yellow, mist.
   Fonts match the storefront: Bebas Neue and Atkinson Hyperlegible. */
:root {
  --plum: #411d4b;
  --purple: #77398e;
  --aqua: #93ccd3;
  --yellow: #e3db49;
  --mist: #dff0f2;
  --tray: #2b1033;
  --display: "Bebas Neue", "Oswald", Impact, "Arial Narrow", sans-serif;
  --body: "Atkinson Hyperlegible", Verdana, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--plum); color: var(--mist); font-family: var(--body); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.sq-studio { font-family: var(--display); font-size: 1.4rem; letter-spacing: 0.05em; color: var(--yellow); text-decoration: none; }
.sq-studio.small { font-size: 1.15rem; }
.sq-studio:hover { color: var(--aqua); }

/* ---------- opening panel ---------- */
#sq-open { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 18px 20px; }
.sq-howto { margin: auto; max-width: 30rem; text-align: center; }
.eyebrow { font-family: var(--display); letter-spacing: 0.12em; color: var(--aqua); margin: 0 0 4px; font-size: 1.2rem; }
.sq-howto h1 { font-family: var(--display); font-weight: 400; font-size: clamp(3.4rem, 14vw, 5.5rem); line-height: 1; margin: 0 0 12px; color: var(--yellow); letter-spacing: 0.02em; }
.sq-howto p { line-height: 1.5; margin: 0 0 12px; }
.sq-howto .hint { color: var(--aqua); font-size: 0.95rem; }

.btn-play, .controls button {
  font-family: var(--display); font-size: 1.5rem; letter-spacing: 0.06em; font-weight: 400;
  background: var(--yellow); color: var(--plum); border: 0; border-radius: 6px;
  padding: 8px 22px; cursor: pointer; box-shadow: 0 4px 0 rgba(20, 6, 26, 0.5);
}
.btn-play:active, .controls button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(20, 6, 26, 0.5); }
.btn-play:hover, .controls button:hover:not(:disabled) { background: var(--aqua); }
.btn-play { font-size: 1.9rem; padding: 10px 40px; margin-top: 8px; }

/* ---------- game ---------- */
#game-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 12px 18px; }
#hud { width: 100%; max-width: 620px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.hud-stats { display: flex; gap: 18px; }
.hud-label { font-family: var(--display); font-size: 1.3rem; letter-spacing: 0.06em; color: var(--aqua); }
.hud-label b { font-weight: 400; color: var(--yellow); }
.hint-line { margin: 4px 0 10px; font-size: 0.95rem; color: var(--mist); text-align: center; max-width: 30rem; }

#board { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; margin: calc(var(--skirt, 0px) + 4px) 0 calc(var(--skirt, 0px) + 14px); }

/* the floor the bricks sit on, fenced in by the skirting board from the mouse game */
.tray {
  position: absolute; inset: 0;
  background-color: var(--tray);
  background-image:
    linear-gradient(rgba(147, 204, 211, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(147, 204, 211, 0.07) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.55);
}
.skirting {
  position: absolute; inset: calc(var(--skirt) * -1); pointer-events: none;
  border: var(--skirt) solid transparent;
  border-image: url("../assets/skirting-wood.png") 160 round;
}

.piece { position: absolute; left: 0; top: 0; cursor: grab; touch-action: none; transition: transform 0.14s ease-out; will-change: transform; }
.piece.drag { cursor: grabbing; z-index: 5; }
.piece .face {
  position: absolute; inset: 2px; border-radius: 9%;
  background-color: var(--c);
  background-image: radial-gradient(circle closest-side at 50% 50%, var(--hi) 0 58%, var(--lo) 62% 82%, transparent 86%);
  background-size: calc(100% / var(--sx)) calc(100% / var(--sy));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 3px 5px rgba(0, 0, 0, 0.45);
}
.piece.drag .face { transform: scale(1.04); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 8px 14px rgba(0, 0, 0, 0.55); }

/* One arrow per colored bar, just outside the wood on the side that bar exits. */
.arrow { position: absolute; left: 0; top: 0; z-index: 2; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.arrow::before { content: ""; position: absolute; inset: 2px 2px 2px 6px; border-radius: 9%; background: var(--c); box-shadow: inset 0 3px 0 rgba(255,255,255,0.35), inset 0 -4px 0 rgba(0,0,0,0.22), 0 3px 5px rgba(0,0,0,0.45); }
.arrow i { position: relative; width: 0; height: 0; border-top: calc(var(--cell) * 0.2) solid transparent; border-bottom: calc(var(--cell) * 0.2) solid transparent; border-left: calc(var(--cell) * 0.3) solid var(--ink, var(--plum)); margin-left: 4px; opacity: 0.85; }
.arrow.left::before { inset: 2px 6px 2px 2px; }
.arrow.left i { border-left: 0; border-right: calc(var(--cell) * 0.3) solid var(--ink, var(--plum)); margin-left: 0; margin-right: 4px; }
.arrow.up::before { inset: 6px 2px 2px 2px; }
.arrow.down::before { inset: 2px 2px 6px 2px; }
.arrow.up i, .arrow.down i { border-left: calc(var(--cell) * 0.2) solid transparent; border-right: calc(var(--cell) * 0.2) solid transparent; margin-left: 0; }
.arrow.up i { border-bottom: calc(var(--cell) * 0.3) solid var(--ink, var(--plum)); border-top: 0; margin-bottom: 4px; }
.arrow.down i { border-top: calc(var(--cell) * 0.3) solid var(--ink, var(--plum)); border-bottom: 0; margin-top: 4px; }
.arrow.lit::before { outline: 2px solid var(--yellow); outline-offset: 1px; }
.arrow.lit i { opacity: 1; }

.shard {
  position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; border-radius: 4px;
  background-color: var(--c);
  background-image: linear-gradient(160deg, var(--hi), var(--c) 45%, var(--lo));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 2px 4px rgba(0, 0, 0, 0.4);
  animation: brick-break 0.55s ease-out forwards;
}
@keyframes brick-break {
  0% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) rotate(var(--rot)) scale(0.55); }
}

.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.controls button { font-size: 1.25rem; padding: 6px 16px; }
.controls button:disabled { opacity: 0.45; cursor: default; }

#overlay { position: fixed; inset: 0; background: rgba(43, 16, 51, 0.82); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20; }
.overlay-panel { background: var(--purple); border: 3px solid var(--aqua); border-radius: 10px; padding: 24px 28px; text-align: center; max-width: 22rem; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); }
.overlay-panel h2 { font-family: var(--display); font-weight: 400; font-size: 2.8rem; margin: 0 0 6px; color: var(--yellow); letter-spacing: 0.03em; }
.overlay-panel p { margin: 0 0 14px; color: var(--mist); }

@media (prefers-reduced-motion: reduce) {
  .piece { transition: none; }
  .shard { animation: none; opacity: 0; }
}
