/* 51% Attack (/51/). The board is one canvas (js/a51.js); this styles the meters, buttons and cards over it. */
html.a51-on, html.a51-on body { margin: 0; overflow: hidden; overscroll-behavior: none; background: #05040a; }
#a51 {
  --teal: #19e6b0; --vio: #9b5cff; --red: #ff3d5a; --gold: #ffc53d; --ink: #05040a; --mute: rgba(233, 230, 245, 0.62); --line: rgba(155, 140, 255, 0.22);
  --display: "Chakra Petch", "Arial Narrow", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  position: fixed; inset: 0; background: var(--ink); color: #e9e6f5; overflow: hidden;
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#a51 [hidden] { display: none !important; }
#a51-cv { position: absolute; inset: 0; display: block; touch-action: none; cursor: pointer; }
#a51 button { font: inherit; color: inherit; cursor: pointer; }
#a51 button:focus-visible, #a51 a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ----- top: consensus, tokens, wave ----- */
.a51-hud {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: min(100%, max(var(--board-w, 520px), 520px));
  display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; box-sizing: border-box;
}
.a51-ic {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(17, 15, 29, 0.8); color: #e9e6f5; text-decoration: none; padding: 0; font: 800 14px var(--mono);
}
.a51-ic svg { width: 18px; height: 18px; }
.a51-ic.on { border-color: var(--gold); color: var(--gold); }
.a51-cons { flex: 1; min-width: 0; display: grid; gap: 4px; }
.a51-cons-top { display: flex; justify-content: space-between; align-items: baseline; font: 800 11px var(--mono); letter-spacing: 0.1em; color: var(--mute); }
.a51-cons-top b { font-size: 17px; letter-spacing: 0; color: #fff; font-variant-numeric: tabular-nums; }
.a51-meter { position: relative; height: 10px; border-radius: 5px; background: rgba(255, 61, 90, 0.28); box-shadow: inset 0 0 0 1px rgba(255, 61, 90, 0.4); overflow: visible; }
.a51-meter i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--teal), var(--vio)); box-shadow: 0 0 12px rgba(25, 230, 176, 0.55); transition: width 0.35s cubic-bezier(.2, .9, .3, 1.2); }
.a51-meter em { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 6px #fff; }
.a51-meter em::after { content: "51%"; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font: 800 9px var(--mono); color: rgba(255, 255, 255, 0.6); font-style: normal; margin-top: 1px; }
.a51-hud.danger .a51-cons-top b { color: var(--red); animation: a51-blink 0.5s steps(2) infinite; }
.a51-hud.danger .a51-meter i { background: linear-gradient(90deg, var(--gold), var(--red)); box-shadow: 0 0 12px rgba(255, 61, 90, 0.7); }
@keyframes a51-blink { 50% { opacity: 0.45; } }
.a51-stat { flex: none; display: grid; justify-items: end; gap: 2px; min-width: 52px; }
.a51-stat span { font: 800 10px var(--mono); letter-spacing: 0.1em; color: var(--mute); }
.a51-stat b { font: 800 17px var(--mono); font-variant-numeric: tabular-nums; }
.a51-stat.gold b { color: var(--gold); }

/* ----- bottom: Super, next wave, speed ----- */
.a51-bar {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, max(var(--board-w, 520px), 520px));
  display: flex; align-items: stretch; gap: 8px; padding: 8px 10px max(10px, env(safe-area-inset-bottom)); box-sizing: border-box;
}
.a51-super, .a51-next {
  position: relative; flex: 1; min-width: 0; height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 12px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(17, 15, 29, 0.86); overflow: hidden;
}
.a51-super img { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(25, 230, 176, 0.5); object-fit: cover; background: #0b2a26; flex: none; filter: grayscale(0.8) brightness(0.7); }
.a51-super-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(25, 230, 176, 0.28), rgba(155, 92, 255, 0.28)); }
.a51-super-txt, .a51-next { display: grid; gap: 1px; align-content: center; position: relative; min-width: 0; }
.a51-next { display: grid; }
.a51-super b, .a51-next b { font: 700 16px/1.1 var(--display); letter-spacing: 0.05em; white-space: nowrap; }
.a51-super small, .a51-next small { font-size: 11.5px; line-height: 1.25; color: var(--mute); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.a51-super:disabled { cursor: default; }
.a51-super.ready { border-color: var(--teal); box-shadow: 0 0 22px rgba(25, 230, 176, 0.55), inset 0 0 18px rgba(25, 230, 176, 0.22); animation: a51-ready 0.9s ease-in-out infinite; }
.a51-super.ready img { filter: none; border-color: var(--teal); }
.a51-super.ready b { color: var(--teal); }
@keyframes a51-ready { 50% { box-shadow: 0 0 34px rgba(25, 230, 176, 0.85), inset 0 0 22px rgba(25, 230, 176, 0.3); } }
.a51-next:disabled { cursor: default; }
.a51-next:not(:disabled) { border-color: rgba(255, 197, 61, 0.7); }
.a51-next:not(:disabled) b { color: var(--gold); }
.a51-speed { height: 60px; width: 48px; border-radius: 14px; }

/* ----- the Super's cut-in ----- */
.a51-cut {
  position: absolute; left: 0; right: 0; top: 36%; height: 88px; display: flex; align-items: center; justify-content: center; gap: 16px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(25, 230, 176, 0.92) 18%, rgba(155, 92, 255, 0.92) 82%, transparent); color: #04140f;
}
.a51-cut img { width: 104px; height: 104px; object-fit: cover; border-radius: 50%; border: 4px solid #04140f; background: #0b2a26; flex: none; }
.a51-cut b { display: block; font: 700 clamp(20px, 6vw, 38px)/1 var(--display); letter-spacing: 0.02em; }
.a51-cut span { font: 800 clamp(11px, 3vw, 15px) var(--mono); letter-spacing: 0.08em; }
.a51-cut.go { animation: a51-cut 1.6s cubic-bezier(.2, .8, .2, 1) both; }
.a51-cut.go img { animation: a51-cut-head 1.6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes a51-cut { 0% { clip-path: inset(50% 0); opacity: 0; } 10% { clip-path: inset(0); opacity: 1; } 82% { clip-path: inset(0); opacity: 1; } 100% { clip-path: inset(50% 0); opacity: 0; } }
@keyframes a51-cut-head { 0% { transform: translateX(-60vw) rotate(-20deg); } 16% { transform: translateX(8px) rotate(4deg); } 80% { transform: translateX(-8px) rotate(-2deg); } 100% { transform: translateX(60vw) rotate(20deg); } }

/* ----- side panels, wide screens only ----- */
.a51-side { position: absolute; top: 76px; width: 230px; display: none; padding: 16px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 14px; background: rgba(12, 10, 24, 0.72); font-size: 13.5px; line-height: 1.5; color: #cfcae6; }
.a51-side h4 { margin: 0 0 10px; font: 800 11px var(--mono); letter-spacing: 0.14em; color: var(--mute); }
.a51-side p { margin: 0 0 9px; }
.a51-side b { color: #fff; }
.a51-side ul, .a51-side ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 7px; }
.a51-side li i { display: inline-block; width: 10px; height: 10px; margin-right: 9px; transform: rotate(45deg); }
.k-aide { background: var(--foe); } .k-lob { background: color-mix(in srgb, var(--foe) 50%, #ffe27a); } .k-sub { background: #ffe9ec; box-shadow: inset 0 0 0 2px var(--foe); transform: none !important; } .k-rog { background: color-mix(in srgb, var(--foe) 55%, #7a2cff); border-radius: 50%; }
.a51-left { right: calc(50% + var(--board-w, 520px) / 2 + 24px); }
.a51-right { left: calc(50% + var(--board-w, 520px) / 2 + 24px); }
#a51-log { margin: 0; font: 500 12px/1.35 var(--mono); }
#a51-log li { color: rgba(233, 230, 245, 0.55); animation: a51-log 0.3s ease-out; }
#a51-log li:first-child { color: #fff; }
#a51-log li.good { color: var(--teal); } #a51-log li.bad { color: var(--red); } #a51-log li.warn { color: var(--gold); }
#a51-log li:nth-child(n+7) { opacity: 0.55; } #a51-log li:nth-child(n+10) { opacity: 0.3; }
@keyframes a51-log { from { opacity: 0; transform: translateY(-6px); } }
@media (min-width: 1060px) and (min-height: 560px) { .a51-side { display: block; } }

/* ----- cards: title, intro, result ----- */
.a51-ov {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); box-sizing: border-box;
  background: radial-gradient(ellipse at center, rgba(5, 4, 10, 0.72) 0%, rgba(5, 4, 10, 0.9) 70%); animation: a51-in 0.35s ease-out;
}
.a51-ov > * { flex-shrink: 0; }
.a51-ov.title { background: radial-gradient(ellipse at center, rgba(5, 4, 10, 0.55) 0%, rgba(5, 4, 10, 0.86) 75%); }
@keyframes a51-in { from { opacity: 0; transform: scale(1.03); } }
.a51-logo { display: flex; flex-direction: column; align-items: center; font: 700 clamp(64px, 19vw, 150px)/0.84 var(--display); letter-spacing: -0.02em; color: #fff; text-shadow: 0 0 40px rgba(155, 92, 255, 0.6); }
.a51-logo-b { font-size: 0.5em; letter-spacing: 0.16em; margin-right: -0.16em; color: var(--red); text-shadow: 0 0 30px rgba(255, 61, 90, 0.8); animation: a51-glitch 4s steps(1) infinite; }
@keyframes a51-glitch { 0%, 91%, 100% { transform: none; opacity: 1; } 92% { transform: translateX(-5px) skewX(-12deg); opacity: 0.7; } 94% { transform: translateX(4px); } 96% { transform: translateX(-2px) skewX(8deg); opacity: 0.85; } }
.a51-tag { margin: 0; max-width: 34ch; font-size: clamp(15px, 2.4vw, 19px); line-height: 1.45; color: rgba(255, 255, 255, 0.82); }
.a51-btn {
  width: min(340px, 100%); padding: 15px 18px; border-radius: 14px; border: 0; background: var(--teal); color: #04140f !important;
  font: 700 20px/1.1 var(--display) !important; letter-spacing: 0.06em; box-shadow: 0 0 28px rgba(25, 230, 176, 0.45), 0 4px 0 #0b7d62; display: grid; gap: 3px;
}
.a51-btn:active { transform: translateY(3px); box-shadow: 0 0 18px rgba(25, 230, 176, 0.45), 0 1px 0 #0b7d62; }
.a51-btn small { font: 600 12px "Space Grotesk", system-ui, sans-serif; letter-spacing: 0.02em; opacity: 0.75; }
.a51-btn.ghost { background: transparent; color: #e9e6f5 !important; box-shadow: inset 0 0 0 1px var(--line); font-size: 15px !important; padding: 12px 18px; }
.a51-best { margin: 0; font: 500 13px var(--mono); color: var(--mute); }
.a51-link { font-size: 13px; color: var(--mute); }
.a51-vs { display: flex; align-items: center; gap: 16px; }
.a51-vs img { width: clamp(72px, 20vw, 116px); height: clamp(72px, 20vw, 116px); border-radius: 50%; border: 3px solid var(--teal); background: #0b2a26; object-fit: cover; box-shadow: 0 0 26px rgba(25, 230, 176, 0.45); }
.a51-vs img.foe { border-color: var(--foe, var(--red)); background: #14101f; box-shadow: 0 0 26px color-mix(in srgb, var(--foe, #ff3d5a) 50%, transparent); }
.a51-vs b { font: 700 30px var(--display); color: var(--mute); }
.a51-ov h2 { margin: 0; font: 700 clamp(30px, 8vw, 52px)/1 var(--display); letter-spacing: 0.03em; }
.a51-ov h2.win { color: var(--teal); text-shadow: 0 0 30px rgba(25, 230, 176, 0.6); }
.a51-ov h2.lose { color: var(--foe, var(--red)); text-shadow: 0 0 30px rgba(255, 61, 90, 0.7); }
.a51-say { margin: 0; width: 100%; max-width: 40ch; font-size: 15.5px; line-height: 1.45; }
.a51-say.foe { color: color-mix(in srgb, var(--foe, #ff3d5a) 45%, #fff); }
.a51-how { list-style: none; margin: 4px 0; padding: 12px 16px; width: 100%; max-width: 380px; box-sizing: border-box; display: grid; gap: 7px; text-align: left; font-size: 14px; line-height: 1.4; color: #cfcae6; border: 1px solid var(--line); border-radius: 12px; background: rgba(17, 15, 29, 0.7); }
.a51-how b { color: #fff; }
.a51-big { font: 800 clamp(48px, 14vw, 84px)/1 var(--mono); color: #fff; display: grid; gap: 6px; font-variant-numeric: tabular-nums; }
.a51-big.lose { font-size: clamp(34px, 10vw, 56px); }
.a51-big small { font: 500 14px "Space Grotesk", system-ui, sans-serif; color: var(--mute); }
.a51-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; font-size: 12px; color: var(--mute); }
.a51-stats span { display: grid; gap: 2px; }
.a51-stats b { font: 800 18px var(--mono); color: #fff; }

/* the story ladder */
.a51-ov h2.sm { font-size: clamp(22px, 6vw, 34px); letter-spacing: 0.1em; }
.a51-ladder { display: grid; gap: 8px; width: min(420px, 100%); }
.a51-rung { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 9px 14px 9px 9px; text-align: left; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--foe) 55%, transparent); background: linear-gradient(90deg, color-mix(in srgb, var(--foe) 20%, #0c0a18), rgba(12, 10, 24, 0.86) 70%); }
.a51-rung img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--foe); background: #0c0a18; }
.a51-rung span { display: grid; gap: 2px; min-width: 0; }
.a51-rung b { font: 700 16px/1.15 var(--display); letter-spacing: 0.05em; color: #fff; }
.a51-rung small { font-size: 12.5px; line-height: 1.3; color: var(--mute); }
.a51-rung em { font: 800 13px var(--mono); font-style: normal; color: var(--foe); }
.a51-rung.done em { color: var(--teal); font-size: 16px; }
.a51-rung.locked { filter: grayscale(1); opacity: 0.5; cursor: default; }
.a51-rung:not(.locked):hover { border-color: var(--foe); box-shadow: 0 0 18px color-mix(in srgb, var(--foe) 45%, transparent); }
.a51-side p.tw b { color: var(--foe, #ff3d5a); }

/* a phone on its side is too short for the board */
.a51-turn { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #05040a; text-align: center; z-index: 5; }
.a51-turn b { font: 700 22px var(--display); letter-spacing: 0.06em; color: var(--teal); }
.a51-turn span { font-size: 14px; color: var(--mute); }
@media (max-height: 440px) and (orientation: landscape) { .a51-turn { display: flex; } }

@media (max-width: 420px) {
  .a51-stat { min-width: 44px; } .a51-ic { width: 36px; height: 36px; } .a51-hud { gap: 8px; }
  .a51-super b, .a51-next b { font-size: 14px; } .a51-super img { width: 38px; height: 38px; }
}
@media (prefers-reduced-motion: reduce) { .a51-super.ready, .a51-logo-b, .a51-hud.danger .a51-cons-top b { animation: none; } }
