/* Create By Asking: the balloon typing game on the typing game page.
   Loaded after style.css, tools.css and family.css; reuses the dark .tool-shell look. */

.ty { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.ty-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; justify-content: space-between; }
.ty-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; flex: 1 1 420px; }
.ty-stats .score { padding: 8px 10px; text-align: center; min-width: 0; }
.ty-stats .score strong { font-size: 1.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ty-stats .score strong.ty-lvname { font-size: 1rem; line-height: 2.25rem; }
.ty-btns { display: flex; gap: 6px; align-items: center; }
.ty-btns .chip-dark:disabled { opacity: 0.4; cursor: default; }

.ty-stage { position: relative; height: 380px; border-radius: 14px; overflow: hidden; background: linear-gradient(180deg, #2B1858 0%, #1C0F3F 100%); }
.ty-sky { position: absolute; inset: 0; }
.ty .game-overlay { background: rgba(15, 8, 39, 0.9); border-radius: 14px; overflow-y: auto; z-index: 3; }
.ty .game-overlay > div { width: min(100%, 560px); }
.ty .game-overlay .f-row { justify-content: center; margin-top: 4px; }
.ty .game-overlay p { margin: 6px 0 12px; }
.ty-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.ty-level { border: 0; border-radius: 12px; padding: 9px 10px; background: rgba(255, 255, 255, 0.08); color: #fff; font: inherit; text-align: left; cursor: pointer; display: grid; gap: 2px; min-width: 0; }
.ty-level b { font: 700 0.9rem/1.2 var(--body); }
.ty-level small { font: 500 0.7rem/1.3 var(--mono); color: #A597CC; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ty-level i { font-style: normal; font: 600 0.72rem/1.2 var(--mono); color: #FFC93C; min-height: 1.2em; white-space: pre; }
.ty-level[aria-pressed="true"] { background: #FFC93C; color: #1C0F3F; }
.ty-level[aria-pressed="true"] small, .ty-level[aria-pressed="true"] i { color: #1C0F3F; }
.ty-speed { margin-bottom: 10px; }
.ty-touch { background: rgba(255, 201, 60, 0.12); color: #FFE08F !important; border-radius: 10px; padding: 8px 12px; }

/* balloons */
.ty-b { position: absolute; left: 0; top: 0; display: grid; justify-items: center; pointer-events: none; will-change: transform; }
.ty-b b { position: relative; display: grid; grid-auto-flow: column; place-items: center; place-content: center; min-width: 58px; height: 68px; padding: 0 14px; border-radius: 50% 50% 48% 48% / 56% 56% 44% 44%; background: radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.6) 0 7%, transparent 8%), var(--c); color: #1C0F3F; font: 800 1.75rem/1 var(--display); box-shadow: inset -6px -8px 0 rgba(0, 0, 0, 0.12); white-space: pre; }
.ty-b b::after { content: ""; position: absolute; bottom: -7px; left: 50%; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top: 8px solid var(--c); }
.ty-b i { width: 2px; height: 34px; margin-top: 6px; background: rgba(255, 255, 255, 0.3); }
.ty-b .done { opacity: 0.35; }
.ty-b.locked b { box-shadow: inset -6px -8px 0 rgba(0, 0, 0, 0.12), 0 0 0 3px #fff; }
.ty-b.small b { min-width: 26px; height: 32px; padding: 0; box-shadow: none; }
.ty-b.small i { height: 18px; }
.ty-b.pop b { animation: ty-pop 0.25s ease-out forwards; }
.ty-b.pop i { opacity: 0; }
.ty-b.shake b { animation: ty-shake 0.3s; }
@keyframes ty-pop { to { transform: scale(1.5); opacity: 0; } }
@keyframes ty-shake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

/* sentence mode */
.ty-sentence { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92%, 640px); z-index: 2; background: rgba(15, 8, 39, 0.75); border-radius: 14px; padding: 18px 20px; text-align: center; font: 600 clamp(1.15rem, 3.6vw, 1.7rem)/1.6 var(--mono); color: #fff; overflow-wrap: anywhere; }
.ty-sentence .done { color: #5BD48F; }
.ty-sentence .cur { background: #FFC93C; color: #1C0F3F; border-radius: 4px; }
.ty-sentence small { display: block; margin-top: 8px; font: 600 0.7rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: #A597CC; }

/* keyboard */
.ty-finger { min-height: 1.6em; text-align: center; color: #CBBFE8; font-size: var(--step--1); display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 0; }
.ty-finger i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.ty-finger kbd { font: 700 0.85rem/1 var(--mono); background: #FFC93C; color: #1C0F3F; border-radius: 5px; padding: 3px 7px; }
.ty-kb { --gap: 5px; --k: calc((100cqw - 9 * var(--gap)) / 10.4); container-type: inline-size; width: min(100%, 640px); margin-inline: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); user-select: none; -webkit-user-select: none; }
.ty-row { display: flex; gap: var(--gap); padding-left: calc(var(--off, 0) * var(--k)); min-width: 0; }
.ty-key { flex: 0 0 var(--k); min-width: 0; aspect-ratio: 1 / 0.92; display: grid; place-items: center; border-radius: 8px; background: color-mix(in srgb, var(--f) 20%, transparent); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), inset 0 0 0 1px color-mix(in srgb, var(--f) 35%, transparent); color: #F2ECFF; font: 600 clamp(0.75rem, 2.4vw, 1rem)/1 var(--mono); position: relative; transition: background 0.12s; }
.ty-key.bump::after { content: ""; position: absolute; bottom: 18%; width: 28%; height: 2px; border-radius: 2px; background: currentColor; opacity: 0.7; }
.ty-row-space { justify-content: center; }
.ty-key.space { flex: 0 0 50%; aspect-ratio: auto; height: clamp(26px, 5vw, 40px); font-size: 0.75rem; }
.ty-key.next { background: var(--f); color: #1C0F3F; box-shadow: 0 0 0 3px #fff, 0 0 16px var(--f); }
.ty-key.ok { background: #5BD48F; color: #1C0F3F; }
.ty-key.bad { background: #FF7A62; color: #1C0F3F; }

@media (max-width: 640px) {
  .ty-stage { height: 460px; }
  .ty-level small { display: none; }
  .ty-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); flex-basis: 100%; }
  .ty-btns { width: 100%; justify-content: flex-end; }
  .ty-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ty-b b { min-width: 50px; height: 58px; font-size: 1.5rem; padding: 0 11px; }
  .ty-kb { --gap: 3px; }
  .ty-key { border-radius: 6px; }
}
@media (prefers-reduced-motion: reduce) { .ty-b.pop b, .ty-b.shake b { animation: none; } }
