/*
 * Tapa los agujeros - overrides only; layout, keypad and feedback come from
 * shared/shell.css. The stage holds a prompt line and the 11x11 board
 * (headers + 10x10 table), sized to whatever square fits the stage.
 */

.tb-start-hint {
  max-width: 420px;
  margin: 0 16px;
  font-family: var(--am-readable-font);
  font-size: 17px;
  line-height: 1.4;
  color: var(--purple-dark);
  text-align: center;
}

.hud .tb-left::before { content: "◉ "; color: var(--ink); }

/* the board takes whatever is left of the stage; on a very short screen
   the stage keeps its minimum and .screen scrolls rather than the board
   sliding under the keypad (same fix as dividir/style.css) */
#screen-game.game-screen { grid-template-rows: auto minmax(min-content, 1fr) auto; }
#screen-game .stage-area { gap: 6px; justify-content: flex-start; }
#screen-game .feedback { min-height: 36px; }
#screen-game .feedback img { width: 30px; }
#screen-game .feedback span { font-size: 22px; }

.tb-prompt {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(22px, 5.6vw, 34px);
  color: var(--purple-dark);
  text-shadow: 2px 2px 0 #fff;
  white-space: nowrap;
}
.tb-prompt { min-height: 1.5em; }
.tb-answer[hidden] { display: none; }
.tb-answer {
  min-width: 2.6em;
  min-height: 1.4em;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 10px;
  color: var(--ink);
  text-shadow: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.15);
}

.tb-board-wrap {
  flex: 1 1 auto;
  min-height: 250px;
  width: 100%;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tb-board {
  --size: min(100cqw, 100cqh, 620px);
  width: var(--size);
  height: var(--size);
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  gap: 2px;
  padding: 4px;
  background: #fff;
  border: 3px solid var(--purple);
  border-radius: 14px;
  box-shadow: 0 5px 0 var(--purple-dark);
  font-size: calc(var(--size) / 11 * .42);
  font-variant-numeric: tabular-nums;
}

.tb-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: #fbf2e2;
  color: var(--ink);
  line-height: 1;
  user-select: none;
}
.tb-head { background: var(--purple); color: #fff; }
.tb-corner { background: var(--pink); color: #fff; }
.tb-head.tb-head-on { background: var(--pink); }
.tb-path { background: #fde2ea; }

/* a crack: still missing, not open yet */
.tb-crack {
  background: #ece6ef;
  color: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(122,67,128,.28);
}
.tb-crack::after {
  content: "";
  position: absolute;
  inset: 28% 22%;
  background: linear-gradient(115deg, transparent 46%, rgba(122,67,128,.35) 47%, rgba(122,67,128,.35) 53%, transparent 54%);
}

/* an open hole: tap it, then type */
.tb-open {
  cursor: pointer;
  color: #fff;
  background: radial-gradient(circle at 50% 45%, #3c2645 0 52%, #6d4a77 53% 60%, #fbf2e2 61%);
  animation: tbBreathe 1.8s ease-in-out infinite;
}
.tb-open.tb-selected {
  background: radial-gradient(circle at 50% 45%, #3c2645 0 60%, #fbf2e2 61%);
  box-shadow: 0 0 0 3px var(--pink);
  animation: none;
  z-index: 1;
}
@keyframes tbBreathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,75,97,0); }
  50%      { box-shadow: 0 0 0 3px rgba(231,75,97,.55); }
}

/* the filled neighbour a hint points at */
.tb-hint { background: #c8ecc9; box-shadow: inset 0 0 0 2px var(--green); }

/* an answer the game filled in after two misses - same orange as the
   other games' corrections */
.tb-revealed { color: #c26a12; font-weight: bold; }

.tb-shake { animation: tbShake .4s ease-in-out; }
@keyframes tbShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.tb-plug { animation: tbPlug .45s ease-out; }
.tb-plug-hint { animation: tbPlug .45s ease-out; }
@keyframes tbPlug {
  0%   { transform: scale(.4); background: var(--green); color: #fff; }
  60%  { transform: scale(1.25); background: var(--green); color: #fff; }
  100% { transform: scale(1); }
}
.tb-plug-hint { animation-name: tbPlugHint; }
@keyframes tbPlugHint {
  0%   { transform: scale(.4); background: var(--orange); color: #fff; }
  60%  { transform: scale(1.2); background: var(--orange); color: #fff; }
  100% { transform: scale(1); }
}
/* a filled cell cracking into a new hole */
.tb-breaking { animation: tbBreak .5s ease-out; }
@keyframes tbBreak {
  0%   { transform: rotate(0); background: #fbf2e2; }
  20%  { transform: rotate(-8deg) scale(1.1); }
  40%  { transform: rotate(7deg) scale(1.1); }
  60%  { transform: rotate(-4deg); }
  100% { transform: rotate(0); }
}
.tb-opening { animation: tbOpen .5s ease-out; }
@keyframes tbOpen {
  0%   { transform: scale(.2); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* before each hole: a light spirals in over the cells and lands on it.
   Each cell glows and fades, so the path leaves a short trail. Higher
   specificity than .tb-open so a hole it passes over glows too. */
.tb-cell.tb-spin { animation: tbSpin .42s ease-out; z-index: 2; }
@keyframes tbSpin {
  0%   { background: #ffe58a; box-shadow: 0 0 0 2px #fff, 0 0 12px 3px #ffd34d; transform: scale(1.12); }
  100% { transform: scale(1); }
}
.tb-cell.tb-land { animation: tbLand .5s ease-out; z-index: 2; }
@keyframes tbLand {
  0%   { transform: scale(1.35); box-shadow: 0 0 0 3px #fff, 0 0 18px 6px #ffd34d; }
  100% { transform: scale(1); }
}

/* the board is whole: a wave corner to corner, then the squares glow */
.tb-whole .tb-cell:not(.tb-head):not(.tb-corner) {
  animation: tbWave .6s ease-out both;
  animation-delay: var(--d, 0ms);
}
@keyframes tbWave {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.18); background: #fff3c4; }
}
.tb-squares-on .tb-square { background: #ffe58a; box-shadow: inset 0 0 0 2px var(--orange); transition: background .4s; }

/* Phones: HUD on one row and a smaller keypad, so 11 rows of cells keep
   a tappable size above the pad. */
@media (max-width: 639px) and (orientation: portrait) {
  #screen-game .hud-area { flex-direction: row; align-items: center; gap: 10px; }
  #screen-game .hud { width: auto; flex: 1; }
  #screen-game.game-screen { gap: 6px; }
  #screen-game .keypad { padding: 8px; gap: 6px; }
  #screen-game .keypad button { width: 54px; height: 46px; font-size: 22px; }
  #screen-game .keypad button.wide { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-open, .tb-whole .tb-cell, .tb-plug, .tb-plug-hint, .tb-opening, .tb-breaking, .tb-shake, .tb-spin, .tb-land { animation: none !important; }
}
