.tangram-play { --game-play-width: 550px; }
.tangram-controls, .tangram-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 7px;
}
.tangram-controls label, .tangram-metrics, .tangram-status {
  color: var(--game-secondary);
  font-size: 14px;
  line-height: 1.6;
}
.tangram-metrics { gap: clamp(7px,4vw,23px); margin: 11px 0; font-variant-numeric: tabular-nums; }
.tangram-metrics strong { color: var(--game-ink); }
.tangram-board {
  --tangram-board: #f1eee6;
  --tangram-silhouette: #cdd9d1;
  --tangram-guide: #fffefa;
  display: block;
  width: min(100%, 390px);
  height: auto;
  max-height: 390px;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 12px;
  background: var(--tangram-board);
  box-shadow: inset 0 0 0 1px #8e9b9263;
  touch-action: none;
  user-select: none;
}
html[data-theme=dark] .tangram-board {
  --tangram-board: #27313c;
  --tangram-silhouette: #52655f;
  --tangram-guide: #92a79d;
}
.tangram-silhouette { fill: var(--tangram-silhouette); stroke: var(--tangram-silhouette); stroke-width: .025; }
.tangram-guide { fill: none; stroke: var(--tangram-guide); stroke-width: .035; stroke-dasharray: .12 .07; }
.tangram-polygon { stroke: #163c3980; stroke-width: .035; stroke-linejoin: round; }
.tangram-polygon[data-piece] { cursor: grab; }
.tangram-polygon[data-selected] { stroke: #fffaf0; stroke-width: .09; }
.tangram-polygon[data-locked] { opacity: .82; }
.tangram-preview { opacity: .67; pointer-events: none; }
.tangram-preview[data-snap] { opacity: .87; stroke: #fff5ce; stroke-width: .08; }
.tangram-hint { fill: #fff5ce4d; stroke: #8b6517; stroke-width: .075; stroke-dasharray: .14 .07; pointer-events: none; }
html[data-theme=dark] .tangram-hint { stroke: #ffda88; }
.tangram-pieces {
  width: min(100%, 470px);
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(3px, 1vw, 7px);
  margin: 10px auto 11px;
}
.tangram-piece {
  display: grid;
  place-items: center;
  min-width: 0;
  height: clamp(37px, 11vw, 55px);
  padding: 4px;
  border: 1px solid var(--game-line);
  border-radius: 7px;
  background: var(--game-surface);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.tangram-piece svg { width: 100%; height: 100%; max-height: 38px; pointer-events: none; }
.tangram-piece[data-placed] { opacity: .55; }
.tangram-piece[aria-pressed=true] { border-color: var(--game-accent); background: var(--game-accent-soft); opacity: 1; }
.tangram-piece:focus-visible, .tangram-board:focus-visible { outline: 2px solid var(--game-accent); outline-offset: 2px; }
.tangram-piece:disabled { cursor: default; }
.tangram-secondary { margin-top: 8px; }
.tangram-status { text-align: center; margin: 8px 0 0; min-height: 1.6em; }
#show-victory[hidden], #next-level[hidden] { display: none; }
.tangram-dialog {
  width: min(100% - 32px, 390px);
  box-sizing: border-box;
  margin: auto;
  padding: 22px;
  text-align: center;
  border: 1px solid var(--game-line);
  border-radius: 13px;
  background: var(--game-surface);
  color: var(--game-ink);
}
.tangram-dialog h2 { margin: 0; color: var(--game-accent); font-size: 22px; }
.tangram-dialog p { color: var(--game-secondary); margin: 9px 0 15px; }
.tangram-dialog::backdrop { background: #17263b88; }
@media (max-width: 420px) {
  body[data-fourhao-game=tangram] .tangram-controls .game-page-button { padding-inline: 10px; }
}
.tangram-dialog[open] {
  animation: tangram-dialog-enter 220ms ease-out;
}
@keyframes tangram-dialog-enter {
  from { opacity: .3; }
  55% { box-shadow: 0 0 0 5px #d7a94c4d, 0 18px 45px #13263442; }
}
@media (prefers-reduced-motion: reduce) {
  .tangram-dialog[open] { animation: none; }
}
