.match-page {
  min-height: 100dvh;
  color: #233d57;
  background: radial-gradient(ellipse at 16% 10%, #fff5da, transparent 58%),
    radial-gradient(ellipse at 89% 18%, #d9f4f1, transparent 67%), #e9f4fd;
}
.match-page .merge-nav { background: transparent; border-color: #b7d6df; }
.match-page .merge-nav .wordmark { color: #28415c; }
.match-page .merge-directory, .match-page .merge-nav-button { color: #274562; }
.match-page .merge-nav-button { border-color: #b0cbdc; background: #edf6fb; }
.match-page .wallet-button { border-color: #d9bc80; background: #fff2cf; }
.match-page .game-tool[aria-pressed="true"] { border-color: #ddb773; background: #ffde9d; color: #643c19; }

.match-layout {
  width: min(calc(100% - 2rem), 65rem);
  margin: auto;
  padding: clamp(.45rem, 1.3vw, .85rem) 0 1.8rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .45rem .42rem;
}
.match-intro, .match-play { grid-column: 1 / -1; }
.match-intro { display: flex; align-items: end; justify-content: space-between; gap: .8rem; }
.match-intro h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3.8vw, 2.55rem);
  line-height: 1.06;
  font-weight: 860;
  letter-spacing: -.045em;
}
.match-intro em { font-style: normal; color: #be5c38; }
.match-series { margin: 0 0 .12rem; color: #2d716e; font-size: .76rem; font-weight: 780; letter-spacing: .13em; }
.match-intro > p { margin: 0 0 .08rem; color: #456078; font-size: .88rem; }
.match-mode-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.match-modes { display: flex; align-items: center; gap: .12rem; padding: .19rem; border: 1px solid #a9c8dc; border-radius: .75rem; background: #f7fcff; }
.match-modes button {
  border: 0;
  border-radius: .53rem;
  background: transparent;
  color: #3e5870;
  padding: .39rem .7rem;
  min-height: 36px;
  font: 750 .88rem/1.2 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.match-modes button[aria-pressed="true"] { color: #fff; background: #236699; }
.match-page .campaign-controls { justify-content: flex-end; margin: 0; }
.match-page .campaign-label, .match-page[data-match-mode="daily"] .campaign-controls { display: none; }
.match-page[data-match-mode="daily"] .match-mode-bar { grid-column: 1 / -1; }
.match-page .campaign-actions { gap: .35rem; }
.match-page .campaign-actions .merge-button { min-height: 38px; padding-inline: .58rem; white-space: nowrap; font-size: .79rem; }
.match-page .campaign-open { background: #ffe4aa; color: #643f1c; border-color: #dabc88; }
.match-page .campaign-rank, .match-page .match-subtle { background: #f4faff; border-color: #abc9dd; color: #2e526f; }
.match-page .campaign-rank::before { color: #92622b; }

.match-play { display: grid; align-items: start; grid-template-columns: minmax(0, 1.24fr) minmax(16.5rem, .86fr); gap: clamp(.6rem, 1.8vw, 1.25rem); }
.match-machine {
  min-width: 0;
  padding: .6rem .68rem;
  border: 1px solid #b0cedd;
  border-radius: 1.05rem;
  background: #fffdf6;
  box-shadow: 0 .65rem 1.55rem #4d759c23;
}
.match-round { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin: 0 0 .3rem; }
.match-round h2 { margin: 0; color: #24435e; font-size: clamp(.96rem, 2.5vw, 1.15rem); line-height: 1.2; }
.match-score { flex: none; color: #536c82; font-size: .75rem; font-variant-numeric: tabular-nums; }
.match-score strong { color: #205275; }
.match-dashboard { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: stretch; gap: .4rem; margin: 0 0 .38rem; }
.match-dashboard small { display: block; color: #46627c; font-size: .7rem; font-weight: 735; }
.match-moves {
  min-width: 4.1rem;
  border: 1px solid #e9cb87;
  border-radius: .6rem;
  padding: .18rem .38rem;
  text-align: center;
  background: #fff0cc;
}
.match-moves strong { display: block; color: #85441c; line-height: 1.15; font-size: clamp(1.1rem, 3.6vw, 1.38rem); font-variant-numeric: tabular-nums; }
.match-moves[data-low="true"] { background: #ffe1cf; }
.match-moves[data-low="true"] strong { color: #a2372a; }
.match-goal-box { border: 1px solid #c1dbe8; border-radius: .6rem; min-width: 0; background: #eaf6fb; padding: .18rem .48rem; }
.match-goal-box ul { display: flex; flex-wrap: wrap; gap: .18rem .6rem; list-style: none; margin: .13rem 0 0; padding: 0; }
.match-goal { display: flex; gap: .24rem; align-items: center; color: #2c4d69; line-height: 1; font-size: .82rem; font-weight: 740; }
.match-goal strong { min-width: 1.1em; font-variant-numeric: tabular-nums; font-size: 1.05em; }
.match-goal[data-cleared="true"] { color: #186f55; }
.match-goal-icon {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: .34rem;
  background: var(--face, none) center / contain no-repeat;
  font-weight: 850;
}
.match-goal-icon[data-type="lamp"] { background: #ffe6a1; color: #7b501b; }
.match-goal-icon[data-type="crate"] { background: #ba804d; color: #fff5df; }

.match-frame {
  position: relative;
  padding: .43rem;
  border: 1px solid #7da9b9;
  border-radius: .94rem;
  background: #a3cdd7;
  box-shadow: inset 0 0 0 2px #e5f9fc63;
}
.match-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--size, 6), minmax(0, 1fr));
  gap: clamp(.13rem, .45vw, .24rem);
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.match-cell {
  appearance: none;
  position: relative;
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid #a5c7d4;
  border-radius: 18%;
  background: #daedf2;
  box-shadow: inset 0 1px 2px #789aa72c;
  touch-action: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.match-cell[data-checker="true"] { background: #cfe6ee; }
.match-cell.is-hole { visibility: hidden; }
.match-cell[data-lamp="1"], .match-cell[data-lamp="2"] { background: radial-gradient(#fff2b2, #edb460); border-color: #be8142; }
.match-cell[data-lamp="2"] { border: 3px double #996636; }
.match-cell.is-lit { box-shadow: inset 0 0 1rem #e3a84b86; border-color: #c8a476; background: #fff3cd; }
.match-cell[aria-pressed="true"], .match-cell.is-drag-target { outline: 2px solid #22619c; outline-offset: -2px; background: #edf9ff; }
.match-cell.is-pressed .match-piece { scale: .93; }
.match-cell.is-hint-from, .match-cell.is-hint-to { outline: 2px solid #be7c24; outline-offset: -2px; background: #fff4cc; }
.match-cell.is-hint-from { z-index: 2; box-shadow: 0 0 .65rem #f4c46c; animation: match-hint 1.18s ease-in-out infinite; }
.match-cell.is-hint-to { outline-style: dashed; }
.match-cell:focus-visible, .match-skill:focus-visible, .match-modes button:focus-visible { outline: 2px solid #1c4a98; outline-offset: 2px; z-index: 4; }
.match-board[data-power="h"] .match-cell:not(.is-hole) { cursor: crosshair; border-color: #bc8257; }
.match-board[data-power="w"] .match-cell:not(.is-hole) { cursor: crosshair; border-color: #247f77; }
.match-direction {
  position: absolute;
  z-index: 5;
  left: var(--hint-x);
  top: var(--hint-y);
  transform: translate(-50%, -50%) rotate(var(--hint-angle));
  display: grid;
  place-items: center;
  width: clamp(1.32rem, 5vw, 1.85rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid #fff3cf;
  background: #ac5629;
  box-shadow: 0 .11rem .42rem #542f2860;
  color: #fff8df;
  pointer-events: none;
}
.match-direction i { font: 850 clamp(.9rem, 4.1vw, 1.21rem)/1 var(--sans); font-style: normal; animation: match-arrow 1s ease-in-out infinite; }
@keyframes match-arrow { 35% { translate: 10% 0; } }

.match-piece { display: grid; place-items: center; position: relative; width: 94%; aspect-ratio: 1; pointer-events: none; }
.match-face {
  position: absolute;
  inset: 0;
  background: var(--face, none) center / contain no-repeat;
  filter: drop-shadow(0 .095rem .075rem #31547169);
}
.match-piece[data-color="1"], .match-goal-icon[data-color="1"] { --face: url("match3/bear.webp"); }
.match-piece[data-color="2"], .match-goal-icon[data-color="2"] { --face: url("match3/dachui.webp"); }
.match-piece[data-color="3"], .match-goal-icon[data-color="3"] { --face: url("match3/turtle.webp"); }
.match-piece[data-color="4"], .match-goal-icon[data-color="4"] { --face: url("match3/chuimei.webp"); }
.match-piece[data-color="5"], .match-goal-icon[data-color="5"] { --face: url("match3/cat.webp"); }
.match-piece[data-color="6"], .match-goal-icon[data-color="6"] { --face: url("match3/rabbit.webp"); }
.match-piece i {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  padding: .13em .26em;
  border: 1px solid #fff0bd;
  border-radius: .38em;
  background: #243955;
  color: #fff5d8;
  font: 860 clamp(.72rem, 3vw, 1.12rem)/1.04 var(--sans);
}
.match-piece[data-device="4"] .match-face { inset: 9%; border: 2px solid #fff4ce; border-radius: 50%; background: conic-gradient(#ffcf64, #ea6c97, #9b7ceb, #5bdac4, #f3dc68); }
.match-crate {
  width: 86%;
  aspect-ratio: 1;
  border-radius: 15%;
  display: grid;
  place-items: center;
  color: #fff2d0;
  font-size: clamp(.9rem, 4vw, 1.45rem);
  font-weight: 800;
  background: repeating-linear-gradient(0deg, #ffffff1b 0 2px, transparent 2px 8px), linear-gradient(138deg, #ce965f, #996139);
  border: 2px solid #a77348;
  box-shadow: inset 0 0 0 2px #ffd29a72, 0 .13rem .18rem #35536562;
}
.match-crate[data-hard="true"] { border-style: double; border-width: 4px; }
.match-feedback {
  position: absolute;
  z-index: 8;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #824118;
  background: #fff3d2f5;
  white-space: nowrap;
  border: 1px solid #deae5c;
  border-radius: 2rem;
  padding: .48rem .86rem;
  font-weight: 860;
  font-size: clamp(1.04rem, 4.5vw, 1.47rem);
  box-shadow: 0 .36rem 1rem #4a555a54;
  pointer-events: none;
}
.is-clearing { background: #ffeab2; box-shadow: inset 0 0 .8rem #ffce5e; }
.is-clearing .match-piece { animation: match-pop .16s ease-in both; }
@keyframes match-pop { 55% { opacity: 1; scale: 1.16; } to { opacity: .13; scale: .48; } }
@keyframes match-hint { 50% { box-shadow: 0 0 .22rem #f4c46c; } }

.match-tools { display: flex; flex-wrap: wrap; gap: .38rem; margin-top: .38rem; }
.match-tools button { min-height: 38px; padding-inline: .75rem; font-size: .82rem; }
.match-status { margin: .26rem .05rem 0; color: #395d73; font-size: .8rem; min-height: 1.15em; }
.match-side { min-width: 0; display: grid; gap: .55rem; }
.match-scene { position: relative; overflow: hidden; min-width: 0; border: 1px solid #86aaba; border-radius: .97rem; background: #cbdce9; }
.match-scene img { display: block; width: 100%; height: auto; object-fit: cover; }
.match-scene > div { position: absolute; inset: auto .64rem .56rem; }
.match-scene span { display: inline-block; padding: .22rem .48rem; border-radius: .35rem; background: #234051e8; color: #fff3ce; font-size: .76rem; font-weight: 730; }
.match-help { padding: .14rem .52rem .34rem; border: 1px solid #b8d4e5; border-radius: .67rem; background: #f7fcff; color: #3c5d77; font-size: .8rem; }
.match-help summary { cursor: pointer; font-weight: 765; min-height: 32px; padding: .28rem 0; }
.match-help p { margin: .24rem 0 .12rem; }
.match-help a { color: #145a8d; text-decoration: underline; text-underline-offset: .17em; }
.match-example { display: flex; align-items: center; gap: .5rem; padding: .4rem; background: #fff1d3; border-radius: .52rem; color: #694928; }
.match-example > div { display: flex; flex: none; }
.match-example img { width: 1.55rem; height: auto; }
.match-helpers summary > span { margin-left: .42rem; color: #1d704e; }
.match-machine .match-helpers { margin-top: .36rem; }
.match-skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .36rem; }
.match-skill {
  display: grid;
  grid-template-columns: 2.05rem minmax(0,1fr) auto;
  align-items: center;
  gap: .36rem;
  padding: .3rem .42rem;
  text-align: left;
  border: 1px solid #abc9dd;
  border-radius: .6rem;
  background: #e9f5fb;
  color: #233e5d;
  font: inherit;
  cursor: pointer;
}
.match-skill:disabled { opacity: 1; cursor: default; }
.match-skill img { display: block; width: 100%; height: auto; }
.match-skill strong, .match-skill small { display: block; }
.match-skill strong { font-size: .82rem; line-height: 1.15; }
.match-skill small { color: #4b647a; font-size: .68rem; line-height: 1.15; }
.match-skill b { color: #80511e; font-size: .73rem; font-variant-numeric: tabular-nums; }
.match-skill progress { display: block; width: 100%; height: .3rem; margin-top: .2rem; accent-color: #cd8b34; }
.match-skill[data-match-power="w"] progress { accent-color: #358279; }
.match-skill[data-ready="true"] { border-color: #d0a759; background: #fff2d0; }
.match-skill[data-match-power="w"][data-ready="true"] { border-color: #76b3a4; background: #e3f7ee; }
.match-skill[aria-pressed="true"] { outline: 2px solid #215d8f; outline-offset: 1px; }
.match-skill-note { font-size: .72rem; color: #4e6b82; }
.match-guide {
  margin: 0;
  padding: .55rem .72rem;
  border: 1px solid #c3dbe8;
  border-radius: .75rem;
  background: #f8fdff;
  color: #33546d;
  font-size: .83rem;
  line-height: 1.5;
}
.match-tips {
  padding: .58rem .72rem;
  border: 1px solid #c3dbe8;
  border-radius: .75rem;
  background: #f8fdff;
  color: #3a5a73;
  font-size: .79rem;
}
.match-tips strong { display: block; margin-bottom: .32rem; color: #24435e; font-size: .83rem; }
.match-tips ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .26rem; }
.match-tips li { display: flex; align-items: baseline; gap: .38rem; }
.match-tips li span {
  flex: none;
  padding: .08rem .36rem;
  border-radius: .35rem;
  background: #e3f2fa;
  color: #1f557d;
  font-weight: 760;
  font-size: .73rem;
}
.match-modal { width: min(calc(100vw - 1.25rem), 33rem); }
.match-modal tr.is-mine { background: #e9f6ef; }

.match-page .game-screen { --game-screen-width: 34rem; background: #edf7fb; }
.game-focus .match-play { display: block; }
.game-focus .match-side { display: none; }

@media (min-width: 681px) {
  .match-page:not(.game-focus) .match-frame {
    width: min(100%, calc(max(16.5rem, 100dvh - 30.5rem)));
    margin-inline: auto;
  }
}

@media (max-width: 680px) {
  .match-layout { width: min(calc(100% - 1.05rem), 32rem); gap: .34rem .28rem; padding-top: .45rem; }
  .match-intro { display: block; }
  .match-intro > p { margin: .15rem 0 0; font-size: .76rem; }
  .match-play { grid-template-columns: minmax(0,1fr); gap: .46rem; }
  .match-machine { padding: .38rem; border-radius: .86rem; }
  .match-dashboard { gap: .26rem; margin-bottom: .28rem; }
  .match-moves { min-width: 3.7rem; }
  .match-frame { padding: .24rem; }
  .match-skill { grid-template-columns: 1.85rem minmax(0,1fr); padding: .28rem .36rem; gap: .28rem; }
  .match-skill b { grid-column: 1 / -1; justify-self: end; margin-top: -.15rem; }
  .match-skill-note { display: none; }
  .match-side { display: flex; flex-direction: column; }
  .match-scene img { max-height: 9rem; object-position: center 54%; }
}
@media (min-width: 681px) and (max-width: 54rem) and (orientation: portrait) {
  .match-layout { width: min(40rem, calc(100% - 1.5rem)); }
  .match-play { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 355px) {
  .match-modes button { padding-inline: .4rem; font-size: .77rem; }
  .match-page .campaign-actions .merge-button { padding-inline: .37rem; font-size: .71rem; }
  .match-page .campaign-actions { gap: .22rem; }
}
@media (orientation: landscape) and (min-width: 30rem) {
  .game-focus .match-machine :is(.match-round, .match-dashboard, .match-tools, .match-helpers, .match-status) { margin-block: 0; }
}
@media (pointer: coarse) {
  .match-page :is(.campaign-actions .merge-button, .match-modes button, .match-demo, .match-helpers summary) { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .match-cell.is-hint-from, .match-direction i, .is-clearing .match-piece { animation: none; } }
.game-reduced-motion :is(.match-cell.is-hint-from, .match-direction i, .is-clearing .match-piece) { animation: none; }
