.kt {
  --ink: #fbf7ee; --ink2: #d6cdb8; --ink3: #9a917e; --edge: rgba(255, 228, 170, 0.22);
  --glass: rgba(14, 18, 32, 0.66); --glass2: rgba(10, 13, 24, 0.82);
  --gold: linear-gradient(180deg, #fff1b8 0%, #ffd056 45%, #e09a1c 100%);
  --blue: #2f7bff; --red: #ff3b3b;
  margin: 0; height: 100vh; height: 100dvh; overflow: hidden; color: var(--ink); background: #0c1220;
  font-family: var(--font); font-weight: 600; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.screen { position: fixed; inset: 0; z-index: 2; }
.screen[hidden], .modal[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }

/* loading */
.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; background: radial-gradient(900px 600px at 50% 30%, #23314f, #0c1220 70%); transition: opacity 0.5s; }
.loading.done { opacity: 0; pointer-events: none; }
.ld-crest { font-size: 3.4rem; filter: drop-shadow(0 8px 24px rgba(255, 208, 86, 0.45)); animation: bob 1.4s ease-in-out infinite; }
.ld-title { margin: 0; font: 900 clamp(1.4rem, 5vw, 2.4rem) var(--display); background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: 0.02em; padding: 0 20px; }
.ld-bar { width: min(320px, 70vw); height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; box-shadow: inset 0 0 0 1px var(--edge); }
.ld-bar i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width 0.2s; }
.loading small { color: var(--ink2); }
@keyframes bob { 50% { transform: translateY(-10px) rotate(12deg); } }

/* top bar */
.top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); background: linear-gradient(180deg, rgba(8, 11, 20, 0.75), rgba(8, 11, 20, 0)); }
.back, .icon-btn { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 14px; background: var(--glass); border: 1px solid var(--edge); color: #fff; text-decoration: none; font-size: 1.5rem; line-height: 1; backdrop-filter: blur(10px); }
.icon-btn { font-size: 1.1rem; }
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.brand b { font: 900 clamp(1rem, 3.4vw, 1.45rem) var(--display); background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); }
.ball-ic { width: 30px; height: 30px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #d7d7d7 55%, #8a8a8a); box-shadow: inset -4px -5px 8px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.5); position: relative; }
.ball-ic::after { content: ''; position: absolute; inset: 9px; background: #1a1a1a; clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); }

/* main menu: cards along the bottom so the heroes stay visible */
.menu-body { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: linear-gradient(0deg, rgba(8, 11, 20, 0.85) 30%, rgba(8, 11, 20, 0)); }
.modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 1040px; margin: 0 auto; padding-top: 40px; }
.mode { position: relative; display: grid; gap: 4px; justify-items: start; text-align: left; padding: 16px 16px 14px; border-radius: 20px; border: 1px solid var(--edge); background: var(--glass); backdrop-filter: blur(14px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08); transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; overflow: hidden; }
.mode::before { content: ''; position: absolute; inset: 0; opacity: 0.55; z-index: -1; }
.m-cup::before { background: radial-gradient(260px 140px at 0% 0%, rgba(255, 196, 64, 0.55), transparent 70%); }
.m-quick::before { background: radial-gradient(260px 140px at 0% 0%, rgba(80, 220, 140, 0.45), transparent 70%); }
.m-two::before { background: radial-gradient(260px 140px at 0% 0%, rgba(47, 123, 255, 0.5), transparent 60%), radial-gradient(260px 140px at 100% 100%, rgba(255, 59, 59, 0.45), transparent 60%); }
.m-online::before { background: radial-gradient(260px 140px at 0% 0%, rgba(160, 110, 255, 0.5), transparent 70%); }
.mode:hover { transform: translateY(-4px); border-color: rgba(255, 220, 140, 0.6); box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 220, 140, 0.25); }
.mode:active { transform: translateY(0) scale(0.98); }
.mi { font-size: 1.7rem; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4)); }
.mode b { font: 800 1.15rem var(--display); letter-spacing: 0.02em; }
.mode small { color: var(--ink2); font-size: 0.86rem; line-height: 1.25; }
.mode em { position: absolute; top: 12px; right: 12px; font-style: normal; font-size: 0.75rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: rgba(255, 208, 86, 0.18); border: 1px solid rgba(255, 208, 86, 0.45); color: #ffe39a; }
.mode em:empty { display: none; }
.tip { max-width: 1040px; margin: 12px auto 0; color: var(--ink3); font-size: 0.85rem; text-align: center; }

/* hero select */
.sel-body { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: linear-gradient(0deg, rgba(8, 11, 20, 0.9) 45%, rgba(8, 11, 20, 0)); display: grid; gap: 14px; justify-items: center; padding-top: 60px; }
.heroes { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; padding: 6px 4px 8px; scrollbar-width: none; }
.heroes::-webkit-scrollbar { display: none; }
.hero { position: relative; flex: none; width: 92px; padding: 6px 6px 8px; border-radius: 18px; border: 1px solid var(--edge); background: var(--glass); backdrop-filter: blur(10px); display: grid; justify-items: center; gap: 2px; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.hero img { width: 76px; height: 76px; border-radius: 14px; background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)); }
.hero span { font-size: 0.78rem; font-weight: 800; line-height: 1.1; text-align: center; }
.hero.on { border-color: #ffd056; box-shadow: 0 0 0 2px rgba(255, 208, 86, 0.6), 0 12px 30px rgba(255, 180, 40, 0.25); transform: translateY(-4px); }
.hero.on2 { border-color: var(--red); box-shadow: 0 0 0 2px rgba(255, 59, 59, 0.6); transform: translateY(-4px); }
.hero.lock img { filter: grayscale(1) brightness(0.45); }
.hero.lock::after { content: '🔒'; position: absolute; top: 26px; font-size: 1.4rem; }
.hero small { font-size: 0.66rem; color: var(--ink3); text-align: center; line-height: 1.1; }
.sel-opts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--glass); border: 1px solid var(--edge); backdrop-filter: blur(10px); gap: 2px; align-items: center; }
.seg > span { padding: 0 8px; color: var(--ink3); font-size: 0.8rem; font-weight: 800; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 800; font-size: 0.9rem; color: var(--ink2); }
.seg button.on { background: var(--gold); color: #3b2500; }
.cta { border: 0; padding: 14px 54px; border-radius: 18px; background: var(--gold); color: #3b2500; font: 900 1.2rem var(--display); letter-spacing: 0.08em; box-shadow: 0 12px 30px rgba(255, 170, 30, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.15); transition: transform 0.12s; }
.cta:hover { transform: translateY(-2px); }
.cta:active { transform: scale(0.97); }
.cta.ghost { background: var(--glass); color: var(--ink); border: 1px solid var(--edge); box-shadow: none; }
.p-tag { font: 800 0.8rem var(--display); padding: 4px 12px; border-radius: 99px; }
.p-tag.b { background: rgba(47, 123, 255, 0.25); color: #9cc2ff; } .p-tag.r { background: rgba(255, 59, 59, 0.25); color: #ffaaaa; }

/* online */
.on-body { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -40%); width: min(420px, calc(100vw - 32px)); display: grid; gap: 12px; padding: 22px; border-radius: 24px; background: var(--glass2); border: 1px solid var(--edge); backdrop-filter: blur(16px); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); text-align: center; }
.on-body .cta { width: 100%; padding: 14px; }
.on-body input { font: 900 1.6rem var(--display); text-align: center; letter-spacing: 0.3em; text-transform: uppercase; padding: 12px; border-radius: 14px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.06); color: #fff; width: 100%; box-sizing: border-box; }
.on-body .code { font: 900 2.6rem var(--display); letter-spacing: 0.25em; background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
.on-body p { margin: 0; color: var(--ink2); }
.spin { width: 44px; height: 44px; margin: 6px auto; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.12); border-top-color: #ffd056; animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.err { color: #ff8a8a !important; }

/* scoreboard */
.board { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45)); }
.side { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--glass2); backdrop-filter: blur(12px); border: 1px solid var(--edge); }
.s0 { border-radius: 18px 0 0 18px; border-right: 0; box-shadow: inset 4px 0 0 var(--blue); }
.s1 { border-radius: 0 18px 18px 0; border-left: 0; box-shadow: inset -4px 0 0 var(--red); }
.side img { width: 44px; height: 44px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); }
.who { display: grid; gap: 5px; min-width: 96px; max-width: 150px; min-width: 0; }
.who b { min-width: 0; }
.s1 .who { justify-items: end; }
.who b { font: 800 0.92rem var(--display); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.pw { width: 100px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.pw i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #ffb020, #ff5a1a); transition: width 0.2s; }
.s1 .pw i { margin-left: auto; }
.pw.full i { background: linear-gradient(90deg, #fff1a0, #ffb020, #ff4010); animation: pulse 0.5s ease-in-out infinite alternate; box-shadow: 0 0 12px #ffb020; }
@keyframes pulse { to { filter: brightness(1.5); } }
.mid { display: grid; place-items: center; padding: 4px 16px; background: linear-gradient(180deg, #1a2238, #0b0f1c); border-top: 1px solid var(--edge); border-bottom: 1px solid var(--edge); }
.score { display: flex; align-items: center; gap: 8px; font: 900 1.9rem var(--display); line-height: 1; }
.score span { color: var(--ink3); font-size: 1.3rem; }
.score b.pop { animation: pop 0.6s; }
@keyframes pop { 30% { transform: scale(1.6); color: #ffd056; } }
.clock { font: 800 0.95rem var(--display); color: #ffe39a; letter-spacing: 0.06em; }
.clock.hot { color: #ff7070; animation: pulse 0.5s infinite alternate; }
.pause-btn { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); }

.banner { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none; text-align: center; transition: opacity 0.25s, transform 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
.banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner b { display: block; font: 900 clamp(3rem, 12vw, 7rem) var(--display); line-height: 1; letter-spacing: 0.04em; background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 0 rgba(90, 50, 0, 0.6)) drop-shadow(0 16px 30px rgba(0, 0, 0, 0.5)); }
.banner small { display: inline-block; margin-top: 8px; padding: 6px 18px; border-radius: 99px; background: var(--glass2); font: 800 1.05rem var(--display); }
.banner.blue b { background: linear-gradient(180deg, #e2efff, #6aa6ff 50%, #2f62ff); -webkit-background-clip: text; background-clip: text; }
.banner.red b { background: linear-gradient(180deg, #ffe8e0, #ff7a6a 50%, #e8202a); -webkit-background-clip: text; background-clip: text; }
.banner.small b { font-size: clamp(1.6rem, 6vw, 3rem); }

.keys-help { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: grid; gap: 4px; text-align: center; color: var(--ink2); font-size: 0.85rem; padding: 8px 16px; border-radius: 14px; background: var(--glass); transition: opacity 0.6s; white-space: nowrap; }
.keys-help.fade { opacity: 0; }

/* touch controls */
.touch { position: absolute; inset: auto 0 0 0; height: 46%; display: none; pointer-events: none; }
.touch.on { display: block; }
.tpad { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; pointer-events: auto; }
.tpad.l { left: max(16px, env(safe-area-inset-left)); }
.tpad.r { right: max(16px, env(safe-area-inset-right)); }
.tb { width: 74px; height: 74px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.28); background: rgba(10, 14, 26, 0.42); backdrop-filter: blur(6px); display: grid; place-items: center; font-size: 1.8rem; color: #fff; touch-action: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.tb.down { background: rgba(255, 208, 86, 0.45); transform: scale(0.94); }
.tb.kick { width: 86px; height: 86px; background: rgba(255, 140, 40, 0.38); }
.tb.kick.full { box-shadow: 0 0 0 3px #ffb020, 0 0 24px #ff7a10; }
.two .tb { width: 58px; height: 58px; font-size: 1.35rem; }
.two .tb.kick { width: 64px; height: 64px; }
.two .tpad { gap: 8px; }
.two .tpad.l2 { left: auto; right: auto; }
.tpad.b0 .tb { border-color: rgba(100, 160, 255, 0.6); }
.tpad.b1 .tb { border-color: rgba(255, 110, 110, 0.6); }
.rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate { display: flex; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); flex-direction: column; align-items: center; gap: 8px; padding: 16px 22px; border-radius: 18px; background: var(--glass2); text-align: center; width: 70vw; pointer-events: none; animation: fadeout 0.6s 3.5s forwards; }
  .rotate span { font-size: 2rem; }
}
@keyframes fadeout { to { opacity: 0; } }

/* modal */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(5, 8, 15, 0.55); backdrop-filter: blur(6px); animation: fade 0.25s; }
@keyframes fade { from { opacity: 0; } }
.mcard { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-sizing: border-box; padding: 24px; border-radius: 26px; background: linear-gradient(180deg, rgba(30, 38, 62, 0.96), rgba(12, 16, 28, 0.97)); border: 1px solid var(--edge); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08); text-align: center; display: grid; gap: 12px; animation: up 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes up { from { transform: translateY(30px) scale(0.95); opacity: 0; } }
.mcard h2 { margin: 0; font: 900 2rem var(--display); background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mcard .final { display: flex; align-items: center; justify-content: center; gap: 16px; }
.mcard .final img { width: 64px; height: 64px; border-radius: 16px; background: rgba(255, 255, 255, 0.07); }
.mcard .final b { font: 900 2.6rem var(--display); }
.mcard .final .b { color: #8db8ff; } .mcard .final .r { color: #ff9a9a; }
.mcard p { margin: 0; color: var(--ink2); }
.mcard .xp { color: #8affb5; font-weight: 800; }
.mcard .btns { display: grid; gap: 10px; margin-top: 4px; }
.mcard .cta { padding: 13px; width: 100%; }
.trophy { font-size: 4rem; animation: bob 1.4s ease-in-out infinite; filter: drop-shadow(0 8px 24px rgba(255, 208, 86, 0.6)); }
.cup-path { display: flex; justify-content: center; gap: 6px; }
.cup-path i { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-style: normal; font-size: 0.8rem; font-weight: 900; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge); overflow: hidden; }
.cup-path i img { width: 100%; height: 100%; }
.cup-path i.done { border-color: #57d48a; box-shadow: 0 0 0 1px #57d48a; }
.cup-path i.cur { border-color: #ffd056; box-shadow: 0 0 0 2px #ffd056; }
.cup-path i.lock img { filter: grayscale(1) brightness(0.5); }

@media (max-width: 760px) {
  .modes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 30px; }
  .mode { padding: 12px; }
  .mode b { font-size: 1rem; }
  .mode small { font-size: 0.78rem; }
  .tip { display: none; }
}
@media (max-height: 500px) {
  .modes { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-top: 10px; }
  .mode small { display: none; }
  .mode { padding: 10px 12px; }
  .mi { font-size: 1.3rem; }
  .tip { display: none; }
  .hero { width: 74px; } .hero img { width: 58px; height: 58px; }
  .sel-body { gap: 8px; padding-top: 20px; }
  .side img { width: 34px; height: 34px; }
  .who { max-width: 96px; } .who b { max-width: 96px; } .pw { width: 70px; }
  .score { font-size: 1.5rem; }
  .side { padding: 4px 8px; }
  .who b { font-size: 0.8rem; }
  .tb { width: 62px; height: 62px; } .tb.kick { width: 72px; height: 72px; }
}
