.match-view {
  --match-cream: #fff1d4;
  --match-mist: #c2d4e1;
  color: var(--match-cream);
  --match-field: clamp(500px, calc(100dvh - 215px), 890px);
  max-width: min(1220px, calc(var(--match-field) + 328px));
  min-width: 0;
  margin-inline: auto;
  padding-inline: 12px;
  padding-top: 8px;
}

.match-view *,
.match-view *::before,
.match-view *::after { box-sizing: border-box; }

.match-view [hidden] { display: none !important; }

.match-view__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-block: 0 12px;
}

.match-view__header h1 {
  margin: 0;
  color: var(--match-cream);
  font: 600 clamp(30px, 3.6vw, 42px)/1.05 Georgia, serif;
}

.match-view__navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.match-modes {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid #6c837b;
  border-radius: 9px;
  background: #102629;
}
.match-view .match-modes .match-action { min-height: 38px; border-color: transparent; background: transparent; }
.match-modes .match-action[aria-pressed='true'] {
  border-color: #e6bf77;
  background: #f0d19a;
  color: #442c1d;
}

.match-view[data-station='workshop'], .match-route[data-theme='workshop'] {
  --station-art: url('../art/style/porcelain-studio.png');
  --station-tile: #292330;
  --station-edge: #8b5f75;
}
.match-view[data-station='forest'], .match-route[data-theme='forest'] {
  --station-art: url('../art/style/tree-courtyard.png');
  --station-tile: #15362e;
  --station-edge: #5b9984;
}
.match-view[data-station='post'], .match-route[data-theme='post'] {
  --station-art: url('../art/style/postcard-winter.png');
  --station-tile: #352839;
  --station-edge: #9c7496;
}
.match-view[data-station='aurora'], .match-route[data-theme='aurora'] {
  --station-art: url('../art/final-aurora.png');
  --station-tile: #202c53;
  --station-edge: #777bc4;
}
.match-view[data-mode='expedition'] .match-cabinet__top {
  padding: 8px 10px;
  border-radius: 7px;
  background: linear-gradient(90deg, #121c29f5 20%, #121c2999), var(--station-art) center 46% / cover;
}

.match-view__layout {
  display: grid;
  grid-template-columns: minmax(0, var(--match-field)) minmax(220px, 280px);
  align-items: start;
  justify-content: center;
  gap: 12px clamp(12px, 2vw, 24px);
}

.match-reward {
  min-width: 0;
  padding: 8px 0;
}

.match-reward h2 {
  margin: 0 0 8px;
  color: #ffebc5;
  font: 600 1.14rem/1.2 Georgia, serif;
}

.match-reward__list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.match-reward__list > li { position: relative; min-width: 0; }
.match-reward__tile {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 53px;
  padding: 2px 6px 2px 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--match-cream);
  text-align: start;
  font-size: .86rem;
  line-height: 1.25;
}
.match-reward__tile:is(:hover, :focus-visible) { border-color: #b89460; background: #342820; }
.match-reward__tile small { display: block; margin-top: 3px; color: #ecd2aa; font-size: .76rem; }

.match-reward__art {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 48px;
  border-radius: 5px;
  background: #282525;
}

.match-reward__art :is(img, canvas) { width: 100%; max-height: 48px; object-fit: contain; }
.match-reward__art .gift-art { width: 100%; }
.match-reward__art .snow-coin { width: 60%; }
.match-view .paint-swatch {
  display: block;
  border-radius: 45% 21% 35% 20%;
  background: linear-gradient(135deg, var(--swatch-light), var(--swatch) 44%, var(--swatch-dark));
}
.match-reward__art .paint-swatch { width: 73%; height: 43%; }
.match-reward__art .paint-stencil-sample { width: 90%; }
.match-reward__tile[data-kind='stencils'] .match-reward__art,

.match-reward__peek {
  display: none;
  position: absolute;
  z-index: 15;
  inset: 100% 0 auto auto;
  width: min(275px, calc(100vw - 30px));
  padding: 9px;
  border: 1px solid #cda260;
  border-radius: 8px;
  background: #28221f;
  box-shadow: 0 8px 20px #061018a3;
}
.match-reward__peek canvas { display: block; width: 100%; border-radius: 4px; }
.match-reward__peek p { margin: 7px 0 1px; color: #fff1d4; font-size: .8rem; line-height: 1.35; }
.match-reward__list > li:has(:focus-visible) .match-reward__peek { display: block; }
@media (hover: hover) {
  .match-reward__list > li:hover .match-reward__peek { display: block; }
}
@media (min-width: 801px) {
  .match-reward__peek { inset: 0 100% auto auto; }
}

.match-cabinet {
  border: 1px solid #8e6643;
  border-radius: 15px;
  background: #211a1b;
  box-shadow: 0 14px 28px #040c1485;
  overflow: hidden;
  padding: clamp(6px, 1vw, 12px);
}

.match-cabinet__inside {
  border-radius: 8px;
  background: #141d26;
}

.match-cabinet__top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 29px;
}

.match-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-block: 7px 3px;
}

.match-cabinet__top h2 {
  margin: 0;
  color: var(--match-cream);
  font: 600 clamp(18px, 3vw, 26px)/1.1 Georgia, serif;
}

.match-round__number {
  margin: 0;
  color: #efc780;
  font-size: .79rem;
  font-weight: 700;
}
.match-round { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; }
.match-round h2 { flex-basis: 100%; }
.match-theme { margin: 0; color: var(--match-mist); font-size: .82rem; }
.match-round .match-progress { order: -1; }
.match-round__number { order: -2; }

.match-moves {
  display: grid;
  justify-items: center;
  min-width: clamp(93px, 12vw, 130px);
  padding: 5px 8px;
  border: 1px solid #ffe3a2;
  border-radius: 9px;
  background: #efd096;
  color: #4a2b1d;
  flex-shrink: 0;
  font-size: .72rem;
  font-weight: 720;
  line-height: 1.15;
}

.match-moves strong {
  font-size: clamp(31px, 5vw, 44px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.match-moves--low {
  border-color: #ffb08c;
  background: #862f33;
  color: #fff7ee;
}

.match-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.match-targets li {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid #6a91a87a;
  border-radius: 5px;
  background: #1c2a35;
  color: #cee3f1;
  font-size: clamp(0.67rem, 2.5vw, 0.84rem);
  line-height: 1.15;
}

.match-targets strong { color: #f1faff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.match-targets li[data-goal='ice']::before {
  content: '';
  width: 1.25em;
  height: 1.25em;
  align-self: center;
  background: url('../art/style/match-ice.webp') center / contain no-repeat;
}
.match-targets .match-targets__done { border-color: #c9e3b6; background: #2d5a3f; color: #eefae6; animation: match-done 700ms ease-out both; }
.match-targets .match-targets__done strong::before { content: '✓ '; }
@keyframes match-done {
  0% { transform: scale(1); box-shadow: 0 0 0 0 #e9f7c080; }
  35% { transform: scale(1.12); box-shadow: 0 0 0 6px #e9f7c033; }
  100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
.match-targets .match-targets__done strong { color: #e2f3df; }

.match-stage {
  position: relative;
  display: grid;
  grid-template-areas: 'ribbon' 'board';
  grid-template-rows: minmax(25px, auto) auto;
}
.match-board-shell {
  position: relative;
  grid-area: board;
  display: grid;
  grid-template-areas: 'field';
  padding: 7% 8% 8%;
  min-width: 0;
  background: #0d1925 url('../art/style/match-cabinet.png') center / 110% 107% no-repeat;
  border-radius: 9px;
  box-shadow: 0 7px 15px #05090fb3;
}
.match-board-shell > .match-grid { grid-area: field; }
.match-stage > .match-result {
  grid-area: ribbon;
  position: relative;
  z-index: 5;
  margin: 0 0 7px;
  padding: 6px 11px;
  border: 1px solid #745335;
  border-radius: 5px;
  background: #211c1a;
  color: #ffe8ba;
  text-align: center;
}
.match-stage .match-status { color: #ffebc5; font-size: .88rem; font-weight: 550; line-height: 1.34; }
.match-stage[data-phase='playing'] > .match-result {
  margin: 0;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  text-align: start;
}
.match-verdict { margin: 0; font: 600 clamp(26px, 6vw, 34px)/1.05 Georgia, serif; color: #fff4d6; }

.match-stage:not([data-phase='playing']) > .match-result {
  grid-area: board;
  align-self: center;
  justify-self: center;
  width: min(88%, 380px);
  margin: 0;
  padding: 20px 18px 16px;
  border: 1px solid #e7c27f;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 50% 0%, #b43c3faa, transparent 62%),
    linear-gradient(180deg, #7d2229, #561319);
  color: var(--match-cream);
  clip-path: none;
  box-shadow: 0 14px 34px #02070dcc, inset 0 0 0 3px #4a1015, inset 0 0 0 4px #d9ad6966;
  animation: match-card 320ms cubic-bezier(.2, .9, .3, 1.15) both;
}
.match-stage:not([data-phase='playing']) > .match-result::before {
  content: '';
  display: block;
  width: 46px;
  height: 46px;
  margin: -44px auto 8px;
  border: 2px solid #f6d48e;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff6d6, #f0c46e 40%, #b07a2f);
  box-shadow: 0 0 22px #ffc75f99, 0 3px 6px #0009;
}
.match-stage[data-phase='lost'] > .match-result {
  background: linear-gradient(180deg, #1f3a52, #12263a);
  border-color: #9fc6e0;
  box-shadow: 0 14px 34px #02070dcc, inset 0 0 0 3px #0c1c2b, inset 0 0 0 4px #9fc6e055;
}
.match-stage[data-phase='lost'] > .match-result::before {
  background: radial-gradient(circle at 36% 30%, #f4fbff, #a9d6ef 45%, #4c7d9d);
  border-color: #d5efff;
  box-shadow: 0 0 18px #a9d6ef77, 0 3px 6px #0009;
}
.match-stage:not([data-phase='playing']) .match-status { margin-top: 7px; color: #f6e5c8; font-weight: 400; font-size: .93rem; }
.match-stage:not([data-phase='playing']) .match-result__actions { justify-content: center; margin: 14px 0 0; }
.match-stage:not([data-phase='playing']) .match-result__actions:not(:has(> :not([hidden]))) { display: none; }
.match-stage:not([data-phase='playing']) .match-action { min-height: 44px; padding-inline: 16px; }
.match-stage:not([data-phase='playing']) .match-board-shell { filter: saturate(.64) brightness(.57); transition: filter 250ms; }
@keyframes match-card { from { opacity: 0; transform: translateY(14px) scale(.94); } }

.match-routes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.match-route-choice h3 { margin: 12px 0 0; font: 600 1.1rem Georgia, serif; }
.match-stage[data-phase='won']:has(.match-route-choice:not([hidden])) > .match-result { width: min(94%, 520px); }
.match-view[data-mode='expedition'] .match-result::before { display: none; }
.match-stage[data-phase='won'] .match-route {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px;
  text-align: left;
  border: 1px solid #e8ba7c;
  background: var(--station-tile, #5a2926);
  color: #fff1d4;
  line-height: 1.2;
}
.match-stage .match-route:hover:not(:disabled) { border-color: #fff1bd; box-shadow: inset 0 0 0 1px #fff1bd; }
.match-route__art {
  display: block;
  height: clamp(44px, 8vw, 76px);
  border-radius: 4px;
  background: var(--station-art) center / cover no-repeat;
}
.match-route strong { font-size: .85rem; }
.match-route span { color: #f6ddbb; font-size: .73rem; font-weight: 400; }
.match-route small { color: #ffe2a5; font-size: .71rem; }
.match-expedition-stats p { margin: 7px 0 0; color: var(--match-mist); font-size: .85rem; }
.match-expedition-stats .game-star-reward p { margin: 0; font-size: .8rem; }
.match-expedition-daily { margin-top: 10px; }

.match-combo {
  position: absolute;
  z-index: 6;
  top: 6%;
  right: 7%;
  padding: 4px 11px;
  border: 1px solid #ffe2a0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd47c, #d38d2f);
  color: #3a1907;
  font-weight: 800;
  font-size: .9rem;
  box-shadow: 0 4px 14px #ffb44a66;
  pointer-events: none;
  animation: match-combo-a 520ms cubic-bezier(.2, .9, .3, 1.3) both;
}
.match-combo--even { animation-name: match-combo-b; }
@keyframes match-combo-a { from { opacity: 0; transform: scale(.4) rotate(-8deg); } }
@keyframes match-combo-b { from { opacity: 0; transform: scale(.4) rotate(-8deg); } }

.match-combo[data-special='true'] {
  border-color: #b7ffe2;
  background: linear-gradient(175deg, #d6ffe9, #91d6bb);
  color: #16392f;
  box-shadow: 0 5px 16px #041e1dcc;
}

.match-board-shell > .match-fx {
  position: relative;
  grid-area: field;
  z-index: 4;
  overflow: hidden;
  border-radius: 7px;
  pointer-events: none;
}
.match-flash { position: absolute; inset: 0; }
.match-flash::before,
.match-flash::after { position: absolute; display: block; opacity: 0; }
.match-flash:is([data-kind='row'], [data-kind='cross'])::before {
  content: '';
  inset: auto 0 auto 0;
  top: var(--flash-y);
  height: clamp(7px, 2.8vw, 14px);
  border-radius: 100%;
  background: radial-gradient(ellipse, #fff8cc 5%, #e8ba75 29%, #ecd8997a 50%, transparent 76%);
  animation: match-flash-row 320ms cubic-bezier(.16, 1, .3, 1) both;
}
.match-flash:is([data-kind='column'], [data-kind='cross'])::after {
  content: '';
  inset: 0 auto 0 var(--flash-x);
  width: clamp(7px, 2.8vw, 14px);
  border-radius: 100%;
  background: radial-gradient(ellipse, #fff8cc 5%, #e8ba75 29%, #ecd8997a 50%, transparent 76%);
  animation: match-flash-column 320ms cubic-bezier(.16, 1, .3, 1) both;
}
.match-flash:is([data-kind='star'], [data-kind='stars'])::before {
  content: '';
  top: var(--flash-y);
  left: var(--flash-x);
  width: 52%;
  aspect-ratio: 1;
  border: 2px solid #fff3ce;
  border-radius: 50%;
  background: radial-gradient(circle, #fff1b94c, #cf97e72c 50%, transparent 70%);
  box-shadow: inset 0 0 16px #c79bd666, 0 0 19px #edbaee66;
  animation: match-flash-ring 350ms cubic-bezier(.16, 1, .3, 1) both;
}
.match-flash[data-kind='stars']::before { width: 86%; }
.match-flash[data-kind='lantern']::before,
.match-flash[data-kind='lantern']::after {
  content: '';
  top: var(--flash-y);
  left: var(--flash-x);
  width: 118%;
  height: clamp(11px, 3.8vw, 20px);
  border-radius: 100%;
  background: radial-gradient(ellipse, #fff8d6 4%, #d2ffe3 27%, #68d5b9ab 54%, transparent 75%);
  animation: match-flash-beam 390ms cubic-bezier(.16, 1, .3, 1) both;
}
.match-flash[data-kind='lantern']::before { --flash-angle: 45deg; }
.match-flash[data-kind='lantern']::after { --flash-angle: -45deg; }
.match-fx--paused .match-flash::before,
.match-fx--paused .match-flash::after,
.match-grid--paused .match-tile::after { animation-play-state: paused; }
@keyframes match-flash-row {
  from { opacity: 1; transform: translateY(-50%) scaleX(.24); }
  to { opacity: 0; transform: translateY(-50%) scaleX(1); }
}
@keyframes match-flash-column {
  from { opacity: 1; transform: translateX(-50%) scaleY(.24); }
  to { opacity: 0; transform: translateX(-50%) scaleY(1); }
}
@keyframes match-flash-ring {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.12); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.04); }
}
@keyframes match-flash-beam {
  from { opacity: 1; transform: translate(-50%, -50%) rotate(var(--flash-angle)) scaleX(.1); }
  37% { opacity: .9; }
  to { opacity: 0; transform: translate(-50%, -50%) rotate(var(--flash-angle)) scaleX(1); }
}

.match-lantern {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 4px 0 0;
  padding: 6px 10px;
  border: 1px solid #83613e;
  border-radius: 7px;
  background: linear-gradient(165deg, #37251e, #201e22 75%);
  color: #ffebc9;
  text-align: left;
  box-shadow: inset 0 1px 0 #efc28930;
}
.match-lantern:enabled { border-color: #d7be82; color: #fff5d5; }
.match-lantern:enabled:hover,
.match-lantern[aria-pressed='true'] { background: linear-gradient(165deg, #533221, #2b2023 75%); }
.match-lantern:focus-visible { outline: 2px solid #ffdc94; outline-offset: 3px; }
.match-lantern__lamp {
  justify-self: center;
  width: 41px;
  aspect-ratio: 1;
  background: url('../art/style/match-specials.png') 100% 100% / 200% 200% no-repeat;
  filter: saturate(.45) brightness(.75);
}
.match-lantern[data-ready='true'] .match-lantern__lamp {
  filter: drop-shadow(0 2px 5px #f7bd4c8f);
}
.match-lantern__body { display: grid; gap: 4px; min-width: 0; }
.match-lantern__body strong { font: 600 clamp(.91rem, 3.9vw, 1.06rem)/1.16 Georgia, serif; }
.match-lantern__rail {
  position: relative;
  display: block;
  overflow: hidden;
  width: min(100%, 15rem);
  height: 5px;
  border-radius: 2px;
  background: #190f13;
}
.match-lantern__rail::before,
.match-lantern__rail::after { content: ''; position: absolute; inset: 0; }
.match-lantern__rail::before {
  width: var(--lantern-charge, 0%);
  background: linear-gradient(90deg, #c0823d, #ffe2a1);
  transition: width 180ms ease-out;
}
.match-lantern__rail::after { background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 6 - 2px), #190f13 0 calc(100% / 6)); }
.match-lantern__intent { color: #e3c88a; font-size: .79rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.match-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(2px, .34vw, 4px);
  isolation: isolate;
  touch-action: none;
  user-select: none;
}

.match-tile {
  appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  width: 100%;
  padding: 0;
  aspect-ratio: 1;
  border: 1px solid var(--station-edge, #4d5a659e);
  border-radius: 6px;
  background: var(--station-tile, #0d1a26);
  box-shadow: inset 0 2px 4px #07111c;
  color: #fff6e1;
  cursor: pointer;
  font: inherit;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.match-grid--ended .match-tile { cursor: default; }
.match-grid--paused .match-tile { cursor: default; }

.match-tile[data-ice='1'],
.match-tile[data-ice='2'] {
  border-color: #a4d5ee;
  background: radial-gradient(ellipse at right bottom, #416174, var(--station-tile, #132737) 76%);
}

.match-tile[data-ice='2'] {
  background: radial-gradient(ellipse at right bottom, #47727d, #173044 80%);
  box-shadow: inset 0 0 0 2px #b3e5fabb;
}

.match-tile:focus-visible { outline: 2px solid white; outline-offset: 2px; z-index: 4; }
.match-tile[aria-pressed='true'] { outline: 2px solid #ffd27c; outline-offset: -2px; z-index: 2; }
.match-tile[aria-pressed='true']:focus-visible { outline-color: #fff4c9; outline-offset: 2px; }
.match-tile--hint { outline: 2px dashed #ffe8b5; outline-offset: -3px; z-index: 2; }
.match-tile--hint .match-piece { animation: match-nudge 1.55s ease-in-out infinite; }
.match-tile--coach {
  border-color: #ffe1a3;
  box-shadow: inset 0 0 0 2px #ffd27c, 0 2px 12px #ffcf7a88;
  z-index: 2;
}
.match-tile--coach .match-piece { animation: match-coach-swap 1.45s ease-in-out infinite; }
@keyframes match-coach-swap {
  0%, 62%, 100% { transform: none; }
  30% { transform: translate(calc(22% * var(--match-x)), calc(22% * var(--match-y))) scale(1.06); }
}
@keyframes match-nudge {
  0%, 74%, 100% { transform: none; }
  33% { transform: translateY(-9%) scale(1.08); filter: brightness(1.18); }
  58% { transform: translateY(-2%) scale(1.03); }
}
.match-tile--aimed { outline: 2px solid #ffedba; outline-offset: -2px; z-index: 2; }
.match-stage[data-lantern='true'] .match-tile { cursor: crosshair; }
.match-tile--lantern,
.match-tile--linked { outline: 2px solid #a7f2ce; outline-offset: -3px; }
.match-tile--lantern { box-shadow: inset 0 0 11px #d4ffbe80; }
.match-tile--linked { outline-style: dashed; }
.match-tile--lantern:focus-visible,
.match-tile--linked:focus-visible { outline-color: #fff8da; outline-offset: 2px; }

.match-piece,
.match-color-mark,
.match-targets li[data-match-piece]::before,
.match-goal-list li[data-match-piece]::before {
  background: url('../art/style/match-toys.png') var(--toy-x, 0%) var(--toy-y, 0%) / 300% 200% no-repeat;
  pointer-events: none;
}
.match-targets li[data-match-piece]::before,
.match-goal-list li[data-match-piece]::before {
  content: '';
  width: 1.25em;
  height: 1.25em;
  flex: none;
  align-self: center;
  border-radius: 3px;
}
.match-piece {
  position: relative;
  width: 113%;
  height: 113%;
}
:is(.match-tile[data-kind='1'], .match-tile[data-kind='4'], [data-match-piece='1'], [data-match-piece='4']) { --toy-x: 50%; }
:is(.match-tile[data-kind='2'], .match-tile[data-kind='parcel'], [data-match-piece='2']) { --toy-x: 100%; }
:is(.match-tile[data-kind='3'], .match-tile[data-kind='4'], .match-tile[data-kind='parcel'], [data-match-piece='3'], [data-match-piece='4']) { --toy-y: 100%; }
.match-color-mark {
  display: none;
  position: absolute;
  top: -1px;
  left: -1px;
  width: 34%;
  aspect-ratio: 1;
  background-color: #13202a;
  border: 1px solid #bc9569;
  border-radius: 50%;
  z-index: 3;
}
.match-tile[data-power]:not([data-power='0']) .match-color-mark { display: block; }
.match-tile[data-power]:not([data-power='0']) .match-piece {
  background: url('../art/style/match-specials.png') var(--power-x, 0%) var(--power-y, 0%) / 200% 200% no-repeat;
}
.match-tile[data-power='2'] { --power-x: 100%; }
.match-tile[data-power='3'] { --power-y: 100%; }

.match-frost {
  position: absolute;
  z-index: 3;
  inset: -1px;
  display: grid;
  place-items: end;
  padding: 0 3px 1px;
  border: 1px solid #d5f4ff;
  border-radius: inherit;
  background:
    linear-gradient(128deg, #f1fcff85 0%, #83d6f040 16%, transparent 33% 70%, #b4ebff6b 100%),
    linear-gradient(38deg, #60bbeb45, transparent 20% 76%, #a9eaff69 100%);
  box-shadow: inset 0 0 0 1px #8bd1ef88, inset 0 0 8px #8fd7ef81;
  color: #f0fbff;
  text-shadow: 0 1px 3px #07111c, 0 0 3px #07111c;
  font: 750 clamp(9px, 1.7vw, 13px)/1.2 var(--shell-sans);
  pointer-events: none;
}
.match-frost:empty { display: none; }
.match-tile[data-ice='2'] .match-frost {
  border-width: 2px;
  background:
    linear-gradient(132deg, #f0fcffa8 0%, #b3eaf283 22%, transparent 44% 64%, #a6e6ff99 100%),
    linear-gradient(42deg, #65bbea72, transparent 27% 74%, #b7eeff8c 100%);
  box-shadow: inset 0 0 0 2px #73a4c7, inset 0 0 0 4px #bdefff79, inset 0 0 11px #8fd7efad;
}
.match-tile--crack .match-frost::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: #fff;
  clip-path: polygon(52% 0, 48% 27%, 66% 40%, 94% 29%, 100% 32%, 65% 47%, 50% 35%, 46% 52%, 24% 61%, 31% 83%, 20% 100%, 17% 97%, 26% 82%, 18% 62%, 0 51%, 0 46%, 23% 55%, 42% 48%, 44% 27%, 49% 0);
  animation: match-crack 270ms ease-out both;
}
@keyframes match-crack { to { opacity: .2; } }
.match-view[data-station='post'] .match-tile:nth-last-child(-n+6) { border-bottom-color: #efb877; }
.match-tile--fired .match-piece { box-shadow: 0 0 18px 4px #ffe4a0; }
.match-tile--clear {
  border-color: #ffe9b8;
  background: radial-gradient(circle, #fff6d4 0 12%, #f6c564 30%, #8a5a26 72%);
  box-shadow: 0 0 14px #ffcc6aaa;
  z-index: 3;
}
.match-tile[aria-pressed='true'] .match-piece { animation: match-toy-pick 210ms cubic-bezier(.22, 1, .36, 1) both; }
.match-tile--clear .match-piece { animation: match-clear 270ms ease-in both; }
.match-tile--parcel-out .match-piece { animation: match-parcel-out 300ms ease-in both; }
.match-tile--clear.match-tile--lit {
  border-color: #c7ffe6;
  background: radial-gradient(circle, #fbf8dc, #a2dcbd 23%, #386b54 63%, #1c3e3a 84%);
  box-shadow: 0 0 14px #9affc878;
}
.match-tile--clear::after {
  content: '';
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 6%, #fff7d0 0 3px, transparent 4px),
    radial-gradient(circle at 94% 50%, #ffe39a 0 3px, transparent 4px),
    radial-gradient(circle at 50% 94%, #fff7d0 0 3px, transparent 4px),
    radial-gradient(circle at 6% 50%, #ffe39a 0 3px, transparent 4px),
    radial-gradient(circle at 18% 18%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 82% 82%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 82% 18%, #ffd27c 0 2px, transparent 3px),
    radial-gradient(circle at 18% 82%, #ffd27c 0 2px, transparent 3px);
  pointer-events: none;
  animation: match-sparks 270ms ease-out both;
}
@keyframes match-sparks { from { opacity: 1; transform: scale(.45); } to { opacity: 0; transform: scale(1.15); } }
.match-tile--crack { box-shadow: inset 0 0 0 2px #e8f8ff, 0 0 14px #bfe9ffaa; }
.match-tile--crack .match-frost { border-color: #fff; }
.match-tile--crack::after {
  background:
    radial-gradient(ellipse at 18% 70%, #b9effb 0 2px, transparent 4px),
    radial-gradient(ellipse at 80% 30%, #fbffff 0 2px, transparent 4px),
    radial-gradient(ellipse at 62% 83%, #d2f9ff 0 2px, transparent 4px),
    radial-gradient(ellipse at 40% 15%, #d2f9ff 0 2px, transparent 4px);
}
.match-tile--fall .match-piece { animation: match-fall 295ms cubic-bezier(.26, .68, .25, 1) both; z-index: 2; }
.match-tile--swap .match-piece { animation: match-swap 220ms ease-out both; z-index: 3; }
.match-tile--miss { border-color: #ff9e8c; box-shadow: inset 0 0 12px #ff6a5a55; }
.match-tile--miss .match-piece { animation: match-miss 280ms ease-out both; }

@keyframes match-toy-pick {
  0% { transform: rotate(0) scale(1); }
  45% { transform: rotate(-6deg) scale(1.09); }
  to { transform: rotate(0) scale(1.035); }
}

@keyframes match-clear {
  48% { opacity: 1; transform: translateY(-4%) scale(1.08); }
  to { opacity: 0; transform: translateY(-12%) scale(.78); }
}

@keyframes match-parcel-out {
  32% { transform: translateY(12%) rotate(5deg); }
  to { opacity: 0; transform: translateY(57%) rotate(-7deg); }
}

@keyframes match-fall {
  from { opacity: .76; transform: translateY(calc(-92% * var(--match-fall))); }
  78% { opacity: 1; transform: translateY(3%) scaleY(.96); }
  to { transform: translateY(0) scaleY(1); }
}

@keyframes match-swap {
  from { transform: translate(calc(108% * var(--match-x)), calc(108% * var(--match-y))); }
}

@keyframes match-miss {
  35% { transform: translate(calc(-31% * var(--match-x)), calc(-31% * var(--match-y))); }
  72% { transform: translate(calc(5% * var(--match-x)), calc(5% * var(--match-y))); }
}

.match-cabinet__actions,
.match-result__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.match-stage[data-phase='playing'] .match-result__actions { display: none; }

.match-cabinet__actions { margin: 0 0 0 auto; align-items: stretch; }

:is(.match-view, .words-view :is(.match-dialog, .words-cabinet)) .match-action {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid #b89460;
  border-radius: 6px;
  background: #24394a;
  color: var(--match-cream);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}

:is(.match-view, .words-view :is(.match-dialog, .words-cabinet)) .match-action--primary { border-color: #f0cf91; background: linear-gradient(180deg, #fff4dc, #f2d7a4); color: #481e20; box-shadow: inset 0 1px #fffaf0, 0 2px #2a0d1088; }
:is(.match-view, .words-view :is(.match-dialog, .words-cabinet)) .match-action--primary:hover:not(:disabled) { background: #ffe3ae; }
:is(.match-view, .words-view :is(.match-dialog, .words-cabinet)) .match-action:hover:not(:disabled) { border-color: #f0c987; }
.match-action--hint span {
  display: inline-grid;
  place-items: center;
  min-width: 1.4em;
  margin-inline-start: 3px;
  padding-inline: 3px;
  border: 1px solid #b89460;
  border-radius: 4px;
  color: #ffe1a3;
  font-variant-numeric: tabular-nums;
}
.match-view .match-cabinet__actions .match-action { padding: 3px 8px; font-size: .83rem; }
.match-action--reset small { display: block; color: #ebd5b2; font-size: .68rem; line-height: 1.1; font-weight: 400; }
.match-view .match-help-button { background: transparent; }
.match-view .match-action:disabled { opacity: 0.52; cursor: default; }
.match-view :is(.match-action, .match-level-node, .match-reward__tile):focus-visible { outline: 2px solid #ffda96; outline-offset: 3px; }

:is(.match-view, .words-view .words-cabinet) .match-progress {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding-inline: 8px;
  border-color: #967950;
  background: transparent;
  color: #f5dbb1;
  font-size: .77rem;
  font-variant-numeric: tabular-nums;
}
.match-progress span { color: #d3b88b; }
.match-level-map { display: grid; gap: 12px; margin-top: 13px; }
.match-level-map h3 { margin: 0 0 6px; color: #f3d9ae; font-size: .82rem; font-weight: 650; }
.match-level-map__path {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  justify-items: center;
  align-items: center;
  gap: 4px;
  background: linear-gradient(90deg, #aa915d66, #aa915d66) center / 85% 2px no-repeat;
}
.match-level-node {
  position: relative;
  inline-size: clamp(42px, 10vw, 51px);
  block-size: clamp(42px, 10vw, 51px);
  border: 1px solid #ba9b69;
  border-radius: 45%;
  background: #25434a;
  color: #fff2d5;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}
.match-level-node:hover { background: #395a57; }
.match-level-node[data-locked='true'] { border-color: #75828a; background: #26333b; color: #cbd4d7; }
.match-level-node[data-locked='true']:hover { background: #34444f; }
.match-level-node[data-passed='true'] { border-color: #87c9ab; background: #245340; }
.match-level-node[data-passed='true']::after {
  content: '';
  position: absolute;
  inset: 5px 6px auto auto;
  width: 7px;
  height: 4px;
  border: solid #b8efca;
  border-width: 0 0 1px 1px;
  transform: rotate(-45deg);
}
.match-level-node[aria-current='step'] {
  border-color: #ffdd90;
  box-shadow: 0 0 0 2px #f4c77888;
  background: #efd096;
  color: #492d20;
}
.match-level-node[aria-current='step']:hover { background: #ffe4ab; }

.match-best { margin: 10px 0 0; color: var(--match-mist); font-size: 0.89rem; }

.match-status { margin: 0; line-height: 1.4; color: #e1edf6; font-size: 0.91rem; }
.match-result__actions:not(:has(> :not([hidden]))) { display: none; }

.match-dialog {
  width: min(520px, calc(100% - 24px));
  max-height: min(85dvh, 680px);
  margin: auto;
  padding: clamp(13px, 3vw, 24px);
  border: 1px solid #b89460;
  border-radius: 12px;
  background: #172a34;
  color: var(--match-cream);
  font-size: .93rem;
  line-height: 1.46;
}
.match-dialog::backdrop { background: #07151bcb; }
.match-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.match-dialog h2 { margin: 0; font: 600 clamp(21px, 3.4vw, 30px)/1.12 Georgia, serif; }
.match-dialog p { margin: 11px 0 0; }
.match-dialog strong { color: #ffdb9c; }
.match-goal-dialog {
  position: fixed;
  z-index: 20;
  inset: auto;
  box-sizing: border-box;
  width: min(450px, calc(100% - 24px));
  margin: 0;
  background: #152c39;
  box-shadow: 0 14px 40px #07111bb8, 0 0 0 100vmax #07151b36;
}
.match-goal-dialog header { align-items: flex-start; margin-block-end: 4px; }
.match-goal-dialog .match-goal-level { margin: .25rem 0 0; color: #d4dfeb; font-size: .86rem; }
.match-goal-dialog .match-action.match-goal-close {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.65rem;
  line-height: 1;
}
.match-goal-dialog h2 { color: #ffe4ae; font-size: clamp(1.65rem, 5vw, 2.2rem); }
.match-goal-list {
  display: grid;
  gap: 7px;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}
.match-goal-list li {
  padding: 8px 11px;
  border: 1px solid #72899a;
  border-radius: 6px;
  background: #203948;
  color: #fff3dc;
  font-size: clamp(.95rem, 3.8vw, 1.16rem);
  font-weight: 700;
}
.match-goal-list li[data-kind="ice"] { border-color: #b7e9ff; background: #284856; }
.match-goal-list li[data-kind="piece"] { border-color: #ebc37a; background: #433325; }
.match-goal-list li[data-match-piece] { display: flex; align-items: center; gap: 7px; }
.match-goal-dialog .match-goal-moves { margin-block: 10px 12px; color: #d4dfeb; }
.match-tile:is(.match-tile--goal-ice, .match-tile--goal-piece) {
  --goal-ice: transparent;
  --goal-piece: transparent;
  box-shadow: inset 0 0 0 2px var(--goal-ice), inset 0 0 0 5px var(--goal-piece), 0 0 6px var(--goal-glow);
  z-index: 2;
}
.match-tile.match-tile--goal-ice { --goal-ice: #c3f1ff; --goal-glow: #79daff; }
.match-tile.match-tile--goal-piece { --goal-piece: #ffcd75; --goal-glow: #eab557; }
.match-grid--goal-briefing .match-tile--hint .match-piece { animation: none; }
.match-grid--goal-briefing .match-tile--goal-piece .match-piece { animation: match-nudge .95s ease-in-out 2; }
.match-grid--goal-briefing .match-tile--goal-ice .match-frost { animation: match-ice-shiver .95s ease-in-out 2; }
.match-grid--goal-briefing .match-tile:nth-child(3n) :is(.match-piece, .match-frost) { animation-delay: 80ms; }
@keyframes match-ice-shiver {
  0%, 55%, 100% { transform: none; }
  16% { transform: translate(-4%, -3%) rotate(-3deg); }
  34% { transform: translate(3%, -4%) rotate(2deg); }
}
.match-grid--paused:not(.match-grid--goal-briefing) :is(.match-piece, .match-frost) {
  animation-play-state: paused;
}
.match-level-details header { align-items: flex-start; }
.match-level-details header button { white-space: nowrap; }
.match-level-details h3 { margin: 16px 0 6px; font-size: .95rem; }
.match-level-details .match-reward__list { grid-template-columns: minmax(0, 1fr); gap: 6px; }
.match-level-details .match-reward__tile { padding: 5px 8px; border-color: #5b5246; background: #20343d; }
.match-level-details .match-reward__tile:is(:hover, :focus-visible) { border-color: #b89460; background: #342820; }
.match-reward__tile[data-toy-tier], .match-reward__peek[data-toy-tier] { border-color: var(--toy-tier-edge); background: var(--toy-tier-stage); }
.match-reward__tile[data-toy-tier]:is(:hover, :focus-visible) { background: color-mix(in srgb, var(--toy-tier-stage), var(--toy-tier-light) 25%); }
.match-reward__tile[data-toy-tier] small { color: var(--toy-tier-label); }
.match-reward__list > li:has(> [data-reward-toy]) { grid-column: 1 / -1; }
.match-reward__list .match-reward__tile[data-reward-toy] { grid-template-columns: minmax(66px, 30%) minmax(0, 1fr); gap: 8px; }
.match-reward__tile[data-reward-toy] .match-reward__art {
  height: 74px;
  background: var(--toy-tier-fill, #282525);
}
.match-reward__tile[data-reward-toy] .match-reward__art :is(img, canvas) { max-height: 74px; }
.match-reward__tile[data-reward-toy] .game-prize-meta { margin-top: .24rem; }
.match-level-details > .match-action { min-height: 44px; margin-top: 16px; }
@media (min-width: 560px) {
  .match-level-details .match-reward__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .match-view { max-width: 684px; }
  .match-view__layout {
    grid-template-columns: minmax(0, min(660px, 100%));
  }
  .match-reward__list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; }
  .match-reward__tile { grid-template-columns: 44px minmax(0, 1fr); gap: 7px; padding-inline: 2px; }
  .match-reward__art { height: 42px; }
  .match-reward__art :is(img, canvas) { max-height: 42px; }
  .match-reward__list > li:nth-child(odd) .match-reward__peek { inset-inline: 0 auto; }
  .match-view .match-action { min-height: 44px; }
  :is(.match-view, .words-view .words-cabinet) .match-progress { min-height: 38px; }
  .match-view .match-modes .match-action { min-height: 39px; }
}

@media (max-width: 520px) {
  .match-view__header { gap: 8px; }
  .match-view__navigation { width: 100%; gap: 5px; }
  .match-view__navigation .match-action { padding-inline: 7px; font-size: .8rem; }
  .match-view__navigation .match-help-button { margin-inline-start: auto; }
  .match-board-shell { padding: 5% 5% 6%; background-size: 117% 113%; }
}

@media (max-width: 410px) {
  .match-view { padding-inline: 10px; }
  .match-cabinet { padding: 4px; border-radius: 9px; }
  .match-tile { border-radius: 5px; }
  .match-cabinet__top { min-height: 25px; padding-inline: 2px; }
  .match-stage:not([data-phase='playing']) > .match-result { padding-inline: 12px; }
  .match-stage .match-status { font-size: .86rem; }
  .match-combo { right: 4%; }
}

@media (max-width: 600px), (max-height: 500px) {
  .match-goal-dialog { inset: 0; margin: auto; }
}

@media (max-width: 800px), (pointer: coarse) {
  .match-view .match-view__navigation .match-action,
  .match-view .match-cabinet .match-action, .match-dialog .match-action { min-height: 44px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .match-view { max-width: 850px; }
  .match-view__layout { grid-template-columns: minmax(0, 1fr); }
  .match-cabinet__inside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(60%, calc(100dvh - 3.1rem));
    grid-template-areas: 'top stage' 'toolbar stage' 'lantern stage' '. stage';
    grid-template-rows: auto auto auto minmax(0, 1fr);
    align-items: start;
    gap: 3px 8px;
  }
  .match-cabinet__top { grid-area: top; }
  .match-toolbar { grid-area: toolbar; }
  .match-lantern { grid-area: lantern; }
  .match-stage { grid-area: stage; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .match-view .match-piece,
  .match-view .match-frost,
  .match-view .match-frost::after,
  .match-view .match-tile::after,
  .match-view .match-flash::before,
  .match-view .match-flash::after,
  .match-view .match-combo,
  .match-view .match-result,
  .match-view .match-targets li,
  .match-view .match-moves strong { animation: none !important; }
  .match-view .match-lantern__rail::before { transition: none; }
  .match-stage .match-board-shell { transition: none !important; }
}
