/* TonyWeb sits on the same sky as the rest of the site. */

body.page-tonyweb .page {
  max-width: 1100px;
}

/* A game fills the window under the header and stays on screen. */
body.tw-playing {
  overflow: hidden;
}

body.tw-playing .page {
  max-width: 1180px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 1.05rem 0.85rem 0.45rem;
  box-sizing: border-box;
}

body.tw-playing .site-header {
  flex: none;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
}

body.tw-playing .header-nav {
  flex-wrap: nowrap;
  gap: 0.35rem;
}

body.tw-playing .brand-badge {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

body.tw-playing .nav-link {
  padding: 0.3rem 0.62rem;
  font-size: 0.82rem;
}

body.tw-playing .site-footer {
  display: none;
}

body.tw-playing .tw,
body.tw-playing #tw-root,
body.tw-playing .tw-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.tw-playing .tw-stage {
  justify-content: center;
}

body.tw-playing .tw-hud,
body.tw-playing .tw-top {
  flex: none;
  margin-bottom: 0.4rem;
}

body.tw-playing .tw-board {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 100%;
  align-content: center;
  justify-content: center;
  justify-items: center;
  overflow: hidden;
}

body.tw-playing .tw-board.tw-fill {
  flex: 1 1 auto;
  width: 100%;
  margin-top: 0;
}

body.tw-playing .tw-stage > .tw-row {
  flex: none;
}

.tw {
  font-family: var(--font);
  color: var(--ink);
}

.tw-loading {
  color: var(--ink);
  font-weight: 800;
}

.tw-stage {
  position: relative;
  background: transparent;
  color: var(--ink);
  min-height: 0;
  padding: 0;
}

.tw-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.tw-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.tw-top > div:first-child {
  flex: 1;
  min-width: 0;
}

.tw-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: -0.02em;
  color: var(--ink);
}

.tw-lead {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.45;
  max-width: 40rem;
}

.tw-status {
  min-height: 1.3rem;
  margin: 0.15rem 0 0.75rem;
  color: #b7791f;
  font-size: 1rem;
  font-weight: 800;
}

.tw-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.tw-search {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: #fff;
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 0.45rem 0.8rem;
  margin: 0.2rem 0 0.9rem;
  box-shadow: var(--shadow);
}

.tw-search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  outline: none;
  min-width: 0;
}

.tw-search input::placeholder {
  color: #8aa0b4;
  font-weight: 700;
}

.tw-search-icon,
.tw-track-icon {
  width: 1.45rem;
  height: 1.45rem;
  object-fit: contain;
  display: block;
  flex: none;
}

.tw-gear {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tw-ico {
  width: 1.2rem;
  height: 1.2rem;
  object-fit: contain;
  display: block;
  flex: none;
}

.tw-sets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.tw-set {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  margin: 0;
  padding: 0.65rem;
  border-radius: 18px;
  background: #fff;
  border: 3px solid #fff;
  box-shadow: 0 8px 20px rgba(40, 80, 120, 0.1);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
}

.tw-set-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--tw-accent, var(--blue)) 18%, white);
  border: 1px solid #e6eef6;
}

.tw-set-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tw-set-body {
  display: block;
  padding: 0.7rem 0.25rem 0.15rem;
}

.tw-set-body strong {
  display: block;
  font-size: 1.12rem;
}

.tw-set-body span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.tw-set-cta {
  color: var(--tony-pink-solid);
  font-weight: 800;
}

.tw-section {
  margin: 1rem 0 0.45rem;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.tw-pack,
.tw-tile,
.tw-mode,
.tw-word,
.tw-btn,
.tw-chip,
.tw-track {
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  border: 0;
  cursor: pointer;
}

.tw-pack {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-align: left;
  border-radius: 18px;
  padding: 0.7rem 0.75rem 0.7rem 0.9rem;
  margin: 0 0 0.55rem;
  background: #fff;
  border: 3px solid #fff;
  border-left: 8px solid var(--tw-accent, var(--blue));
  box-shadow: 0 8px 20px rgba(40, 80, 120, 0.1);
}

.tw-pack-main {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.tw-pack-main strong {
  display: block;
  font-size: 1.15rem;
}

.tw-pack-main span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  margin-top: 0.12rem;
}

.tw-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 2px solid #e6eef6;
  background: #f7fbff;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.tw-icon-btn--edit { color: #2b6cb0; }
.tw-icon-btn--del { color: var(--tony-pink-solid); }

.tw-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.tw-games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 0.85rem;
  width: 100%;
  align-content: center;
}

.tw-tile,
.tw-mode {
  border-radius: 22px;
  min-height: 132px;
  width: 100%;
  padding: 0.85rem 0.75rem;
  text-align: center;
  background: color-mix(in srgb, var(--tw-accent, var(--blue)) 26%, white);
  border: 3px solid #fff;
  box-shadow: 0 10px 22px rgba(40, 80, 120, 0.12);
}

.tw-tile:disabled {
  opacity: 0.5;
  cursor: default;
}

.tw-tile .emo,
.tw-mode .emo {
  display: grid;
  place-items: center;
  height: 4.4rem;
}

.tw-tile .emo img,
.tw-mode .emo img {
  width: 4rem;
  height: 4rem;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 6px 0 rgba(255, 255, 255, 0.45));
}

.tw-tile strong,
.tw-mode strong {
  display: block;
  font-size: 1.25rem;
  margin-top: 0.25rem;
}

.tw-tile em,
.tw-mode em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-weight: 700;
  margin-top: 0.2rem;
}

.tw-btn {
  background: #fff;
  color: var(--ink);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 0.65rem 1.05rem;
  font-size: 1.02rem;
  box-shadow: 0 6px 14px rgba(40, 80, 120, 0.12);
}

.tw-btn--green {
  background: linear-gradient(145deg, #9adf8d, #5aaa50);
  color: #fff;
}
.tw-btn--red {
  background: linear-gradient(145deg, #ff9eb8, #e53e6b);
  color: #fff;
}
.tw-btn--blue {
  background: linear-gradient(145deg, #90cdf4, #4299e1);
  color: #fff;
}
.tw-btn--purple {
  background: linear-gradient(145deg, #d6bcfa, #9f7aea);
  color: #fff;
}
.tw-btn--dim {
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
}

.tw-btn:hover,
.tw-pack:hover,
.tw-set:hover,
.tw-tile:hover,
.tw-mode:hover,
.tw-word:hover {
  transform: translateY(-2px);
}

.tw-btn:active,
.tw-tile:active,
.tw-mode:active,
.tw-word:active,
.tw-pack:active,
.tw-set:active,
.tw-chip:active {
  transform: scale(0.97);
}

.tw-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 6;
}

.tw-hud h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  flex: 1;
  color: var(--ink);
}

.tw-score {
  font-size: 1.25rem;
  font-weight: 800;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  border: 3px solid #fff;
  box-shadow: 0 6px 14px rgba(40, 80, 120, 0.12);
}

.tw-score.is-pop {
  animation: tw-score-pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.tw-board {
  display: grid;
  gap: 8px;
  justify-content: center;
  align-content: start;
  background: rgba(255, 255, 255, 0.72);
  border: 3px solid #fff;
  border-radius: 24px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
}

.tw-card {
  aspect-ratio: 830 / 1160;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  border: 3px solid #fff;
  border-radius: 14px;
  padding: 0;
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.7), transparent 42%),
    linear-gradient(160deg, #b9e3fb, #7eb6f6);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 16px rgba(40, 80, 120, 0.16);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.tw-card:has(.num)::before {
  content: "";
  position: absolute;
  top: 8%;
  left: 50%;
  width: 1.8rem;
  height: 1.8rem;
  transform: translateX(-50%);
  background: url("/static/img/icons/sparkles.png?v=r2") center / contain no-repeat;
  opacity: 0.72;
  pointer-events: none;
}

.tw-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.tw-card .num {
  font-size: clamp(1.3rem, 2.6vw, 2.1rem);
  text-shadow: 0 2px 0 rgba(43, 108, 176, 0.25);
}

.tw-card.is-gap {
  visibility: hidden;
  pointer-events: none;
}

.tw-card.is-matched {
  box-shadow: 0 0 0 3px #5aaa50, 0 8px 16px rgba(90, 170, 80, 0.35);
}

.tw-card.is-miss {
  box-shadow: 0 0 0 3px #e53e6b;
}

.tw-card.is-turn {
  transform: scaleX(0);
}

.tw-card.is-turn-in {
  animation: tw-flip-in 0.15s ease;
}

.tw-card:disabled {
  cursor: default;
}

.tw-card:focus,
.tw-box:focus,
.tw-word:focus,
.tw-tile:focus,
.tw-mode:focus,
.tw-chip:focus {
  outline: none;
}

.tw-card:focus-visible,
.tw-box:focus-visible {
  outline: 3px solid #2b6cb0;
  outline-offset: 2px;
}

.tw-reveal {
  display: grid;
  grid-template-columns: minmax(110px, 190px) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  align-items: center;
  gap: 0.8rem;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.tw-target {
  background: #fff;
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 0.65rem;
  box-shadow: var(--shadow);
}

.tw-target p {
  margin: 0 0 0.4rem;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.tw-reveal > .tw-board {
  background: rgba(255, 255, 255, 0.72);
  width: 100%;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}

.tw-words {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.55rem;
}

.tw-word {
  border-radius: 16px;
  min-height: 64px;
  padding: 0.45rem 0.6rem;
  font-size: 1.15rem;
  background: color-mix(in srgb, var(--tw-accent, var(--blue)) 32%, white);
  border: 3px solid #fff;
  box-shadow: 0 8px 16px rgba(40, 80, 120, 0.1);
}

.tw-board.tw-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.tw-pick .tw-words {
  width: min(760px, 100%);
}

.tw-board.tw-mole-play {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.tw-mole-play .tw-banner,
.tw-mole-play > .tw-hud {
  width: min(980px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.tw-moles {
  flex: 1;
  min-height: 0;
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.65rem;
  padding: 0.55rem 0.7rem 0.7rem;
  align-items: center;
  justify-items: center;
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.34), transparent 42%),
    linear-gradient(180deg, #b6ef9a 0%, #6fbe5c 55%, #4f9a45 100%);
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.42),
    0 14px 28px rgba(40, 90, 40, 0.16);
}

.tw-mole {
  --card: min(96cqw, calc((100cqh - 2rem) * 830 / 1160));
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
}

.tw-hole {
  position: relative;
  flex: none;
  width: min(100%, calc(var(--card) * 1.2));
  height: clamp(0.7rem, calc(var(--card) * 0.12), 1.45rem);
  margin-top: 0.28rem;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 45%, #3a2414 0 36%, #6b3f22 58%, #8d5a32 70%, #d7f0b4 84%, transparent 86%);
  box-shadow: 0 7px 0 rgba(46, 90, 36, 0.16);
  z-index: 4;
  pointer-events: none;
}

.tw-mole .pop {
  position: relative;
  z-index: 1;
  flex: none;
  width: var(--card);
  height: auto;
  aspect-ratio: 830 / 1160;
  transform-origin: center bottom;
  transform: scaleY(0);
  transition: transform 0.22s cubic-bezier(0.2, 1.35, 0.36, 1);
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 16px rgba(20, 50, 20, 0.18);
}

.tw-mole.is-up .pop {
  transform: scaleY(1);
}

.tw-mole.is-hit .pop {
  animation: tw-squash 0.16s ease;
}

.tw-mole.is-stun .pop {
  animation: tw-shake 0.28s linear;
}

.tw-mole.is-stun button {
  animation: tw-redflash 0.28s ease;
}

.tw-mole button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  border-radius: 14px;
  overflow: hidden;
}

.tw-mole .pop img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #fff;
  pointer-events: none;
}

.tw-mole .pop img.bomb {
  padding: 12%;
  box-sizing: border-box;
  background:
    radial-gradient(circle at 50% 42%, #fff, #ffe4ea 70%, #ffc2d4);
}

.tw-banner {
  text-align: center;
  background: #fff;
  color: var(--ink);
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 0.5rem 0.8rem;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
  font-weight: 800;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow);
}

.tw-timer {
  font-size: 1.7rem;
  font-weight: 800;
  min-width: 2.4rem;
  color: var(--ink);
}

.tw-timer.is-low {
  color: #e53e6b;
  animation: tw-score-pop 0.5s ease infinite;
}

.tw-combo {
  color: #c05621;
  font-size: 1.15rem;
  font-weight: 800;
}

.tw-combo.is-pop {
  animation: tw-score-pop 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.tw-board.tw-modes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.tw-modes .tw-mode {
  width: min(280px, 100%);
}

.tw-board.tw-wheel-board {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.tw-wheel-board .tw-lead {
  flex: none;
  text-align: center;
  margin: 0;
}

.tw-wheel-layout {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(148px, 250px);
  gap: 0.75rem;
  align-items: center;
  justify-items: center;
}

.tw-wheel-wrap {
  position: relative;
  touch-action: none;
  cursor: grab;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  justify-self: center;
  background: #fff;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.tw-wheel-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.tw-pointer {
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid #ffe566;
  filter: drop-shadow(0 2px 0 rgba(44, 62, 80, 0.2));
  pointer-events: none;
  z-index: 2;
}

.tw-wheel-wrap.is-spin .tw-pointer {
  animation: tw-pointer 0.12s ease infinite;
}

.tw-card-side {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  max-height: 100%;
}

.tw-prompt {
  width: min(100%, 230px);
  max-height: 100%;
  aspect-ratio: 830 / 1160;
  border-radius: 18px;
  background: #fff;
  border: 3px dashed #c5d7ea;
  display: grid;
  place-items: center;
  font-size: 4.5rem;
  font-weight: 800;
  color: #8aa0b4;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

.tw-prompt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tw-drop {
  position: absolute;
  inset: 8%;
  border: 3px dashed #63b3ed;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.tw-drop.is-live {
  animation: tw-drop-pulse 1.2s ease-in-out infinite;
}

.tw-drop.is-over { border-style: solid; border-color: #5aaa50; background: rgba(123, 201, 111, 0.28); }
.tw-drop.is-bad { border-style: solid; border-color: #e53e6b; background: rgba(229, 62, 107, 0.18); }
.tw-drop.is-ok { border-style: solid; border-color: #5aaa50; background: rgba(123, 201, 111, 0.38); }

.tw-chips {
  display: flex;
  gap: 0.4rem;
  width: 100%;
  min-width: 0;
}

.tw-chip {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  border-radius: 16px;
  padding: 0.3rem;
  font-size: 1.05rem;
  touch-action: none;
  color: var(--ink);
  background: color-mix(in srgb, var(--tw-accent, #ff8fab) 40%, white);
  border: 3px solid #fff;
  box-shadow: 0 6px 12px rgba(40, 80, 120, 0.12);
}

.tw-ghost {
  position: fixed;
  z-index: 50;
  transform: translate(-50%, -50%);
  background: #fff;
  color: var(--ink);
  border: 3px solid #fff;
  border-radius: 16px;
  padding: 0.65rem 0.9rem;
  pointer-events: none;
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.tw-box {
  aspect-ratio: 1 / 1.08;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  color: #fff;
  font-size: 2rem;
  position: relative;
  overflow: hidden;
  padding: 0;
  box-shadow: 0 8px 14px rgba(40, 80, 120, 0.16);
}

.tw-box-face {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #fff;
  text-shadow: 0 2px 0 rgba(44, 62, 80, 0.28);
  transition: transform 0.28s cubic-bezier(0.5, 0, 1, 1), opacity 0.22s linear;
}

.tw-box-face::before,
.tw-box-face::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.38);
}

.tw-box-face::before {
  left: 46%;
  width: 8%;
  top: 0;
  bottom: 0;
}

.tw-box-face::after {
  top: 30%;
  left: 0;
  right: 0;
  height: 12%;
}

.tw-box.is-open .tw-box-face {
  transform: translateY(-120%);
  opacity: 0;
}

.tw-box img,
.tw-box-card {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  display: block;
}

.tw-box-card {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transform: scale(0.72);
  animation: tw-card-pop 0.32s cubic-bezier(0.2, 1.4, 0.36, 1) 0.04s forwards;
}

.tw-box.is-jiggle {
  animation: tw-jiggle 0.2s ease;
}

.tw-overlay,
.tw-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 0;
}

.tw-overlay {
  background: rgba(126, 200, 245, 0.22);
  z-index: 30;
  pointer-events: none;
}

.tw-modal {
  background: rgba(44, 62, 80, 0.28);
  z-index: 40;
}

.tw-panel {
  position: relative;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border: 3px solid #fff;
  border-radius: 24px;
  padding: 1.25rem 1.3rem 1.3rem;
  width: min(440px, 92%);
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.tw-count-panel {
  width: auto;
  min-width: 7.5rem;
  padding: 0.15rem 1.3rem 0.45rem;
  border-radius: 32px;
}

.tw-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 1.7rem;
  font-weight: 800;
}

.tw-panel p {
  color: var(--muted);
  font-weight: 700;
}

.tw-count {
  position: relative;
  font-size: clamp(4.5rem, 12vw, 6.5rem);
  font-weight: 800;
  line-height: 1;
  margin: 0.2rem 0;
  color: var(--ink);
}

.tw-count.is-pop {
  animation: tw-count-pop 0.72s cubic-bezier(0.2, 1.15, 0.36, 1);
}

.tw-count.is-go {
  color: #3d8f45;
}

.tw-count.is-go.is-pop {
  animation-name: tw-count-go;
}

.tw-panel .tw-row { justify-content: center; margin-top: 0.8rem; }

.tw-field {
  width: 100%;
  font: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--ink);
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  border: 2px solid #d5e4f2;
  background: #f7fbff;
}

.tw-settings label.line,
.tw-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin: 0.45rem 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.tw-settings input[type="range"] {
  width: 120px;
  accent-color: #4299e1;
}

.tw-tracks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0.4rem 0 0.8rem;
}

.tw-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 14px;
  min-height: 64px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(44, 62, 80, 0.25);
  border: 3px solid transparent;
}

.tw-track.is-on,
.tw-levels button.is-on {
  outline: 3px solid #2b6cb0;
  outline-offset: 1px;
}

.tw-levels { display: flex; gap: 0.4rem; }

.tw-file { display: none; }

.tw-bit {
  position: absolute;
  width: 12px;
  height: 16px;
  margin: -8px 0 0 -6px;
  border-radius: 3px;
  animation: tw-bit 0.9s cubic-bezier(0.16, 0.7, 0.3, 1) forwards;
  pointer-events: none;
}

.tw-bit--mark {
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  background: none !important;
}

.tw-bit--mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tw-float {
  position: absolute;
  transform: translate(-50%, -40%);
  font-size: 1.7rem;
  font-weight: 800;
  pointer-events: none;
  animation: tw-float 0.85s ease forwards;
  text-shadow: 0 2px 0 #fff;
}

.tw-float.is-good { color: #2f855a; }
.tw-float.is-bad { color: #e53e6b; }

.tw-dazed {
  position: absolute;
  left: 50%;
  top: 18%;
  width: 0;
  height: 0;
  z-index: 4;
  pointer-events: none;
}

.tw-dazed img {
  position: absolute;
  width: 1.45rem;
  height: 1.45rem;
  object-fit: contain;
  animation: tw-orbit 0.85s linear infinite;
  animation-delay: calc(var(--i) * -0.17s);
}

.tw-deal {
  animation: tw-deal 0.32s cubic-bezier(0.2, 1.4, 0.36, 1) backwards;
}

.is-shake {
  animation: tw-shake 0.32s linear;
}

@keyframes tw-deal {
  from { transform: scale(0.45); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes tw-flip-in {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes tw-score-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

@keyframes tw-count-pop {
  0% { transform: scale(0.45); opacity: 0; }
  28% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 0.2; }
}

@keyframes tw-count-go {
  0% { transform: scale(0.4); opacity: 0; }
  35% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes tw-bit {
  0% { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 1; }
  42% { transform: translate(calc(var(--dx) * 0.72), calc(var(--dy) * 0.72 - 26px)) scale(1) rotate(var(--rot)); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 54px)) scale(0.7) rotate(var(--rot)); opacity: 0; }
}

@keyframes tw-float {
  0% { transform: translate(-50%, -20%) scale(0.7); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -78px) scale(1); opacity: 0; }
}

@keyframes tw-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes tw-jiggle {
  0% { transform: scale(1, 1); }
  35% { transform: scale(1.1, 0.92); }
  70% { transform: scale(0.93, 1.08); }
  100% { transform: scale(1, 1); }
}

@keyframes tw-card-pop {
  0% { transform: scale(0.72); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes tw-squash {
  0% { transform: scaleY(1) scaleX(1); }
  40% { transform: scaleY(0.9) scaleX(1.08); }
  100% { transform: scaleY(1) scaleX(1); }
}

@keyframes tw-redflash {
  0% { filter: none; }
  30% { filter: saturate(1.4) hue-rotate(-18deg) brightness(1.15); }
  100% { filter: none; }
}

@keyframes tw-orbit {
  0% { transform: translate(-50%, -50%) translate(26px, 0) rotate(0deg); }
  25% { transform: translate(-50%, -50%) translate(0, 9px) rotate(90deg); }
  50% { transform: translate(-50%, -50%) translate(-26px, 0) rotate(180deg); }
  75% { transform: translate(-50%, -50%) translate(0, -9px) rotate(270deg); }
  100% { transform: translate(-50%, -50%) translate(26px, 0) rotate(360deg); }
}

@keyframes tw-drop-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes tw-pointer {
  50% { margin-top: 3px; }
}

@media (max-width: 800px) {
  .tw-reveal {
    grid-template-columns: minmax(84px, 120px) minmax(0, 1fr);
  }
  .tw-wheel-layout {
    grid-template-columns: minmax(0, 1fr) minmax(108px, 38%);
    gap: 0.45rem;
  }
  .tw-prompt { width: 100%; font-size: 2.2rem; }
  body.tw-playing .tw-games {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .tw-sets { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .tw-board.tw-mole-play {
    justify-content: center;
  }
  .tw-moles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    flex: 0 1 auto;
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 1.22 / 1;
    gap: 0.35rem 0.4rem;
    padding: 0.4rem 0.4rem 0.5rem;
  }
}

@media (max-width: 560px) {
  .tw-moles { gap: 0.3rem 0.4rem; }
  .tw-board { padding: 0.55rem; border-radius: 18px; }
  .tw-hud h2 {
    flex: 1 1 100%;
    font-size: 1.25rem;
  }
  body.tw-playing .nav-link:not(.nav-link--green):not(.nav-link--blue) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tw-card,
  .tw-mole .pop,
  .tw-btn,
  .tw-deal,
  .tw-bit,
  .tw-float,
  .tw-dazed img,
  .tw-score.is-pop,
  .tw-count.is-pop,
  .tw-box.is-jiggle,
  .tw-box.is-open .tw-box-card,
  .is-shake,
  .tw-drop.is-live,
  .tw-wheel-wrap.is-spin .tw-pointer,
  .tw-timer.is-low {
    animation: none;
    transition: none;
  }
  .tw-box.is-open .tw-box-card {
    opacity: 1;
    transform: none;
  }
}
