:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-strong: #f0f7f4;
  --ink: #1c2420;
  --muted: #68736d;
  --line: #d7ddd7;
  --green: #16805c;
  --green-dark: #0d5f43;
  --amber: #d88416;
  --rose: #cf4d5e;
  --blue: #3774a5;
  --shadow: 0 14px 36px rgba(30, 38, 33, 0.12);
  --board-size: min(86dvh, 980px, 100%);
  --cell-size: clamp(32px, 4.8vmin, 48px);
  --cell-font-size: clamp(0.88rem, 3.1vmin, 1.55rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-mode="mobile"] {
  --board-size: min(78dvh, 620px, 100%);
  --cell-size: clamp(36px, 8.7vmin, 50px);
  --cell-font-size: clamp(1rem, 5.1vmin, 1.62rem);
}

body[data-mode="board"] {
  --board-size: min(88dvh, 1100px, 100%);
  --cell-size: clamp(32px, 3.3vmin, 46px);
  --cell-font-size: clamp(0.9rem, 2.25vmin, 1.45rem);
}

body[data-size="compact"] {
  --board-size: min(76dvh, 600px, 100%);
}

body[data-size="wide"] {
  --board-size: min(87dvh, 1040px, 100%);
}

body[data-size="large"] {
  --board-size: min(89dvh, 1160px, 100%);
}

body[data-mode="mobile"][data-size="compact"] {
  --board-size: min(72dvh, 540px, 100%);
  --cell-size: clamp(36px, 9.2vmin, 52px);
}

body[data-mode="tablet"][data-size="compact"] {
  --cell-size: clamp(32px, 6.4vmin, 46px);
}

body[data-mode="tablet"][data-size="large"],
body[data-mode="board"][data-size="large"] {
  --cell-size: clamp(32px, 3.3vmin, 48px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 244, 239, 0.94)),
    repeating-linear-gradient(90deg, rgba(22, 128, 92, 0.06) 0 1px, transparent 1px 76px),
    repeating-linear-gradient(0deg, rgba(55, 116, 165, 0.055) 0 1px, transparent 1px 76px),
    var(--bg);
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

button {
  border: 0;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font: inherit;
  min-height: 32px;
  padding: 0 10px;
}

button:focus-visible,
.cell:focus-visible {
  outline: 3px solid rgba(55, 116, 165, 0.45);
  outline-offset: 3px;
}

.app-shell {
  width: min(1440px, calc(100vw - 16px));
  height: 100dvh;
  margin: 0 auto;
  padding: 10px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
}

body[data-size="compact"] .app-shell {
  padding: 6px 0;
  gap: 6px;
}

body[data-size="large"] .app-shell {
  width: min(1600px, calc(100vw - 18px));
}

.topbar {
  display: grid;
  grid-template-columns: minmax(124px, 0.6fr) auto auto auto;
  align-items: center;
  gap: 8px;
}

.brand {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green-dark);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.24rem, 2.2vw, 1.9rem);
  line-height: 1;
  letter-spacing: 0;
}

.stats,
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat {
  width: 76px;
  min-height: 38px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 5px 14px rgba(30, 38, 33, 0.05);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 0;
  font-size: 1.03rem;
  line-height: 1;
}

.stat.timer-ending {
  border-color: rgba(207, 77, 94, 0.42);
  background: #fff1f3;
  color: #8f2637;
}

.primary-button {
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.mode-button {
  min-height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  white-space: nowrap;
}

.mode-button.active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 6px 14px rgba(22, 128, 92, 0.16);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  font-weight: 800;
}

.play-surface {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid rgba(28, 36, 32, 0.14);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.96), rgba(240, 247, 244, 0.98)),
    var(--surface-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.line-layer,
.effects-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.line-layer {
  z-index: 4;
}

.effects-layer {
  z-index: 5;
}

.active-path {
  fill: none;
  opacity: 0;
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 8;
}

.active-path.ready {
  stroke-width: 9;
}

.active-path.over-target {
  stroke-width: 8;
}

.board {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  padding: 0;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  min-width: var(--cell-size);
  min-height: var(--cell-size);
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(28, 36, 32, 0.15);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 248, 244, 0.96));
  box-shadow: 0 8px 18px rgba(30, 38, 33, 0.1);
  color: var(--ink);
  cursor: pointer;
  font-size: var(--cell-font-size);
  font-weight: 900;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transform: translate(-50%, -50%);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 999px;
  border: 2px solid transparent;
  pointer-events: none;
}

.cell:hover,
.cell.selected,
.cell.link-target {
  border-color: var(--input-color, rgba(22, 128, 92, 0.6));
  box-shadow: 0 0 0 4px var(--input-glow, rgba(22, 128, 92, 0.18)), 0 12px 24px rgba(30, 38, 33, 0.16);
  transform: translate(-50%, -50%) translateY(-2px);
}

.cell.selected::after {
  border-color: var(--input-color, rgba(22, 128, 92, 0.38));
}

.cell.ready {
  background: #fff7df;
  color: #7a4b08;
  animation: readyCell 500ms ease 2 alternate;
}

.cell.ready::after {
  border-color: rgba(216, 132, 22, 0.66);
}

.cell.over-target {
  background: #fff1f3;
  box-shadow: 0 0 0 3px rgba(207, 77, 94, 0.1), 0 10px 20px rgba(30, 38, 33, 0.12);
}

.cell.locked {
  pointer-events: none;
}

.cell.dragging {
  border-color: rgba(55, 116, 165, 0.75);
  box-shadow: 0 0 0 4px rgba(55, 116, 165, 0.14), 0 14px 26px rgba(30, 38, 33, 0.14);
}

.cell.cleared,
.cell.empty {
  pointer-events: none;
  color: transparent;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: none;
  transform: translate(-50%, -50%) scale(0.88);
}

.cell.correct {
  background: #e4f5ec;
  color: var(--green-dark);
}

.cell.breaking {
  animation: breakTile 420ms ease forwards;
  border-color: rgba(22, 128, 92, 0.78);
  background: #e4f5ec;
  color: var(--green-dark);
  box-shadow: 0 0 0 8px rgba(22, 128, 92, 0.16), 0 16px 32px rgba(22, 128, 92, 0.2);
}

.cell.spawned {
  animation: spawnTile 360ms ease;
}

.cell.wrong {
  animation: wrongShake 240ms ease;
  border-color: rgba(207, 77, 94, 0.7);
  background: #fff1f3;
}

.particle {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--amber);
  opacity: 0;
  box-shadow: 0 0 8px currentColor;
  transform: translate(-50%, -50%);
  animation: particlePop 680ms ease-out forwards;
  will-change: transform, opacity;
}

.success-flash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(216, 132, 22, 0.26), transparent 36%),
    radial-gradient(circle at center, rgba(22, 128, 92, 0.16), transparent 58%);
  opacity: 0;
  animation: successFlash 480ms ease-out forwards;
}

.success-flash.combo {
  background:
    radial-gradient(circle at center, rgba(216, 132, 22, 0.34), transparent 34%),
    radial-gradient(circle at center, rgba(55, 116, 165, 0.2), transparent 62%);
}

.success-flash.fever {
  background:
    radial-gradient(circle at center, rgba(216, 132, 22, 0.44), transparent 32%),
    radial-gradient(circle at center, rgba(207, 77, 94, 0.18), transparent 50%),
    radial-gradient(circle at center, rgba(55, 116, 165, 0.22), transparent 68%);
}

.ready-pop {
  position: absolute;
  display: block;
  width: 66px;
  height: 66px;
  border: 4px solid var(--input-color, var(--amber));
  border-radius: 999px;
  background: rgba(255, 250, 232, 0.92);
  color: #7a4b08;
  font-size: 2rem;
  font-weight: 950;
  line-height: 58px;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
  transform: translate(-50%, -50%) scale(0.7);
  animation: readyPop 560ms ease-out forwards;
}

.success-ring {
  position: absolute;
  width: 74px;
  height: 74px;
  border: 4px solid rgba(22, 128, 92, 0.72);
  border-radius: 999px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.55);
  animation: successRing 660ms ease-out forwards;
}

.score-pop,
.combo-pop {
  position: absolute;
  display: block;
  color: var(--green-dark);
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.88), 0 10px 28px rgba(30, 38, 33, 0.22);
  transform: translate(-50%, -50%) scale(0.72);
  white-space: nowrap;
}

.score-pop {
  font-size: clamp(1.8rem, 5vmin, 3.6rem);
  animation: scorePop 760ms ease-out forwards;
}

.combo-pop {
  color: var(--amber);
  font-size: clamp(1.35rem, 4vmin, 2.75rem);
  animation: comboPop 900ms ease-out forwards;
}

.combo-pop.strong {
  color: #b46400;
}

.combo-pop.fever {
  color: var(--rose);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.88), 0 0 28px rgba(207, 77, 94, 0.28);
}

.miss-pop {
  position: absolute;
  display: block;
  font-size: clamp(1.1rem, 3vmin, 2rem);
  font-weight: 950;
  line-height: 1;
  opacity: 0;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.84);
  transform: translate(-50%, -50%) scale(0.84);
  white-space: nowrap;
  animation: missPop 520ms ease-out forwards;
}

.miss-ring {
  position: absolute;
  width: 66px;
  height: 66px;
  border: 3px solid rgba(207, 77, 94, 0.36);
  border-radius: 999px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.74);
  animation: missRing 420ms ease-out forwards;
}

.spawn-spark {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: radial-gradient(circle, var(--input-glow, rgba(22, 128, 92, 0.18)), transparent 68%);
  border: 2px solid var(--input-color, var(--green));
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  animation: spawnSpark 500ms ease-out forwards;
}

.stat.score-hit {
  animation: statHit 360ms ease;
}

.stat.combo-hit {
  animation: comboHit 420ms ease;
}

.stat.combo-break {
  animation: comboBreak 360ms ease;
}

.lower-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 240px);
  align-items: center;
  gap: 8px;
}

.feedback {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback.success {
  color: var(--green-dark);
}

.feedback.error {
  color: var(--rose);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(28, 36, 32, 0.11);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
  transition: width 220ms ease;
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(-5px);
  }

  70% {
    transform: translateX(5px);
  }
}

@keyframes successFlash {
  0% {
    opacity: 0;
  }

  24% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes readyCell {
  0% {
    transform: translate(-50%, -50%) translateY(-2px) scale(1);
  }

  100% {
    box-shadow: 0 0 0 7px rgba(216, 132, 22, 0.18), 0 14px 28px rgba(216, 132, 22, 0.2);
    transform: translate(-50%, -50%) translateY(-4px) scale(1.05);
  }
}

@keyframes readyPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.62);
  }

  28% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -72%) scale(1);
  }
}

@keyframes successRing {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.5);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(var(--ring-scale, 2));
  }
}

@keyframes scorePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -28%) scale(0.65);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -118%) scale(0.94);
  }
}

@keyframes comboPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.6);
  }

  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(var(--combo-scale, 1.08));
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -120%) scale(0.9);
  }
}

@keyframes missPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.82);
  }

  24% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -78%) scale(0.9);
  }
}

@keyframes missRing {
  0% {
    opacity: 0.75;
    transform: translate(-50%, -50%) scale(0.7);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.55);
  }
}

@keyframes spawnSpark {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45);
  }

  30% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1.08);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

@keyframes statHit {
  0%,
  100% {
    transform: scale(1);
  }

  45% {
    border-color: rgba(22, 128, 92, 0.68);
    box-shadow: 0 0 0 5px rgba(22, 128, 92, 0.14), 0 10px 24px rgba(22, 128, 92, 0.16);
    transform: scale(1.05);
  }
}

@keyframes comboHit {
  0%,
  100% {
    transform: scale(1);
  }

  44% {
    border-color: rgba(216, 132, 22, 0.76);
    box-shadow: 0 0 0 5px rgba(216, 132, 22, 0.18), 0 10px 24px rgba(216, 132, 22, 0.18);
    transform: scale(1.08);
  }
}

@keyframes comboBreak {
  0%,
  100% {
    transform: scale(1);
  }

  48% {
    border-color: rgba(207, 77, 94, 0.48);
    box-shadow: 0 0 0 4px rgba(207, 77, 94, 0.1), 0 8px 20px rgba(207, 77, 94, 0.12);
    transform: scale(0.98);
  }
}

@keyframes breakTile {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.44) rotate(6deg);
  }
}

@keyframes spawnTile {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-18px) scale(0.72);
  }

  60% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(2px) scale(1.08);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0) scale(1);
  }
}

@keyframes particlePop {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.25);
  }
}

@media (max-width: 1100px) and (min-width: 821px) {
  .topbar {
    grid-template-columns: minmax(110px, 0.5fr) auto auto auto;
    gap: 6px;
  }

  .mode-switch {
    grid-column: auto;
  }

  h1 {
    font-size: clamp(1.14rem, 2.1vw, 1.65rem);
  }

  .stat {
    width: 70px;
  }

  .mode-button {
    padding: 0 7px;
    font-size: 0.7rem;
  }

  .actions {
    gap: 8px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 12px, 720px);
    padding: 6px 0;
    gap: 5px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px 6px;
  }

  .brand {
    align-self: center;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(1.08rem, 4.7vw, 1.55rem);
  }

  .stats,
  .mode-switch,
  .actions {
    width: 100%;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-column: 1 / -1;
    gap: 4px;
  }

  .stat {
    width: auto;
    min-height: 32px;
    padding: 4px 6px;
  }

  .stat-label {
    font-size: 0.58rem;
  }

  .stat strong {
    font-size: 0.96rem;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, auto));
    width: auto;
    min-width: 0;
    gap: 4px;
  }

  .mode-switch {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px;
    padding: 2px;
  }

  .mode-button {
    min-height: 28px;
    min-width: 0;
    padding: 0 5px;
    font-size: 0.68rem;
  }

  button {
    min-height: 30px;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .play-surface {
    min-height: auto;
  }

  .board {
    width: 100%;
    height: 100%;
  }

  .lower-panel {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 28vw);
    gap: 6px;
  }

  .feedback {
    min-height: 0;
    font-size: 0.72rem;
    line-height: 1.1;
  }

  .progress-track {
    height: 6px;
  }
}

@media (orientation: landscape) and (max-height: 640px) {
  :root,
  body[data-mode="mobile"],
  body[data-mode="board"],
  body[data-size="compact"],
  body[data-size="wide"],
  body[data-size="large"] {
    --board-size: min(100cqw, 100cqh);
    --cell-size: clamp(26px, 7vmin, 36px);
    --cell-font-size: clamp(0.8rem, 4vmin, 1.18rem);
  }

  .app-shell {
    width: min(100vw - 10px, 1440px);
    padding: 5px 0;
    gap: 5px;
  }

  body[data-size="compact"] .app-shell {
    padding: 4px 0;
    gap: 4px;
  }

  .topbar {
    grid-template-columns: minmax(92px, 0.4fr) auto auto auto;
    gap: 5px;
  }

  .mode-switch {
    grid-column: auto;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(1rem, 3.7vh, 1.35rem);
  }

  .stat {
    width: 64px;
    min-height: 30px;
    padding: 3px 6px;
  }

  .stat-label {
    font-size: 0.54rem;
  }

  .stat strong {
    margin-top: 0;
    font-size: 0.86rem;
  }

  button,
  .mode-button {
    min-height: 28px;
    padding: 0 7px;
    font-size: 0.66rem;
  }

  .mode-switch {
    gap: 3px;
    padding: 3px;
  }

  .actions {
    gap: 6px;
  }

  .lower-panel {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 220px);
    gap: 6px;
  }

  .feedback {
    min-height: 0;
    font-size: 0.68rem;
    line-height: 1.08;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .progress-track {
    height: 5px;
  }
}


/* Pinky NE bundled make10 home link */
.pinky-home-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.74rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.pinky-home-link:hover {
  background: var(--surface-strong);
}

@media (max-width: 820px), (orientation: landscape) and (max-height: 640px) {
  .pinky-home-link {
    min-height: 30px;
    padding: 0 8px;
    font-size: 0.78rem;
  }
}

@media (orientation: landscape) and (max-height: 640px) {
  .pinky-home-link {
    min-height: 28px;
    padding: 0 7px;
    font-size: 0.66rem;
  }
}
