/* Стилі плагіна «Арена» */
.ar-page { --ar-r: 24px; font-family: var(--font-round, system-ui); }
.ar-h { font-size: 20px; font-weight: 700; margin: 26px 0 12px; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ar-h small { font-size: 13px; font-weight: 500; color: var(--label2); }
.ar-hint { color: var(--label2); font-size: 13px; line-height: 1.45; margin: 10px 2px 0; }
.ar-empty { color: var(--label2); padding: 18px; text-align: center; border-radius: var(--ar-r); background: var(--glass-bg); box-shadow: var(--glass-edge), var(--glass-shadow); }
.ar-crest { display: block; width: 64px; height: 72px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .18)); }
.ar-crest.big { width: 96px; height: 108px; }
.ar-crest.sm { width: 40px; height: 45px; }
.ar-bar { height: 10px; border-radius: 6px; background: var(--fill); overflow: hidden; }
.ar-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange, #ff9500), #ffcc00); transition: width .9s var(--ease, ease); }
.ar-row-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.ar-row-btns .btn { min-width: 150px; }

/* --- Картка рангу --- */
.ar-rank { display: grid; grid-template-columns: auto 1fr; gap: 16px 20px; align-items: center; padding: 20px; border-radius: var(--ar-r);
  background: var(--glass-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--glass-edge), var(--glass-shadow); }
.ar-rank-info small, .ar-season > small { color: var(--label2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ar-rank-info h2 { margin: 2px 0 4px; font-size: 26px; letter-spacing: -.02em; }
.ar-rp { color: var(--label2); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ar-rp b { color: var(--label); font-size: 20px; font-variant-numeric: tabular-nums; }
.ar-streak { display: inline-flex; align-items: center; gap: 4px; color: #ff6b3d; font-weight: 700; font-size: 13px; }
.ar-streak .sf { width: 14px; height: 14px; }
.ar-next-rank { margin: 8px 0 0; font-size: 13px; color: var(--label2); }
.ar-season { grid-column: 1 / -1; border-top: .5px solid var(--sep); padding-top: 14px; }
.ar-season-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.ar-season-grid div { background: var(--fill); border-radius: 14px; padding: 10px; text-align: center; }
.ar-season-grid b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.ar-season-grid span { font-size: 11px; color: var(--label2); }

/* --- Режими --- */
.ar-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ar-mode { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--ar-r); text-align: left; color: var(--label); font: inherit; cursor: pointer;
  background: var(--glass-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--glass-edge), var(--glass-shadow);
  transition: transform .2s var(--ease, ease), box-shadow .2s; border: 0; }
.ar-mode:hover { transform: translateY(-2px); }
.ar-mode:active { transform: scale(.98); }
.ar-mode.flag { grid-column: 1 / -1; padding: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--mc) 22%, transparent), transparent 70%), var(--glass-bg); }
.ar-mode-ic { width: 52px; height: 52px; flex: none; border-radius: 16px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--mc) 75%, #fff), var(--mc)); box-shadow: 0 6px 16px color-mix(in srgb, var(--mc) 40%, transparent); }
.ar-mode-ic .sf { width: 28px; height: 28px; }
.ar-mode-ic.big { width: 64px; height: 64px; border-radius: 20px; }
.ar-mode-ic.big .sf { width: 36px; height: 36px; }
.ar-mode.flag .ar-mode-ic { width: 64px; height: 64px; }
.ar-mode-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ar-mode-info b { font-size: 17px; }
.ar-mode-info small { color: var(--label2); font-size: 13px; line-height: 1.35; }
.ar-mode-info em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--mc); }
.ar-mode-go { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--mc); flex: none; }
.ar-mode-go .sf { width: 14px; height: 14px; }

/* --- Сходинки рангів --- */
.ar-ladder { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ar-tier { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px; border-radius: 18px; text-align: center;
  background: var(--glass-bg); box-shadow: var(--glass-edge), var(--glass-shadow); opacity: .6; }
.ar-tier b { font-size: 12px; line-height: 1.2; }
.ar-tier small { font-size: 11px; color: var(--label2); }
.ar-tier.past { opacity: .85; }
.ar-tier.cur { opacity: 1; box-shadow: var(--glass-edge), 0 0 0 2px var(--accent), var(--glass-shadow); }

/* --- Історія --- */
.ar-hist { border-radius: var(--ar-r); overflow: hidden; background: var(--glass-bg); box-shadow: var(--glass-edge), var(--glass-shadow); }
.ar-hrow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: .5px solid var(--sep); }
.ar-hrow:last-child { border-bottom: 0; }
.ar-hic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--mc); flex: none; }
.ar-hic .sf { width: 18px; height: 18px; }
.ar-hmain { flex: 1; min-width: 0; font-size: 14px; }
.ar-hmain small { display: block; color: var(--label2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-hrow.win .ar-hmain b { color: var(--green); }
.ar-hrow.lose .ar-hmain b { color: #7a4f0a; }
.ar-hd { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.ar-hrow.win .ar-hd { color: var(--green); }
.ar-hrow.lose .ar-hd { color: var(--label2); }

/* --- Вступ до режиму --- */
.ar-back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font: inherit; font-weight: 600; background: none; border: 0; padding: 6px 0; cursor: pointer; }
.ar-back .sf { width: 16px; height: 16px; }
.ar-intro-card { margin-top: 8px; padding: 22px; border-radius: var(--ar-r); background: var(--glass-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--glass-edge), var(--glass-shadow); }
.ar-intro-head { display: flex; align-items: center; gap: 16px; }
.ar-intro-head small { color: var(--label2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ar-intro-head h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.02em; }
.ar-rules { margin: 18px 0 0; padding-left: 22px; line-height: 1.5; font-size: 15px; }
.ar-rules li { margin-bottom: 6px; }
.ar-rewards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.ar-rewards div { background: var(--fill); border-radius: 14px; padding: 10px; text-align: center; }
.ar-rewards b { display: block; font-size: 16px; color: var(--mc); }
.ar-rewards span { font-size: 12px; color: var(--label2); }
.ar-opp-line { color: var(--label2); font-size: 14px; margin: 14px 0 0; }
.ar-load { margin-top: 18px; }
.ar-load h3 { font-size: 17px; margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ar-load h3 small { font-size: 12px; color: var(--label2); font-weight: 500; }
.ar-load-sel { display: flex; gap: 10px; margin-bottom: 12px; }
.ar-slot { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px; border-radius: 16px; background: color-mix(in srgb, var(--mc) 12%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--mc) 50%, transparent); }
.ar-slot svg { width: 64px; height: 64px; }
.ar-slot b { font-size: 12px; text-align: center; }
.ar-slot .n, .ar-kind-n { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--mc); }
.ar-load-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ar-kind { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 8px; border-radius: 16px; background: var(--fill); color: var(--label); font: inherit; border: 0; cursor: pointer; text-align: center; transition: transform .15s; }
.ar-kind:active { transform: scale(.96); }
.ar-kind.on { background: color-mix(in srgb, var(--mc) 16%, transparent); box-shadow: inset 0 0 0 2px var(--mc); }
.ar-kind-art svg { width: 58px; height: 58px; display: block; }
.ar-kind b { font-size: 13px; }
.ar-kind b em { font-style: normal; font-size: 10px; font-weight: 600; color: var(--label2); background: var(--bg2); border-radius: 6px; padding: 1px 5px; }
.ar-kind small { font-size: 11px; color: var(--label2); line-height: 1.3; }
.ar-toggles { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.ar-tg { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.ar-tg.dim { color: var(--label2); cursor: default; }
.ar-tg input { width: 20px; height: 20px; accent-color: var(--mc); }
.ar-go { background: var(--mc); }

/* --- Пошук суперника --- */
.ar-search { margin: 30px auto; max-width: 460px; text-align: center; padding: 30px 22px; border-radius: var(--ar-r); background: var(--glass-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--glass-edge), var(--glass-shadow); }
.ar-search h2 { margin: 18px 0 6px; }
.ar-search p { color: var(--label2); margin: 0; }
.ar-radar { position: relative; width: 120px; height: 120px; margin: 0 auto; display: grid; place-items: center; color: #ff6b3d; }
.ar-radar .sf { width: 44px; height: 44px; position: relative; }
.ar-radar i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: arRadar 2.4s ease-out infinite; }
.ar-radar i:nth-child(2) { animation-delay: .8s; }
.ar-radar i:nth-child(3) { animation-delay: 1.6s; }
@keyframes arRadar { from { transform: scale(.3); opacity: .8; } to { transform: scale(1); opacity: 0; } }

/* ================= Бій ================= */
.lesson.ar-battle { display: flex; flex-direction: column; padding-bottom: 18px; overflow: hidden; font-family: var(--font-round, system-ui); }
.ar-top { display: flex; align-items: center; gap: 12px; padding: 14px 20px 8px; }
.ar-vs { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 10px; }
.ar-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ar-who.me { align-items: flex-end; text-align: right; }
.ar-who b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ar-who small { font-size: 11px; color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ar-who.me b { color: #e8730c; }
.ar-who.op b { color: #4a67e0; }
.ar-vs-badge { flex: none; font-weight: 900; font-size: 13px; color: #fff; background: linear-gradient(135deg, #ff6b3d, #5b7cfa); border-radius: 10px; padding: 4px 8px; letter-spacing: .04em; }
.ar-clock { min-width: 64px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.ar-clock.low { color: var(--red); animation: arPulse 1s ease-in-out infinite; }
@keyframes arPulse { 50% { opacity: .5; } }
.ar-body { position: relative; width: 100%; max-width: 980px; margin: 0 auto; padding: 4px 18px 10px; display: flex; flex-direction: column; gap: 12px; }

/* Відлік 3-2-1 */
.ar-count { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: color-mix(in srgb, var(--bg2) 55%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.ar-count b { font-size: 120px; line-height: 1; font-weight: 900; color: var(--mc); text-shadow: 0 10px 30px color-mix(in srgb, var(--mc) 45%, transparent); animation: arCount .8s var(--ease, ease) both; }
.ar-count span { font-weight: 700; color: var(--label2); }
@keyframes arCount { from { transform: scale(1.8); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }

/* Діалог «Здатися?» і банер результату */
.ar-quit { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, .28); padding: 20px; }
.ar-quit-card { max-width: 360px; width: 100%; text-align: center; padding: 22px; border-radius: 24px; background: var(--bg2); box-shadow: var(--glass-shadow); }
.ar-quit-card h3 { margin: 0 0 6px; font-size: 22px; }
.ar-quit-card p { margin: 0; color: var(--label2); }
.ar-quit-card .btn { min-width: 0; flex: 1; }
.ar-banner { position: absolute; inset: 0; z-index: 35; display: grid; place-items: center; pointer-events: none; background: color-mix(in srgb, var(--bg2) 35%, transparent); animation: fadeIn .3s; }
.ar-banner b { font-size: 56px; font-weight: 900; padding: 10px 30px; border-radius: 26px; color: #fff; background: var(--label2); animation: arCount .6s var(--ease, ease) both; }
.ar-banner.win b { background: linear-gradient(135deg, #34c759, #1f9d48); }
/* Після поразки — теплий пісок, не червоний: спроба, а не покарання */
.ar-banner.lose b { color: #7a4f0a; background: #fdf1d2; box-shadow: inset 0 0 0 3px #f2b632; font-size: 42px; text-align: center; }

/* Підказка-питання і поле вводу (зверху, щоб клавіатура iOS не закривала) */
.ar-prompt { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 22px; background: var(--bg2); box-shadow: var(--glass-edge), 0 4px 18px rgba(0, 0, 0, .06); }
.ar-q { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.ar-q .em { font-size: 38px; line-height: 1; flex: none; }
.ar-q b { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.ar-q small { margin-left: auto; color: var(--label2); font-size: 12px; text-align: right; }
.ar-dots { display: flex; gap: 5px; flex-wrap: wrap; min-height: 6px; }
.ar-dots .d { width: 22px; height: 28px; border-bottom: 3px solid var(--fill2); display: grid; place-items: center; font-weight: 800; font-size: 17px; color: var(--label); text-transform: lowercase; }
.ar-dots .d.on { border-color: var(--mc); }
.ar-dots .d.hint { color: var(--label3); }
.ar-dots .gap { width: 10px; }
.ar-form { display: flex; gap: 8px; }
.ar-in { flex: 1; min-width: 0; font: inherit; font-size: 18px; font-weight: 600; padding: 12px 16px; border-radius: 16px; border: 0; outline: 0; color: var(--label);
  background: var(--fill); box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .15s; }
.ar-in:focus { box-shadow: inset 0 0 0 2px var(--mc); }
.ar-fire { background: var(--mc); min-width: 0; padding-left: 20px; padding-right: 20px; white-space: nowrap; }
.ar-mic { flex: 1; background: var(--mc); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.ar-mic .sf { width: 20px; height: 20px; animation: arPulse 1.2s infinite; }
.ar-sub { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; font-size: 13px; color: var(--label2); min-height: 18px; }
.ar-reveal { color: var(--red); }
.ar-reveal b { color: var(--label); }
.ar-next { color: var(--label2); }
.ar-link { margin-left: auto; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 0; }
.ar-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--label2); padding: 0 4px; }

/* Поле бою */
.ar-field { --sky1: #bfe3ff; --sky2: #eaf6ff; --grass: #8fd06f; --grass2: #6fb553;
  position: relative; border-radius: 22px; overflow: hidden; min-height: 230px; isolation: isolate;
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 70%); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05); }
.ar-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 22%; background: linear-gradient(180deg, var(--grass), var(--grass2)); z-index: 0; }
.ar-sky .cl { position: absolute; width: 90px; height: 26px; border-radius: 20px; background: rgba(255, 255, 255, .8); filter: blur(1px); z-index: 0; animation: arCloud 40s linear infinite; }
.ar-sky .cl::before { content: ""; position: absolute; width: 44px; height: 30px; border-radius: 50%; background: inherit; left: 18px; top: -14px; }
.ar-sky .c1 { top: 12%; left: 8%; }
.ar-sky .c2 { top: 24%; left: 55%; transform: scale(.7); animation-duration: 55s; }
.ar-sky .c3 { top: 6%; left: 80%; transform: scale(.55); animation-duration: 70s; }
@keyframes arCloud { from { translate: -30vw 0; } to { translate: 30vw 0; } }
.ar-row { position: relative; z-index: 1; display: flex; align-items: flex-end; height: 100%; min-height: 230px; padding: 8px 8px 18px; gap: 4px; }
.ar-town { flex: 3; display: flex; align-items: flex-end; gap: 4px; min-width: 0; }
.ar-mid { flex: 1.2; min-width: 6px; }
.ar-cannon { flex: none; width: 58px; transform-origin: 40% 80%; }
.ar-cannon svg { width: 100%; display: block; }
.ar-cannon.op { transform: scaleX(-1); }
.ar-cannon.fire .brl { animation: arRecoil .35s var(--ease, ease); transform-origin: 18px 16px; }
.ar-cannon.misfire { animation: arWobble .5s; }
.ar-cannon.misfire.op { animation-name: arWobbleOp; }
@keyframes arRecoil { 30% { transform: translateX(-5px) rotate(4deg); } }
@keyframes arWobble { 25% { transform: rotate(-8deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }
@keyframes arWobbleOp { 25% { transform: scaleX(-1) rotate(-8deg); } 50% { transform: scaleX(-1) rotate(6deg); } 75% { transform: scaleX(-1) rotate(-3deg); } }

.ar-house { position: relative; flex: 1; min-width: 0; max-width: 120px; display: flex; flex-direction: column; align-items: center; }
.ar-art { width: 100%; position: relative; transition: transform .5s var(--ease, ease), filter .5s; transform-origin: 50% 100%; }
.ar-art svg { width: 100%; height: auto; display: block; }
.ar-hp { width: 86%; height: 8px; border-radius: 5px; background: rgba(0, 0, 0, .18); overflow: hidden; position: relative; margin-bottom: 3px; }
.ar-hp i { position: absolute; inset: 0; width: calc(var(--hp) * 100%); border-radius: inherit; background: linear-gradient(90deg, #34c759, #8be36b); transition: width .4s var(--ease, ease); }
.ar-house.hurt .ar-hp i { background: linear-gradient(90deg, #ff9500, #ffcc00); }
.ar-hp span { position: absolute; inset: 0; font-size: 0; }
.ar-hname { font-size: 10px; font-weight: 700; color: var(--label); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ar-ab { position: absolute; top: 12px; right: -2px; font-size: 14px; line-height: 1; background: var(--bg2); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); z-index: 2; }
.ar-house.shield .ar-art::before { content: ""; position: absolute; inset: -6% -4% 0; border-radius: 50% 50% 12% 12%; background: radial-gradient(circle at 50% 30%, rgba(120, 200, 255, .15), rgba(90, 170, 255, .35)); box-shadow: inset 0 0 0 2px rgba(90, 170, 255, .7); z-index: 1; }
.ar-house.hurt .ar-art::after { content: ""; position: absolute; left: 40%; top: 10%; width: 22%; aspect-ratio: 1; border-radius: 50%; background: rgba(90, 90, 100, .55); filter: blur(3px); animation: arSmoke 2.2s ease-out infinite; }
.ar-house.down .ar-art { filter: grayscale(1) brightness(.75); transform: scaleY(.55) translateY(8%); }
.ar-house.down .ar-art::after { content: ""; position: absolute; left: 30%; top: 0; width: 34%; aspect-ratio: 1; border-radius: 50%; background: rgba(70, 70, 80, .5); filter: blur(4px); animation: arSmoke 3s ease-out infinite; }
.ar-house.down .ar-hp, .ar-house.down .ar-ab { opacity: .35; }
@keyframes arSmoke { from { transform: translateY(0) scale(.6); opacity: .9; } to { transform: translateY(-60px) scale(2.2); opacity: 0; } }

/* Ефекти */
.ar-fx { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.ar-ball { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #7a7884, #24222a 70%); box-shadow: 0 3px 6px rgba(0, 0, 0, .3); }
.ar-ball.heavy { width: 26px; height: 26px; left: -13px; top: -13px; background: radial-gradient(circle at 35% 35%, #ff9f6b, #a02f10 70%); }
.ar-flash { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: radial-gradient(circle, #fff6c2, #ffb347 45%, transparent 70%); animation: arFlash .35s ease-out forwards; }
@keyframes arFlash { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.ar-boom { position: absolute; width: 0; height: 0; }
.ar-boom::before { content: ""; position: absolute; width: 70px; height: 70px; left: -35px; top: -35px; border-radius: 50%; background: radial-gradient(circle, #fff3b0, #ff9a3c 40%, #e2401f 62%, transparent 72%); animation: arBoom .6s ease-out forwards; }
.ar-boom.big::before { width: 110px; height: 110px; left: -55px; top: -55px; }
.ar-boom i { position: absolute; width: 8px; height: 8px; left: -4px; top: -4px; border-radius: 2px; background: #7a5236; animation: arDebris .8s ease-out forwards; }
.ar-boom i:nth-child(1) { --dx: -40px; --dy: -50px; } .ar-boom i:nth-child(2) { --dx: 36px; --dy: -56px; background: #c4553a; }
.ar-boom i:nth-child(3) { --dx: -55px; --dy: -14px; background: #9a9aa4; } .ar-boom i:nth-child(4) { --dx: 52px; --dy: -20px; }
.ar-boom i:nth-child(5) { --dx: -12px; --dy: -70px; background: #f2b84b; } .ar-boom i:nth-child(6) { --dx: 18px; --dy: -40px; background: #9a9aa4; }
@keyframes arBoom { from { transform: scale(.2); opacity: 1; } 60% { opacity: .9; } to { transform: scale(1.3); opacity: 0; } }
@keyframes arDebris { to { transform: translate(var(--dx), calc(var(--dy) + 70px)) rotate(260deg); opacity: 0; } }
.ar-pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 18px; white-space: nowrap; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .45); animation: arPopUp 1.1s ease-out forwards; z-index: 6; }
.ar-pop.dmg { color: #ff4d3a; font-size: 22px; }
.ar-pop.heal { color: #34c759; }
.ar-pop.miss { color: #8e8e93; text-shadow: 0 1px 2px rgba(255, 255, 255, .6); }
.ar-pop.shield { color: #4aa8ff; }
.ar-pop.down { color: #ffcc00; font-size: 15px; animation-delay: .15s; }
@keyframes arPopUp { from { transform: translate(-50%, -30%) scale(.6); opacity: 0; } 20% { transform: translate(-50%, -80%) scale(1.1); opacity: 1; } to { transform: translate(-50%, -200%) scale(1); opacity: 0; } }
.ar-wave { position: absolute; transform: translate(-50%, -50%); font-size: 30px; font-weight: 900; color: #fff; background: rgba(142, 92, 240, .85); padding: 8px 22px; border-radius: 18px; animation: arWave 1.5s ease forwards; white-space: nowrap; }
@keyframes arWave { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; } }
.ar-shake { animation: arShake .42s; }
@keyframes arShake { 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, 0); } }

/* --- Дуель і Ланцюжок: варіанти --- */
.ar-duel-score { display: flex; align-items: center; justify-content: center; gap: 18px; font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ar-duel-score .me { color: #e8730c; } .ar-duel-score .op { color: #4a67e0; }
.ar-duel-score small { font-size: 13px; color: var(--label2); font-weight: 600; }
.ar-rtimer { height: 6px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.ar-rtimer i { display: block; height: 100%; width: 100%; background: var(--mc); border-radius: inherit; }
.ar-duel, .ar-chain-q { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 22px; background: var(--bg2); box-shadow: var(--glass-edge), 0 4px 18px rgba(0, 0, 0, .06); }
.ar-duel .ar-q, .ar-chain-q .ar-q { justify-content: center; flex-wrap: wrap; }
.ar-duel .ar-q b, .ar-chain-q .ar-q b { font-size: 28px; }
.ar-chain-q .ar-q small { margin-left: 0; width: 100%; text-align: center; }
.ar-st { text-align: center; font-weight: 700; color: var(--label2); min-height: 20px; }
.ar-st.ok { color: var(--green); } .ar-st.bad { color: var(--red); }
.ar-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ar-opt { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; font-size: 17px; min-height: 52px; width: 100%; }
.ar-opt.op-bad { box-shadow: inset 0 0 0 2px #5b7cfa; opacity: .6; }

/* --- Облога --- */
.ar-field.siege { min-height: 300px; }
.ar-vill { position: absolute; left: 0; bottom: 14%; width: 16%; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 0; }
.ar-mini { width: 100%; max-width: 74px; margin-top: -12%; transition: filter .4s, transform .4s; }
.ar-mini svg { width: 100%; height: auto; display: block; }
.ar-mini.down { filter: grayscale(1) brightness(.7); transform: scaleY(.6); transform-origin: 50% 100%; }
.ar-cats { position: absolute; inset: 0 0 0 0; z-index: 3; }
.ar-cat { position: absolute; width: 70px; margin-left: -10px; display: flex; flex-direction: column; align-items: center; transition: opacity .4s; will-change: left; }
.ar-cat.lane0 { top: 6%; } .ar-cat.lane1 { top: 31%; } .ar-cat.lane2 { top: 55%; }
.ar-cat svg { width: 60px; display: block; animation: arRoll .5s linear infinite alternate; }
.ar-sign { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 10px; white-space: nowrap; background: var(--bg2); color: var(--label); box-shadow: 0 3px 10px rgba(0, 0, 0, .18); margin-bottom: 2px; }
.ar-cat.dead { opacity: 0; transform: scale(.6) rotate(-20deg); transition: opacity .4s, transform .4s; }
@keyframes arRoll { to { transform: translateY(-2px) rotate(-2deg); } }
.ar-hearts { letter-spacing: 2px; }
.ar-front { margin-left: auto; color: var(--label); font-weight: 600; }

/* --- Снайпер --- */
.ar-target { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; border-radius: 22px; background: var(--bg2); box-shadow: var(--glass-edge), 0 4px 18px rgba(0, 0, 0, .06); flex-wrap: wrap; }
.ar-target .em { font-size: 40px; line-height: 1; }
.ar-target b { font-size: 28px; font-weight: 800; }
.ar-target small { color: var(--label2); width: 100%; text-align: center; font-size: 12px; margin-top: -6px; }
.ar-snipe-hud { justify-content: center; font-size: 15px; gap: 8px 20px; }
.ar-mult { font-weight: 900; padding: 2px 10px; border-radius: 10px; background: var(--fill); }
.ar-mult.on { background: #34c759; color: #fff; animation: arCount .4s var(--ease, ease); }
.ar-field.snipe { min-height: 380px; height: 52vh; max-height: 520px; }
.ar-sky-field { position: absolute; inset: 0; z-index: 2; }
.ar-bal { position: absolute; transform: translateX(-50%); width: 104px; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; touch-action: manipulation; -webkit-tap-highlight-color: transparent; will-change: top; }
.ar-bal-b { display: grid; place-items: center; width: 96px; min-height: 64px; padding: 8px 6px; border-radius: 50% 50% 46% 46% / 55% 55% 45% 45%; font-weight: 800; font-size: 15px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); word-break: break-word;
  background: radial-gradient(circle at 32% 28%, hsl(var(--h) 90% 78%), hsl(var(--h) 75% 52%) 60%, hsl(var(--h) 70% 40%)); box-shadow: inset -6px -8px 14px rgba(0, 0, 0, .15), 0 6px 14px rgba(0, 0, 0, .18); animation: arBob 2.4s ease-in-out infinite alternate; }
.ar-bal i { width: 2px; height: 26px; background: rgba(0, 0, 0, .3); }
.ar-bal.bad .ar-bal-b { background: #8e8e93; opacity: .55; animation: arShake .4s; }
.ar-bal.pop, .ar-bal.gone { pointer-events: none; opacity: 0; transition: opacity .25s; }
.ar-bal.pop .ar-bal-b { transform: scale(1.5); transition: transform .25s; }
@keyframes arBob { to { transform: translateX(6px) rotate(3deg); } }

/* --- Ланцюжок --- */
.ar-field.chain { min-height: 330px; }
.ar-towers { position: absolute; inset: 0 0 18% 0; z-index: 2; display: flex; justify-content: space-around; align-items: flex-end; padding: 0 10%; }
.ar-tower { display: flex; flex-direction: column; align-items: center; width: 34%; max-width: 160px; }
.ar-stack { display: flex; flex-direction: column-reverse; align-items: center; width: 100%; transform-origin: 50% 100%; animation: arSway 2.6s ease-in-out infinite; }
.ar-stack i { display: block; width: calc(86% - (var(--k) * 1.2%)); height: var(--bh); margin-top: 2px; border-radius: 6px; animation: arDrop .35s var(--ease, ease) backwards; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.ar-tower.me .ar-stack i { background: linear-gradient(90deg, #ffb057, #ff8a1f); }
.ar-tower.me .ar-stack i:nth-child(even) { background: linear-gradient(90deg, #ffc778, #f59a3c); }
.ar-tower.op .ar-stack i { background: linear-gradient(90deg, #8ea6ff, #5b7cfa); }
.ar-tower.op .ar-stack i:nth-child(even) { background: linear-gradient(90deg, #a8b9ff, #6f8cfb); }
.ar-tower.op .ar-stack { animation-delay: -1.1s; }
.ar-tlabel { margin-top: 6px; font-size: 12px; font-weight: 700; text-align: center; color: var(--label); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; position: absolute; bottom: -22px; }
.ar-tower { position: relative; }
.ar-tlabel b { font-size: 16px; }
@keyframes arSway { 0%, 100% { transform: rotate(calc(var(--amp) * -1)); } 50% { transform: rotate(var(--amp)); } }
@keyframes arDrop { from { transform: translateY(-40px); opacity: 0; } }

/* ================= Результат ================= */
.result.ar-result { padding-bottom: 40px; font-family: var(--font-round, system-ui); }
.ar-res-crest { animation: pop .6s var(--ease, ease); }
.ar-result.win h1 { color: var(--green); }
.ar-result.lose h1 { color: #7a4f0a; }
.ar-promo { margin: 4px 0 6px; padding: 10px 18px; border-radius: 16px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #ffb300, #ff6b3d); box-shadow: 0 8px 24px rgba(255, 140, 0, .35); animation: pop .6s var(--ease, ease) .3s backwards; }
.ar-promo.div { background: linear-gradient(135deg, #5b7cfa, #8e5cf0); box-shadow: 0 8px 24px rgba(91, 124, 250, .3); }
.ar-rp-card { width: min(420px, 100%); margin-top: 12px; padding: 16px 18px; border-radius: 22px; background: var(--bg2); box-shadow: var(--glass-edge), 0 4px 18px rgba(0, 0, 0, .06); text-align: left; }
.ar-rp-row { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; color: var(--label2); font-weight: 600; }
.ar-rp-num { font-size: 34px; font-weight: 900; color: var(--label); font-variant-numeric: tabular-nums; }
.ar-delta { margin-left: auto; font-size: 20px; font-weight: 900; color: var(--label2); }
.ar-delta.up { color: var(--green); }
.ar-rp-card small { display: block; margin-top: 8px; color: var(--label2); font-size: 13px; }
.ar-res-btns { margin-top: 22px; }

/* ================= Мобільний (375px) ================= */
@media (max-width: 700px) {
  .ar-modes { grid-template-columns: 1fr; }
  .ar-ladder { grid-template-columns: repeat(3, 1fr); }
  .ar-rank { grid-template-columns: auto 1fr; padding: 16px; }
  .ar-crest.big { width: 72px; height: 81px; }
  .ar-season-grid { grid-template-columns: repeat(2, 1fr); }
  .ar-rewards { grid-template-columns: 1fr; }
  .ar-load-grid { grid-template-columns: 1fr 1fr; }
  .ar-intro-card { padding: 16px; }
  .ar-intro-head h1 { font-size: 23px; }

  .lesson.ar-battle { min-height: calc(100dvh - var(--gap) * 2); }
  .ar-top { padding: 10px 12px 4px; gap: 8px; }
  .ar-who b { font-size: 13px; }
  .ar-who small { display: none; }
  .ar-clock { min-width: 44px; font-size: 14px; }
  .ar-body { padding: 2px 10px 8px; gap: 8px; }
  .ar-prompt { padding: 10px; gap: 6px; border-radius: 18px; }
  .ar-q { min-height: 38px; gap: 8px; }
  .ar-q .em { font-size: 28px; }
  .ar-q b { font-size: 20px; }
  .ar-q small { font-size: 11px; max-width: 34%; }
  .ar-dots .d { width: 18px; height: 22px; font-size: 15px; }
  .ar-in { font-size: 16px; padding: 10px 12px; } /* 16px — без автозуму iOS */
  .ar-fire { padding: 0 14px; }
  .ar-field { min-height: 170px; border-radius: 18px; }
  .ar-row { min-height: 170px; padding: 6px 4px 12px; gap: 2px; }
  .ar-cannon { width: 40px; }
  .ar-mid { flex: .4; }
  .ar-town { gap: 2px; }
  .ar-hname { display: none; }
  .ar-ab { width: 18px; height: 18px; font-size: 11px; top: 10px; }
  .ar-hp { height: 6px; }
  .ar-legend { display: none; }
  .ar-duel-score { font-size: 36px; }
  .ar-duel .ar-q b, .ar-chain-q .ar-q b, .ar-target b { font-size: 22px; }
  .ar-opts { gap: 8px; }
  .ar-opt { font-size: 15px; min-height: 48px; }
  .ar-field.siege { min-height: 260px; }
  .ar-cat { width: 58px; }
  .ar-cat svg { width: 48px; }
  .ar-sign { font-size: 11px; padding: 2px 6px; }
  .ar-front { margin-left: 0; width: 100%; }
  .ar-field.snipe { min-height: 320px; height: 50dvh; }
  .ar-bal { width: 86px; }
  .ar-bal-b { width: 80px; min-height: 54px; font-size: 13px; }
  .ar-field.chain { min-height: 280px; }
  .ar-banner b { font-size: 40px; }
  .ar-banner.lose b { font-size: 30px; }
  .ar-count b { font-size: 96px; }
}

/* ================= Менше руху ================= */
html.no-motion .ar-sky .cl, html.no-motion .ar-stack, html.no-motion .ar-bal-b, html.no-motion .ar-cat svg,
html.no-motion .ar-house.hurt .ar-art::after, html.no-motion .ar-house.down .ar-art::after, html.no-motion .ar-radar i { animation: none !important; }
html.no-motion .ar-shake { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .ar-sky .cl, .ar-stack, .ar-bal-b, .ar-cat svg, .ar-house.hurt .ar-art::after, .ar-house.down .ar-art::after, .ar-shake, .ar-clock.low { animation: none !important; }
}
