/* ---------- Datilografia ---------- */

.ty-app {
  --u: clamp(26px, 5.4vw, 52px);           /* tamanho de uma tecla */
  --f-lp: #ff5d8f; --f-lr: #ff9b3d; --f-lm: #ffd84a; --f-li: #4cf29a;
  --f-ri: #2fe3e3; --f-rm: #5aa2ff; --f-rr: #a67cff; --f-rp: #f05cff; --f-th: #8ea0c4;
  position: relative; z-index: 2;
  max-width: 980px; margin: 0 auto; padding: 1rem 1rem 3rem;
  min-height: 100dvh; display: flex; flex-direction: column;
}

.ty-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.ty-back { padding: .4rem .9rem; font-size: .8rem; display: inline-flex; gap: .5rem; align-items: center; }
.ty-brand { font-size: 1.3rem; }
.ty-top-info { min-width: 90px; text-align: right; font-size: .78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }

.ty-screen { animation: tyIn .35s ease both; display: flex; flex-direction: column; gap: 1rem; flex: 1; }
.ty-screen[hidden] { display: none; }
@keyframes tyIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.ty-title { font-family: var(--font-display); font-size: clamp(1.5rem, 4.5vw, 2.3rem); text-align: center; margin: .5rem 0 0; }
.ty-title-sm { font-size: clamp(1.15rem, 3.2vw, 1.6rem); margin-top: 0; }
.ty-sub { text-align: center; color: var(--text-dim); margin: 0 auto; max-width: 620px; }

.ty-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px;
  padding: 1.25rem; backdrop-filter: blur(8px); display: flex; flex-direction: column; gap: 1rem;
}

.ty-nav { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }

/* ---------- escolha do teclado / nível ---------- */
.ty-layouts, .ty-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-top: .5rem; }
.ty-choice {
  text-align: left; color: var(--text); background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 1rem; cursor: pointer; transition: transform .2s, border-color .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: .5rem; font-family: inherit;
}
.ty-choice:hover, .ty-choice:focus-visible { transform: translateY(-4px); border-color: var(--cyan); box-shadow: 0 8px 28px rgba(0, 229, 255, .18); outline: none; }
.ty-choice h3 { font-family: var(--font-display); font-size: 1rem; margin: 0; }
.ty-choice p { margin: 0; font-size: .82rem; color: var(--text-dim); }
.ty-choice .ty-mini { --u: 11px; pointer-events: none; }
.ty-best { font-size: .75rem; color: var(--amber); }

.ty-toggle { display: flex; gap: .6rem; align-items: center; justify-content: center; color: var(--text-dim); cursor: pointer; }
.ty-toggle input { accent-color: var(--cyan); width: 18px; height: 18px; }

/* ---------- teclado ---------- */
.ty-kb { display: flex; flex-direction: column; gap: calc(var(--u) * .12); align-items: center; user-select: none; }
.ty-row { display: flex; gap: calc(var(--u) * .12); }
.ty-key {
  width: var(--u); height: var(--u); border-radius: calc(var(--u) * .2);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: calc(var(--u) * .4);
  color: rgba(255, 255, 255, .92); text-transform: uppercase;
  background: color-mix(in srgb, var(--fc, #34405e) 24%, #0d1322);
  border: 1.5px solid color-mix(in srgb, var(--fc, #34405e) 55%, transparent);
  box-shadow: 0 calc(var(--u) * .07) 0 color-mix(in srgb, var(--fc, #34405e) 30%, #000);
  transition: transform .08s, background .15s, box-shadow .15s, opacity .2s; position: relative;
}
.ty-key.space { width: calc(var(--u) * 6); --fc: var(--f-th); }
.ty-key.bump::after { content: ''; position: absolute; bottom: 14%; width: 30%; height: 2px; background: currentColor; border-radius: 2px; }
.ty-kb.dim .ty-key { opacity: .28; }
.ty-kb.dim .ty-key.on { opacity: 1; background: color-mix(in srgb, var(--fc) 70%, #0d1322); box-shadow: 0 0 calc(var(--u) * .5) var(--fc); transform: translateY(-2px); }
.ty-key.target { opacity: 1 !important; background: var(--fc); color: #08101c; animation: tyPulse 1s ease-in-out infinite; box-shadow: 0 0 calc(var(--u) * .7) var(--fc); }
.ty-key.press { transform: translateY(2px) scale(.94); }
.ty-key.bad { background: var(--red) !important; color: #fff; animation: tyShake .25s; }
@keyframes tyPulse { 50% { transform: translateY(-3px) scale(1.06); } }
@keyframes tyShake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- mãos ---------- */
.ty-hands { width: min(100%, 560px); height: auto; display: block; margin: 0 auto; }
.ty-hands .fg { fill: color-mix(in srgb, var(--fc) 30%, #10182b); stroke: var(--fc); stroke-width: 2; transition: fill .2s, filter .2s; cursor: pointer; }
.ty-hands .fg.on { fill: var(--fc); filter: drop-shadow(0 0 8px var(--fc)); }
.ty-hands .fg.dim { opacity: .35; }
.ty-hands .palm { fill: #121a2e; stroke: rgba(255, 255, 255, .12); stroke-width: 2; }
.ty-hands text { fill: #08101c; font: 700 11px var(--font-display); pointer-events: none; }

.ty-stage { display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.ty-stage-play .ty-hands { width: min(100%, 420px); }

.ty-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.ty-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 99px; font-size: .78rem;
  background: color-mix(in srgb, var(--fc) 18%, #0d1322); border: 1px solid var(--fc); color: var(--text); cursor: pointer;
  font-family: inherit;
}
.ty-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--fc); }
.ty-chip.on { background: var(--fc); color: #08101c; font-weight: 700; }

.ty-examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.ty-ex {
  display: flex; gap: .7rem; align-items: center; padding: .55rem .75rem; border-radius: 12px; cursor: pointer;
  background: rgba(255, 255, 255, .04); border: 1px solid color-mix(in srgb, var(--fc) 50%, transparent); font-family: inherit; color: var(--text); text-align: left;
}
.ty-ex:hover, .ty-ex.on { background: color-mix(in srgb, var(--fc) 22%, #0d1322); }
.ty-ex b { font: 900 1.5rem var(--font-display); width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 9px; background: var(--fc); color: #08101c; text-transform: uppercase; }
.ty-ex span { font-size: .78rem; line-height: 1.25; }
.ty-tryit { text-align: center; padding: .9rem; border: 1px dashed var(--panel-border); border-radius: 14px; color: var(--text-dim); font-size: .9rem; min-height: 3.2rem; }
.ty-tryit strong { color: var(--fc, var(--cyan)); font-size: 1.05rem; }
.ty-rules { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.ty-rules li { display: flex; gap: .75rem; align-items: flex-start; padding: .7rem .9rem; background: rgba(255, 255, 255, .04); border-radius: 12px; font-size: .92rem; }
.ty-rules i { color: var(--cyan); margin-top: .2rem; width: 1.2rem; text-align: center; }

.ty-steps { display: flex; justify-content: center; gap: .5rem; }
.ty-steps span { width: 34px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .12); transition: background .2s; }
.ty-steps span.done { background: var(--cyan); }

/* ---------- jogo ---------- */
.ty-hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.ty-hud div { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: .45rem; text-align: center; }
.ty-hud small { display: block; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.ty-hud b { font-family: var(--font-display); font-size: 1.05rem; }

.ty-word {
  display: flex; justify-content: center; flex-wrap: wrap; gap: .3rem; min-height: 5.2rem; align-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 8vw, 3.6rem); letter-spacing: .05em;
}
.ty-ch { min-width: 1.05em; text-align: center; border-bottom: 3px solid rgba(255, 255, 255, .2); padding: 0 .05em; transition: color .12s, border-color .12s; color: var(--text-dim); }
.ty-ch.hidden { color: rgba(255, 255, 255, .22); }
.ty-ch.ok { color: var(--green); border-color: var(--green); }
.ty-ch.cur { color: #fff; border-color: var(--cyan); animation: tyBlink 1s steps(2) infinite; }
.ty-ch.miss { color: var(--red); border-color: var(--red); }
.ty-ch.ok.dirty { color: var(--amber); border-color: var(--amber); }
@keyframes tyBlink { 50% { border-color: transparent; } }
.ty-word.flash-bad { animation: tyShake .25s; }

.ty-countdown {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(5, 7, 13, .78); backdrop-filter: blur(6px);
}
.ty-countdown[hidden] { display: none; }
.ty-countdown .num { font: 900 clamp(7rem, 30vw, 14rem)/1 var(--font-display); color: var(--cyan); text-shadow: 0 0 60px var(--cyan); animation: tyPop .9s ease-out both; }
.ty-countdown .num.go { color: var(--green); text-shadow: 0 0 60px var(--green); }
.ty-countdown .msg { position: absolute; top: 22%; color: var(--text-dim); text-transform: uppercase; letter-spacing: .15em; font-size: .9rem; text-align: center; }
@keyframes tyPop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(.9); opacity: .9; } }

.ty-finger-now { text-align: center; min-height: 1.6rem; font-size: .95rem; color: var(--text-dim); }
.ty-finger-now strong { color: var(--fc); }
.ty-hidden-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: -100px; }

/* ---------- resultado ---------- */
.ty-result { align-items: center; text-align: center; }
.ty-stars { font-size: 2.2rem; color: var(--amber); letter-spacing: .3rem; }
.ty-stars .off { color: rgba(255, 255, 255, .15); }
.ty-bigscore { font: 900 clamp(3rem, 14vw, 5.5rem)/1 var(--font-display); color: var(--cyan); text-shadow: 0 0 40px rgba(0, 229, 255, .5); }
.ty-bigscore small { display: block; font-size: .9rem; color: var(--text-dim); letter-spacing: .15em; text-shadow: none; }
.ty-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; width: 100%; }
.ty-stats div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: .6rem; }
.ty-stats b { display: block; font: 700 1.2rem var(--font-display); }
.ty-stats small { color: var(--text-dim); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.ty-rounds { width: 100%; display: grid; gap: .4rem; text-align: left; }
.ty-rounds div { display: flex; justify-content: space-between; gap: .5rem; background: rgba(255, 255, 255, .04); padding: .45rem .8rem; border-radius: 10px; font-size: .88rem; }
.ty-rounds em { font-style: normal; color: var(--amber); }

@media (max-width: 640px) {
  .ty-app { --u: calc((100vw - 2.2rem) / 11.6); padding-bottom: 5rem; }
  .ty-top-info { display: none; }
  .ty-back span { display: none; }
  .ty-key.space { width: calc(var(--u) * 5); }
}
@media (prefers-reduced-motion: reduce) {
  .ty-screen, .ty-key.target, .ty-ch.cur, .ty-countdown .num { animation: none; }
}

.ty-stage > div { width: 100%; }
.ty-stage-play .ty-hands { width: min(100%, 460px); }

/* ---------- aulas guiadas ---------- */
.ty-h2 { font: 700 1.1rem var(--font-display); text-align: center; margin: 1rem 0 0; color: var(--cyan); }
.ty-teacher { border-color: rgba(255, 176, 32, .4); }
.ty-teacher-head { display: flex; align-items: center; gap: .5rem; justify-content: center; color: var(--amber); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.ty-seq { font-size: clamp(1.4rem, 5.5vw, 2.4rem); min-height: 4rem; gap: .25rem; }
.ty-seq .ty-ch.space { min-width: .7em; }
.ty-seq.preview .ty-ch { color: var(--text-dim); animation: none; border-color: rgba(255, 255, 255, .12); }
.ty-lesson-done { color: var(--green); font-size: .78rem; }
.ty-choice.done { border-color: rgba(0, 255, 156, .4); }
.ty-choice.locked { opacity: .5; cursor: not-allowed; }
.ty-choice.locked:hover { transform: none; border-color: var(--panel-border); box-shadow: none; }
