:root {
  color-scheme: light;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #49324f;
  background: #fff2f6;
  --muted: #715a77;
  --line: #ead7e7;
  --berry: #8b365f;
  --panel: #fffcfe;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle, #e8cbe170 1.5px, transparent 2px) 0 0 / 22px 22px,
    radial-gradient(ellipse at 78% 0%, #fff8ce 0, transparent 48%),
    linear-gradient(145deg, #fff0f5, #f3eafd 65%, #eafaf5);
  overscroll-behavior: none;
}

.console {
  width: min(100%, 790px);
  margin: 0 auto;
  padding: 22px max(22px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}
.masthead, .brand, .board-caption, .status { display: flex; align-items: center; }
.masthead { justify-content: space-between; gap: 9px; margin-bottom: 13px; }
.brand { gap: 12px; }
.brand-mark {
  display: grid;
  flex: none;
  grid-template-columns: repeat(3, 9px);
  grid-template-rows: repeat(2, 9px);
  gap: 2px;
  padding: 10px;
  border: 1px solid #e9aac3;
  border-radius: 15px;
  background: #ffdcea;
  box-shadow: 0 3px #eab8d0;
  transform: rotate(-7deg);
}
.brand-mark i { border-radius: 3px; background: #cb618e; box-shadow: inset 0 2px #ffffff75; }
.brand-mark i:first-child { grid-area: 1 / 2; background: #a674d6; }
.brand-mark i:nth-child(2) { grid-area: 2 / 1; }
.brand-mark i:nth-child(3) { grid-area: 2 / 2; background: #e98f70; }
.brand-mark i:nth-child(4) { grid-area: 2 / 3; }
.kicker, h1, h2, p { margin: 0; }
.kicker { color: var(--berry); font-size: 0.78rem; font-weight: 750; letter-spacing: 0.12em; }
h1 { font-size: clamp(1.5rem, 5vw, 2.25rem); line-height: 1.16; letter-spacing: 0.035em; }
.status {
  flex: none;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  color: var(--muted);
  background: #fff9fd;
  font-size: 0.875rem;
  font-weight: 700;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status[data-state="playing"] { color: #336a58; background: #ddf8e9; border-color: #bce5d5; }
.status[data-state="paused"] { color: #75521d; background: #fff0c3; border-color: #efdab0; }
.status[data-state="over"] { color: var(--berry); background: #ffe0ed; border-color: #efc3d5; }

.game-layout {
  display: grid;
  grid-template: "board stats" auto "board controls" 1fr / minmax(0, 1.23fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 19px;
  box-shadow: 0 4px #e7d5e580, 0 10px 24px #803a7410;
  min-width: 0;
}
.board-panel {
  grid-area: board;
  padding: 8px 10px 10px;
  background: repeating-linear-gradient(-45deg, #fff5fa 0 10px, #ffedf5 10px 20px);
}
.board-caption { justify-content: space-between; padding: 2px 5px 7px; color: var(--muted); font-size: 0.875rem; font-weight: 750; }
.dimensions { font: 700 0.82rem var(--mono); }
.playfield {
  position: relative;
  width: min(100%, 304px, max(152px, calc((100vh - 148px) * 0.5)));
  margin: auto;
  border: 2px solid #e5cde6;
  border-radius: 13px;
  overflow: hidden;
  background: #fffafd;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#board { display: block; width: 100%; height: auto; }
#effects { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.celebration {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  max-width: calc(100% - 10px);
  width: max-content;
  padding: 5px 9px;
  border: 1px solid #e4b4d6;
  border-radius: 999px;
  background: #fff5fb;
  color: var(--berry);
  box-shadow: 0 3px #dca2ca55;
  font-size: 0.83rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  animation: pop 240ms ease-out both;
}
@keyframes pop {
  from { transform: translateX(-50%) scale(0.82); opacity: 0.4; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 7px;
  background: #fbecf5ce;
}
.overlay-card {
  width: min(100%, 225px);
  padding: 14px 7px 12px;
  text-align: center;
  border: 2px solid #e9c8dd;
  border-radius: 18px;
  background: #fffaff;
  box-shadow: 0 5px #e9cade, 0 9px 18px #96508018;
}
.overlay-card h2 { font-size: 1.19rem; }
.overlay-card p { margin: 5px 0 10px; color: var(--muted); font-size: 0.85rem; line-height: 1.45; }
.mascot {
  display: block;
  position: relative;
  width: 47px;
  height: 36px;
  margin: 5px auto 8px;
  border: 2px solid #d780a7;
  border-radius: 13px;
  background: #ffcbe1;
  box-shadow: inset 0 4px #fff4fa, 0 3px #f0d0e1;
  transform: rotate(-7deg);
}
.mascot::before, .mascot::after {
  content: "";
  position: absolute;
  top: 14px;
  width: 4px;
  height: 5px;
  border-radius: 50%;
  background: #653651;
}
.mascot::before { left: 11px; box-shadow: -4px 6px 0 1px #ec91b7; }
.mascot::after { right: 11px; box-shadow: 4px 6px 0 1px #ec91b7; }
.mascot i { position: absolute; top: 16px; left: 18px; width: 7px; height: 6px; border-bottom: 2px solid #653651; border-radius: 50%; }

.telemetry { grid-area: stats; display: grid; gap: 10px; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; }
.metric { display: grid; gap: 3px; padding: 10px 13px; }
.metric:nth-child(odd) { border-right: 1px solid var(--line); }
.metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
.metric span { color: var(--muted); font-size: 0.875rem; font-weight: 650; }
.metric strong { font: 750 clamp(1.05rem, 4vw, 1.7rem) var(--mono); overflow-wrap: anywhere; }
.score { background: #ffedf6; }
.score strong { color: var(--berry); }
.preview { display: flex; justify-content: space-between; align-items: center; gap: 7px; padding: 8px 13px; background: #f4ecff; }
.preview h2, .controls h2 { color: var(--muted); font-size: 0.875rem; font-weight: 750; }
#next { display: block; width: 96px; max-width: 100%; height: auto; background: #fffafd; border: 1px dashed #dec9ed; border-radius: 11px; }

.controls { grid-area: controls; padding: 10px; }
.controls h2 { margin-bottom: 7px; }
.direction-controls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.button {
  min-width: 0;
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid #e0cce8;
  border-radius: 12px;
  color: #573860;
  background: #f5eafb;
  box-shadow: inset 0 -3px #7e518515;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}
.button:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 2px #7e51852a; }
.button:focus-visible { outline: 2px solid #8b365f; outline-offset: 2px; }
.button:disabled { color: #786480; cursor: default; }
.primary { background: #f6aaca; border-color: #e28bb1; color: #552840; }
.control { grid-column: span 2; min-height: 52px; padding: 4px 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.control span { display: block; color: #804488; font: 800 1.15rem/1.1 var(--mono); }
.soft, .drop { grid-column: span 3; }
.soft { background: #e1f4ed; border-color: #c4e6dc; }
.drop { background: #ffe1ed; border-color: #edc3d5; }
.session-controls, .sound-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
.session-controls .button { background: #fff5dc; border-color: #edddba; }
.sound { background: #f9f0fb; }
.sound span { margin-right: 0.3em; color: var(--berry); }
.sound[aria-pressed="false"] { background: #fffafd; border-style: dashed; box-shadow: none; }
.sound[aria-pressed="false"] span { color: var(--muted); text-decoration: line-through; }
.help { margin-top: 7px; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
kbd { font-family: var(--mono); color: #59395f; }
.touch-help { display: none; }

@media (max-width: 600px) {
  .console { width: min(100%, 460px); padding: max(9px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .masthead { margin: 0 3px 7px; }
  .brand { gap: 9px; }
  .brand-mark { padding: 7px; }
  .game-layout { grid-template: "stats" "board" "controls" / minmax(0, 1fr); gap: 6px; }
  .telemetry { grid-template-columns: minmax(0, 1fr) 73px; gap: 6px; }
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metric { align-content: center; gap: 2px; padding: 4px 2px; text-align: center; }
  .metric span { font-size: 0.77rem; }
  .metric:nth-child(n) { border-bottom: 0; border-right: 1px solid var(--line); }
  .metric:last-child { border-right: 0; }
  .preview { flex-direction: column; justify-content: center; gap: 1px; padding: 3px; }
  .preview h2 { font-size: 0.77rem; }
  #next { width: 44px; border: 0; }
  .board-panel { padding: 3px 5px 5px; }
  .board-caption { padding: 0 2px 3px; }
  .playfield {
    width: min(100%, 227px, max(150px, calc((100vh - 331px) * 0.5)));
    width: min(100%, 227px, max(150px, calc((100svh - 331px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.5)));
  }
  .controls { padding: 6px; }
  .controls h2 { display: none; }
  .direction-controls { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .control { grid-column: auto; min-height: 48px; padding: 3px 0; }
  .session-controls, .sound-controls { margin-top: 4px; }
  .help { margin-top: 4px; }
}

@media (pointer: coarse) {
  .keyboard-help { display: none; }
  .touch-help { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .celebration { animation: none; }
  .button:active:not(:disabled) { transform: none; }
}

/* 釉面、树脂和糖粉质感也延伸到棋盘外的控制台。 */
body {
  background:
    radial-gradient(ellipse at 18% 8%, #fffdf7 0, #fffdf700 34%),
    radial-gradient(ellipse at 90% 100%, #e1eee6 0, #e1eee600 55%),
    radial-gradient(ellipse at 87% 27%, #eddfed 0, #eddfed00 42%),
    linear-gradient(153deg, #f9e9e8, #f6e5ec 60%, #eee8ec);
}
.panel {
  background-image: linear-gradient(160deg, #ffffffb5, #fffaff00 60%);
  box-shadow: inset 0 1px 1px #fff, 0 2px 0 #d9bdd0, 0 10px 21px #67465c16, 0 18px 45px #77445a0e;
}
.board-panel {
  background:
    linear-gradient(147deg, #fff9f6cf, #fff9f600 32%, #b88ca03b 78%, #fffaf688),
    repeating-linear-gradient(-47deg, #f2d5e2 0 11px, #f8e6ed 11px 23px);
  border-color: #ead0dd;
  box-shadow: inset 0 1px 1px #fffdfc, 0 3px 0 #d2abc0, 0 18px 36px #7c4b642d;
}
.playfield {
  border-color: #dcc1d1;
  box-shadow: inset 0 2px 6px #8f61724d, 0 1px 0 #fff9;
  isolation: isolate;
}
.scene { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
.preview-window { position: relative; flex: none; overflow: hidden; border-radius: 10px; }
#next { border: 1px solid #e7cae5; }
.button {
  background-image: linear-gradient(155deg, #ffffff75, #ffffff00 58%, #5942660b);
  box-shadow: inset 0 1px 1px #fffc, inset 0 -3px #7e518513, 0 1px 1px #6e446c14;
}
.combo-meter {
  --remaining: 1;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid #d8accb;
  background: #f9edf5;
  color: #672b61;
  padding: 2px 8px;
  font-size: 0.78rem;
  line-height: 1.15;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.combo-meter::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: scaleX(var(--remaining));
  transform-origin: left center;
  background: linear-gradient(90deg, #ffcbe0, #dbbef2);
}
.celebration[data-lines="2"] { background: #e6f5fa; border-color: #a8d4e1; color: #3e626d; }
.celebration[data-lines="3"] { background: #efe6ff; border-color: #cbaee9; color: #62417e; }
.celebration[data-lines="4"] { background: #fff1ce; border-color: #e7c079; color: #734917; }
.overlay { background: linear-gradient(155deg, #f9eaf1d9, #eee0edd1); }
.overlay-card {
  background: linear-gradient(150deg, #fffdf9, #fdf1f8 80%, #f8e9f3);
  box-shadow: inset 0 1px 1px white, 0 5px #d9adca, 0 13px 30px #79405c30;
}
.mascot {
  background: radial-gradient(ellipse at 27% 17%, #fff4fa 1%, #ffffff00 24%),
    linear-gradient(145deg, #ffd1e6, var(--mood, #e895b9));
  box-shadow: inset 0 2px 2px #fff7, inset -3px -4px 7px #96486537, 0 4px 6px #7f4c6740;
  transform: rotate(var(--tilt, -7deg)) scale(var(--smile-size, 1));
}
.overlay-card .review {
  margin: 4px auto 12px;
  padding: 6px 5px;
  border: 1px solid #e7cadc;
  border-radius: 11px;
  background: #ffffffac;
  color: #644759;
}
.review strong, .review span { display: block; }
.review strong { color: #713b68; font-size: 0.9rem; }
.review span { margin-top: 3px; font-size: 0.77rem; }
.overlay[data-mood="0"] { --mood: #a995b6; --tilt: -16deg; --smile-size: .79; }
.overlay[data-mood="1"] { --mood: #b3a0d1; --tilt: -13deg; --smile-size: .84; }
.overlay[data-mood="2"] { --mood: #baa9df; --tilt: -10deg; --smile-size: .89; }
.overlay[data-mood="3"] { --mood: #c5a4e3; --tilt: -7deg; --smile-size: .92; }
.overlay[data-mood="4"] { --mood: #dda6db; --tilt: -4deg; --smile-size: .96; }
.overlay[data-mood="5"] { --mood: #eb9dc6; --tilt: 0deg; }
.overlay[data-mood="6"] { --mood: #f0a0b2; --tilt: 4deg; --smile-size: 1.05; }
.overlay[data-mood="7"] { --mood: #f3aa98; --tilt: 7deg; --smile-size: 1.10; }
.overlay[data-mood="8"] { --mood: #f7b589; --tilt: 10deg; --smile-size: 1.16; }
.overlay[data-mood="9"] { --mood: #f9c97f; --tilt: 13deg; --smile-size: 1.22; }
.overlay:is([data-mood="0"], [data-mood="1"], [data-mood="2"]) .mascot i {
  top: 20px;
  border-bottom: 0;
  border-top: 2px solid #653651;
}
.overlay:is([data-mood="0"], [data-mood="1"]) .mascot::after { box-shadow: 3px 6px 0 1px #9fd6e9; }
.overlay:is([data-mood="7"], [data-mood="8"], [data-mood="9"]) .mascot i {
  top: 18px;
  left: 16px;
  width: 11px;
  height: 8px;
  border: 2px solid #743751;
  border-radius: 1px 1px 8px 8px;
  background: #f87da5;
}
.overlay:is([data-mood="8"], [data-mood="9"]) .mascot::before,
.overlay:is([data-mood="8"], [data-mood="9"]) .mascot::after {
  clip-path: polygon(50% 0%, 64% 35%, 100% 50%, 64% 64%, 50% 100%, 37% 64%, 0 50%, 37% 35%);
  width: 9px;
  height: 9px;
  top: 9px;
  background: #883a67;
}
.overlay[data-mood="9"] .mascot { outline: 2px dotted #f4c372; outline-offset: 4px; }
@media (max-width: 600px) {
  .combo-meter { padding: 2px 6px; }
  .overlay-card .review { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .combo-meter::before { transform: none; }
}
