.board__surface { perspective: 75rem; }

.board__turn,
.board__front,
.board-result {
  position: absolute;
  inset: 0;
}

.board__turn {
  transform-style: preserve-3d;
  transition: transform 760ms cubic-bezier(.42, 0, .25, 1);
}

.game[data-outcome]:not([data-show-front]) .board__turn { transform: rotateY(180deg); }

.board__flip {
  position: absolute;
  z-index: 1;
  inset: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.board__front,
.board-result {
  backface-visibility: hidden;
}

.board__front {
  display: grid;
  grid-template: var(--column-ruler-size) var(--grid-side) var(--column-ruler-size) /
    var(--row-ruler-size) var(--grid-side);
}

.board-result {
  display: grid;
  place-items: center;
  transform: rotateY(180deg);
  border-radius: var(--grid-radius, .4rem);
  background: #18130e;
  pointer-events: none;
}

.board-result__tiles,
.board-result__badge { grid-area: 1 / 1; }

.board-result__tiles {
  width: var(--grid-side);
  aspect-ratio: 1;
  border: 1px solid #865a29;
  border-radius: var(--grid-radius, .4rem);
}

:is(.board-result__tiles, .game[data-idle] .board__grid) {
  --tile-step: calc(100% / var(--board-size));
  background:
    linear-gradient(to right, #6d451e85 1px, transparent 1px) 0 0 / var(--tile-step) 100%,
    linear-gradient(to bottom, #6d451e85 1px, transparent 1px) 0 0 / 100% var(--tile-step),
    repeating-linear-gradient(130deg, #fff1 0 1px, #7b431109 1px 3px, transparent 3px 5px),
    radial-gradient(ellipse at center, #f6e0b0, #c69052);
  box-shadow: inset 0 0 1rem #6b3b245c;
}

.board-result__badge {
  display: none;
  z-index: 1;
  width: calc(var(--grid-side) * .79);
  max-height: var(--grid-side);
  object-fit: contain;
  filter: var(--outcome-tone, saturate(1))
    drop-shadow(0 0 .32rem color-mix(in srgb, var(--hud-stone, #5fc5d4) 46%, transparent))
    drop-shadow(0 .2rem .35rem #231508a6);
}

.board-result[data-result="victoria"] [data-badge="victoria"],
.board-result[data-result="derrota"] [data-badge="derrota"] { display: block; }

.game .game-actions button[hidden] { display: none; }
.game[data-outcome] #reset { --action-start: 50%; }

.game[data-skin="santuario"] #start-game {
  --action-start: 50%;
  --action-width: 45%;
  aspect-ratio: auto;
  min-height: 2.4rem;
  padding: .38rem .5rem;
  border: 1px solid transparent;
  background: linear-gradient(#392716, #16191e) padding-box, var(--metal) border-box;
  color: #fff1be;
  font: 700 clamp(.78rem, 3.25cqw, 1.12rem)/1.15 Georgia, serif;
}

.game-status[data-fading] { animation: notice-fade 360ms ease-out both; }

@keyframes notice-fade {
  to { opacity: 0; }
}

.game-intro {
  position: fixed;
  z-index: 5;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.game-intro__curtain,
.game-intro__portrait,
.game-intro__portrait img { position: absolute; }

.game-intro__curtain {
  inset: 0;
  background: #0a1421;
}

.game-intro__portrait {
  inset: 0 auto auto 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.game-intro__portrait img {
  top: 0;
  height: auto;
}

.game[data-intro] :is(.hero__art, .hero__title, .hero__menu, .hero__caption, .game-status, .board, .game-actions),
.game[data-intro] .footer::before { opacity: 0; }

.game[data-intro="reveal"] .hero__art { opacity: 1; }

.game[data-intro="reveal"] :is(.hero__title, .hero__menu),
.game[data-intro="reveal"] .footer::before { animation: intro-fade 340ms ease-out both; }

.game[data-intro="reveal"] .board {
  animation: intro-board 630ms 220ms cubic-bezier(.23, .7, .28, 1) both;
}

.game[data-intro="reveal"] :is(.game-actions, .hero__caption) {
  animation: intro-fade 290ms 820ms ease-out both;
}

@keyframes intro-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes intro-board {
  from { opacity: 0; translate: 0 2.8rem; }
  52% { opacity: 1; translate: 0 -.25rem; }
  76% { translate: 0 .12rem; }
  to { opacity: 1; translate: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .board__turn { transition: none; }
  .game-status[data-fading] { animation: none; }
}
