/* ===========================================================
   10K TAVERN — Tankards
   Builds on /styles.css and borrows the board frame, pause veil,
   ledger and control styles from /sudoku/sudoku.css (copied below
   where needed so this room stands on its own).
   Each table is tinted a different tavern colour. There are no heavy
   lines between tables on purpose — they made the puzzle too easy.
   =========================================================== */

/* -------------------- table colours -------------------- */
:root{
  --tk-0: #E9C46A;  /* golden ale   */
  --tk-1: #D4896A;  /* copper       */
  --tk-2: #A8C686;  /* hops         */
  --tk-3: #8DB8CF;  /* pewter blue  */
  --tk-4: #C99BC4;  /* berry wine   */
  --tk-5: #C9CED4;  /* pewter       */
  --tk-6: #B9A486;  /* oak          */
  --tk-7: #E39A9A;  /* cherry       */
  --tk-8: #9ED1BC;  /* mint julep   */
  --tk-9: #B4AEE0;  /* lavender     */
  --tk-ink: #241F1A;
  --tk-cross: rgba(36,31,26,0.55);
  --tk-auto: rgba(36,31,26,0.2);
}
[data-theme="casino"]{
  --tk-0: #8A6A1E;
  --tk-1: #8A4A32;
  --tk-2: #4F6E37;
  --tk-3: #34637C;
  --tk-4: #6E3F6A;
  --tk-5: #5C6772;
  --tk-6: #5E4E3A;
  --tk-7: #873A43;
  --tk-8: #2F6E5A;
  --tk-9: #4E4A8A;
  --tk-ink: #050506;
  --tk-cross: rgba(242,236,221,0.7);
  --tk-auto: rgba(242,236,221,0.22);
}

/* -------------------- ladder (level picker) -------------------- */
.tk-next{ text-align: center; margin: 4px 0 28px; }
.tk-next-btn{ font-size: 1.1rem; padding: 14px 34px; }
.tk-next-sub{
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: rgba(var(--fg-rgb),0.55);
}
.tk-ladder{
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 860px;
  margin: 0 auto;
}
.tk-room{
  background: rgba(0,0,0,0.16);
  border: 1px solid rgba(var(--fg-rgb),0.08);
  border-radius: 12px;
  padding: 14px 16px 16px;
}
.tk-room.locked{ opacity: 0.45; padding-bottom: 14px; }
.tk-room-head{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.tk-room.locked .tk-room-head{ margin-bottom: 0; }
.tk-room-name{ font-family: var(--display); font-weight: 600; font-size: 1.2rem; color: var(--fg); }
.tk-room-size{ font-family: var(--mono); font-size: 0.75rem; color: rgba(var(--fg-rgb),0.55); }
.tk-tiles{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
}
.tk-tile{
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(var(--ink-rgb),0.15);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--bone-light), var(--bone));
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(0,0,0,0.22), 0 6px 12px rgba(0,0,0,0.18);
  padding: 0;
  transition: transform 0.12s ease;
}
.tk-tile b{ font-family: var(--display); font-size: 1.2rem; line-height: 1; }
.tk-tile small{ font-family: var(--mono); font-size: 0.6rem; color: rgba(var(--ink-rgb),0.55); }
.tk-tile:hover:not(:disabled){ transform: translateY(-2px); }
.tk-tile.done{ background: linear-gradient(180deg, rgba(var(--pine-rgb),0.22), rgba(var(--pine-rgb),0.12)), linear-gradient(180deg, var(--bone-light), var(--bone)); }
.tk-tile.current{
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: var(--felt-deep);
  box-shadow: 0 0 0 2px var(--brass-bright), 0 6px 16px rgba(0,0,0,0.3);
}
.tk-tile.current small{ color: rgba(0,0,0,0.55); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.tk-tile.locked{ opacity: 0.35; box-shadow: none; cursor: default; }

/* -------------------- ledger / tray (shared look with Sudoku) -------------------- */
.tk-level{ font-family: var(--display) !important; }
.plaque .p-name{ justify-content: space-between; }
.sd-pause{
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pine);
  background: rgba(var(--pine-rgb),0.14);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
}
.sd-pause:hover{ background: rgba(var(--pine-rgb),0.24); }
@media (max-width: 860px){
  .felt .ledger{ flex-direction: row; gap: 8px; }
  .felt .ledger .plaque{ flex: 1; min-width: 0; padding: 10px 12px; }
  .felt .ledger .p-name{ font-size: 0.85rem; }
  .felt .ledger .p-score{ font-size: 1.2rem; }
  .sd-pause-word{ display: none; }
  .sd-pause{ padding: 2px 6px; }
  .felt .ledger .p-onboard{ font-size: 0.64rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

.sd-tray{ min-height: 0; padding: 18px; align-items: center; justify-content: center; }
@media (max-width: 640px){ .sd-tray{ padding: 10px; border-radius: 12px; } }
.sd-board-wrap{ position: relative; width: 100%; max-width: 540px; }
@media (min-width: 861px){
  .sd-board-wrap{ max-width: min(540px, max(360px, calc(100vh - 300px))); }
}
.sd-paused{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.sd-paused span{
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--fg);
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}
.tk-loading span{ font-size: 1.4rem; }

.sd-controls{ justify-content: center; flex-wrap: wrap; }
.sd-controls .btn-secondary{ padding: 11px 22px; }
@media (max-width: 640px){
  /* Phone: Undo · Clear · Restart on top, the two hints below */
  .sd-controls{ gap: 6px; display: grid; grid-template-columns: repeat(6, 1fr); }
  .tk-controls #btn-undo, .tk-controls #btn-clear, .tk-controls #btn-restart{ grid-column: span 2; }
  .tk-controls #btn-hint, .tk-controls #btn-cross{ grid-column: span 3; }
  .sd-controls .btn-secondary{ padding: 10px 4px; font-size: 0.85rem; white-space: nowrap; }
}

/* -------------------- the board -------------------- */
.tk-board{
  --n: 6;
  display: grid;
  aspect-ratio: 1 / 1;
  width: 100%;
  background: var(--tk-ink);
  border: 3px solid var(--tk-ink);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18), 0 10px 24px rgba(0,0,0,0.3);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;           /* so a drag marks squares instead of scrolling */
  /* Lets the squares size their mug / ✕ from the board's real width
     (100cqw = the board's width), so a mug always fits its square. */
  container-type: inline-size;
}
.tk-board.is-paused, .tk-board.is-loading{ filter: blur(9px); pointer-events: none; }

.tk-cell{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  min-width: 0;
  border: 0 solid var(--tk-ink);
  /* thin line between squares of the same table */
  box-shadow: inset -1px -1px 0 rgba(0,0,0,0.14);
  min-height: 0;
  overflow: hidden;
  font-size: calc(100cqw / var(--n) * 0.56);
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tk-cell:focus-visible{ outline: 3px solid var(--brass-bright); outline-offset: -3px; z-index: 1; }

/* No heavy lines between tables — the colours alone show where each
   table ends (spotting the edges is part of the puzzle). */

.tk-t0{ background: var(--tk-0); } .tk-t1{ background: var(--tk-1); }
.tk-t2{ background: var(--tk-2); } .tk-t3{ background: var(--tk-3); }
.tk-t4{ background: var(--tk-4); } .tk-t5{ background: var(--tk-5); }
.tk-t6{ background: var(--tk-6); } .tk-t7{ background: var(--tk-7); }
.tk-t8{ background: var(--tk-8); } .tk-t9{ background: var(--tk-9); }

.tk-cell.cross{ color: var(--tk-cross); font-family: var(--body); font-weight: 700; font-size: calc(100cqw / var(--n) * 0.36); }
.tk-cell.auto{ color: var(--tk-auto); font-family: var(--body); font-weight: 600; font-size: calc(100cqw / var(--n) * 0.28); }
.tk-cell.mug{ animation: tk-set 0.22s ease-out; text-shadow: 0 2px 2px rgba(0,0,0,0.25); }
@keyframes tk-set{
  0%{ transform: scale(0.4) translateY(-30%); }
  70%{ transform: scale(1.12); }
  100%{ transform: none; }
}

/* Mugs breaking a rule get a red wash and a wobble. */
.tk-cell.clash{
  background-image: repeating-linear-gradient(45deg, rgba(166,61,47,0.45) 0 6px, rgba(166,61,47,0.25) 6px 12px);
}
[data-theme="casino"] .tk-cell.clash{
  background-image: repeating-linear-gradient(45deg, rgba(230,57,70,0.55) 0 6px, rgba(230,57,70,0.3) 6px 12px);
}
.tk-cell.mug.clash{ animation: tk-wobble 0.4s ease-in-out; }
@keyframes tk-wobble{
  0%,100%{ transform: none; } 25%{ transform: rotate(-12deg); } 75%{ transform: rotate(12deg); }
}

/* The square a hint just changed */
.tk-cell.hinted{ animation: tk-hint 1.2s ease-out; }
@keyframes tk-hint{
  0%{ box-shadow: inset 0 0 0 4px var(--brass-bright), inset 0 0 30px rgba(var(--brass-rgb),0.8); }
  100%{ box-shadow: inset -1px -1px 0 rgba(0,0,0,0.14); }
}

/* Solved: the mugs clink in turn */
.tk-board.solved .tk-cell{ cursor: default; }
.tk-board.solved .tk-cell.mug{ animation: tk-cheers 0.7s ease-in-out 2; }
@keyframes tk-cheers{
  0%,100%{ transform: none; }
  30%{ transform: rotate(-14deg) translateY(-8%); }
  60%{ transform: rotate(10deg); }
}


/* -------------------- modals -------------------- */
.sd-howto{
  font-size: 0.88rem;
  line-height: 1.6;
  color: rgba(var(--ink-rgb),0.8);
  padding-left: 20px;
  margin: 0 0 18px;
}
#solved-body{ font-size: 0.95rem; line-height: 1.6; }
#solved-body .sd-solved-time{
  font-family: var(--mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--pine);
  line-height: 1.2;
}
#solved-body .sd-solved-best{ font-weight: 700; color: var(--brass); }
#solved-body table{ width:100%; border-collapse:collapse; margin-top:12px; font-family: var(--mono); font-size:0.85rem; }
#solved-body td{ padding:6px 4px; border-bottom:1px solid rgba(var(--ink-rgb),0.1); }
#solved-body td:last-child{ text-align:right; }

/* "Next level" button that replaces the controls once a level is solved */
.tk-controls .tk-next-level{ grid-column: 1 / -1; padding: 13px 34px; font-size: 1.05rem; }
.tk-controls [hidden]{ display: none !important; }

/* A table, row or column left with no room for its mug */
.tk-cell.stuck{
  background-image: repeating-linear-gradient(45deg, rgba(166,61,47,0.38) 0 6px, rgba(166,61,47,0.16) 6px 12px);
  animation: tk-stuck 1.6s ease-in-out infinite;
}
[data-theme="casino"] .tk-cell.stuck{
  background-image: repeating-linear-gradient(45deg, rgba(230,57,70,0.45) 0 6px, rgba(230,57,70,0.2) 6px 12px);
}
@keyframes tk-stuck{ 0%,100%{ filter: none; } 50%{ filter: brightness(1.15); } }

/* -------------------- lives -------------------- */
.tk-lives{ display: flex; gap: 4px; font-size: 1.35rem !important; line-height: 1.2; }
.tk-life{ display: inline-block; transition: transform 0.2s ease, opacity 0.2s ease; }
.tk-life.lost{ filter: grayscale(1); opacity: 0.35; transform: scale(0.85); }
@media (max-width: 860px){ .tk-lives{ font-size: 1.05rem !important; gap: 2px; } }

/* A square proven wrong: locked red ✕ */
.tk-cell.wrong{ color: var(--clay) !important; font-weight: 800; }
[data-theme="casino"] .tk-cell.wrong{ color: var(--clay-bright) !important; }
/* The moment a wrong mug cracks (or a locked square is tapped) */
.tk-cell.broke{ animation: tk-broke 0.5s ease-out; }
@keyframes tk-broke{
  0%{ box-shadow: inset 0 0 0 4px rgba(230,57,70,0.9), inset 0 0 26px rgba(230,57,70,0.7); transform: scale(1.06); }
  25%{ transform: rotate(-6deg) scale(1.04); }
  50%{ transform: rotate(6deg); }
  100%{ box-shadow: inset -1px -1px 0 rgba(0,0,0,0.14); transform: none; }
}
.tk-board.over{ filter: grayscale(0.6) brightness(0.85); }
.tk-board.over .tk-cell{ cursor: default; }

/* A square wrongly ✕'d: its mug is shown, ringed in red */
.tk-cell.revealed{ box-shadow: inset 0 0 0 3px rgba(166,61,47,0.85); }
[data-theme="casino"] .tk-cell.revealed{ box-shadow: inset 0 0 0 3px rgba(230,57,70,0.9); }

/* -------------------- hints -------------------- */
.tk-hint-count{
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.35em; height: 1.35em; margin-left: 4px; padding: 0 5px;
  border-radius: 999px;
  background: var(--brass-bright); color: var(--felt-deep);
  font-family: var(--mono); font-size: 0.78em; font-weight: 700;
}
.tk-hint-count.empty{ background: rgba(var(--fg-rgb),0.18); color: rgba(var(--fg-rgb),0.7); }
.btn-secondary.tk-out{ opacity: 0.7; }
.tk-bonus{
  margin: 10px 0 4px; padding: 8px 12px; border-radius: 8px;
  background: rgba(var(--brass-rgb),0.18); font-size: 0.92rem;
}

/* Squares a cross-out hint just marked */
.tk-cell.swept{ animation: tk-swept 0.9s ease-out; }
@keyframes tk-swept{
  0%{ box-shadow: inset 0 0 0 3px var(--brass-bright), inset 0 0 22px rgba(var(--brass-rgb),0.7); transform: scale(0.85); }
  40%{ transform: scale(1.05); }
  100%{ box-shadow: inset -1px -1px 0 rgba(0,0,0,0.14); transform: none; }
}
