/* COLORIBUS MAXIMUS. Everything is round, everything wobbles. */
:root {
  --bg: #0b0816;
  --glass: rgba(18, 12, 34, 0.82);
  --edge: rgba(255, 255, 255, 0.12);
  --ink: #f4ecff;
  --dim: #a99cc8;
  --mag: #ff3fa4;
  --cyan: #2fe0ff;
  --lime: #9dff3a;
  --gold: #ffd84a;
  --font: 'Poppins', 'Avenir Next', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; }
button { font-family: inherit; color: inherit; }
[hidden] { display: none !important; }

@keyframes blobby {
  0%   { border-radius: 42% 58% 55% 45% / 48% 44% 56% 52%; }
  33%  { border-radius: 55% 45% 42% 58% / 56% 52% 48% 44%; }
  66%  { border-radius: 48% 52% 58% 42% / 44% 58% 42% 56%; }
  100% { border-radius: 42% 58% 55% 45% / 48% 44% 56% 52%; }
}
@keyframes softblob {
  0%   { border-radius: 26px 34px 28px 32px / 30px 26px 34px 28px; }
  50%  { border-radius: 34px 26px 32px 28px / 26px 34px 28px 32px; }
  100% { border-radius: 26px 34px 28px 32px / 30px 26px 34px 28px; }
}
@keyframes jiggle {
  0%, 100% { transform: translateY(0) scale(1, 1) rotate(0deg); }
  25% { transform: translateY(-3px) scale(1.06, 0.95) rotate(-3deg); }
  50% { transform: translateY(1px) scale(0.95, 1.06) rotate(2deg); }
  75% { transform: translateY(-1px) scale(1.03, 0.98) rotate(-1deg); }
}

/* ---------------- HUD */
#hud { position: fixed; top: 12px; right: 12px; display: flex; gap: 8px; align-items: flex-start; z-index: 20; pointer-events: none; }
.chip { height: 46px; background: var(--glass); border: 1px solid var(--edge); padding: 7px 14px 7px 10px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; animation: softblob 7s ease-in-out infinite; backdrop-filter: blur(6px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }
.chip b { font-variant-numeric: tabular-nums; min-width: 2.2em; }
.chip.res.full b { color: #ff7a7a; }
.dot { width: 16px; height: 16px; display: inline-block; animation: blobby 4s ease-in-out infinite; }
.dot-p { background: conic-gradient(from 0deg, #ff3fa4, #ffd84a, #9dff3a, #2fe0ff, #9b5cff, #ff3fa4); }
.dot-s { background: radial-gradient(circle at 35% 30%, #ffffff, #bfe8ff 45%, #8ab0ff); box-shadow: 0 0 10px rgba(190, 230, 255, 0.7); }
.dot-b { background: radial-gradient(circle at 35% 30%, #fff, #9b5cff 55%, #4a2a8a); }
.chip.apm { padding: 3px 14px 3px 3px; height: 46px; display: grid; grid-template-columns: 40px auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; }
#apm-blob { width: 40px; height: 40px; grid-row: span 2; }
.apm-num { display: flex; align-items: baseline; gap: 6px; line-height: 1; }
.apm-num b { font-size: 21px; line-height: 1; }
.apm-num span { font-size: 12px; color: var(--dim); letter-spacing: 0.08em; }
#apm-sub { font-size: 10px; line-height: 1.1; color: var(--dim); font-weight: 400; white-space: nowrap; }
#clock { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 20; background: var(--glass); border: 1px solid var(--edge); padding: 5px 16px; font-weight: 600; font-variant-numeric: tabular-nums; animation: softblob 9s ease-in-out infinite; pointer-events: none; }
#speed-chip { margin-left: 8px; color: var(--gold); font-size: 13px; }

/* ---------------- bottom panel */
#panel { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 20; width: min(1000px, calc(100vw - 20px)); height: 214px; display: grid; grid-template-columns: 214px 1fr 252px; gap: 10px; padding: 7px; background: var(--glass); border: 1px solid var(--edge); animation: softblob 11s ease-in-out infinite; backdrop-filter: blur(8px); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.mm-wrap { width: 200px; height: 200px; overflow: hidden; animation: softblob 8s ease-in-out infinite reverse; border: 1px solid var(--edge); }
#minimap { width: 200px; height: 200px; display: block; cursor: pointer; }
#selbox { overflow: hidden; padding: 6px 4px; min-width: 0; }
.sel-empty { color: var(--dim); font-size: 13px; padding: 10px; }
.sel-one { display: flex; gap: 12px; align-items: flex-start; }
.portrait { width: 84px; height: 84px; flex: none; animation: jiggle 3.2s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5)); }
.sel-info { min-width: 0; flex: 1; }
.sel-name { font-weight: 600; font-size: 17px; margin-bottom: 4px; }
.sel-name .foe { color: #ff8a9a; font-weight: 400; font-size: 13px; }
.sel-line { font-size: 13px; margin-top: 4px; }
.sel-line.dim { color: var(--dim); }
.hpbar { position: relative; height: 16px; background: rgba(0, 0, 0, 0.45); border-radius: 10px; overflow: hidden; max-width: 260px; }
.hpbar i { position: absolute; inset: 0 auto 0 0; border-radius: 10px; }
.hpbar span { position: absolute; left: 8px; top: 0; font-size: 11px; line-height: 16px; font-weight: 600; color: #160d24; text-shadow: 0 0 3px rgba(255, 255, 255, 0.6); }
.queue { display: flex; gap: 6px; margin-top: 10px; }
.qitem { width: 46px; height: 46px; padding: 0; position: relative; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--edge); animation: blobby 6s ease-in-out infinite; cursor: pointer; overflow: hidden; }
.qitem img { width: 100%; height: 100%; }
.qitem i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--gold); }
.qitem:hover { background: rgba(255, 80, 100, 0.25); }
.sel-grid { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 4px; }
.sel-mini { width: 44px; height: 44px; padding: 0; position: relative; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--edge); border-radius: 46% 54% 50% 50%; cursor: pointer; overflow: hidden; }
.sel-mini img { width: 100%; height: 100%; }
.sel-mini i { position: absolute; left: 4px; bottom: 2px; height: 3px; border-radius: 2px; max-width: calc(100% - 8px); }
.sel-mini:hover { background: rgba(255, 255, 255, 0.14); }
.sel-more { align-self: center; color: var(--dim); font-size: 13px; }
#card { display: grid; grid-template-columns: repeat(4, 58px); grid-template-rows: repeat(3, 62px); gap: 6px; align-content: center; justify-content: end; }
.cbtn { position: relative; width: 58px; height: 62px; padding: 0; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03)); border: 1px solid var(--edge); cursor: pointer; animation: blobby 6s ease-in-out infinite; transition: transform 0.12s, background 0.12s; }
.cbtn:nth-child(2n) { animation-delay: -2s; }
.cbtn:nth-child(3n) { animation-delay: -4s; }
.cbtn img { width: 44px; height: 44px; display: block; margin: 2px auto 0; pointer-events: none; }
.cbtn kbd { position: absolute; top: 2px; left: 6px; font-family: var(--mono); font-size: 10px; color: var(--gold); }
.cbtn .cost { position: absolute; bottom: 1px; left: 0; right: 0; text-align: center; font-size: 10px; line-height: 12px; }
.cbtn .cost b { margin: 0 2px; font-weight: 600; }
.cp { color: #ff8ae0; }
.cs { color: #cfeeff; }
.cbtn:hover { transform: scale(1.08); background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.06)); }
.cbtn:active { transform: scale(0.94); }
.cbtn.off { opacity: 0.42; }
.cbtn.on { background: radial-gradient(circle at 35% 30%, rgba(255, 216, 74, 0.5), rgba(255, 216, 74, 0.12)); border-color: var(--gold); }
.cbtn.empty { visibility: hidden; }

/* ---------------- toasts, tooltip, pause */
#toasts { position: fixed; left: 50%; bottom: 240px; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--glass); border: 1px solid var(--edge); padding: 7px 18px; font-size: 14px; font-weight: 600; animation: softblob 5s ease-in-out infinite, pop 0.35s cubic-bezier(.2, 1.6, .4, 1); transition: opacity 0.5s, transform 0.5s; text-align: center; max-width: 80vw; }
.toast.warn { color: #ffd2a0; border-color: rgba(255, 170, 90, 0.5); }
.toast.bad { color: #ffb3b8; border-color: rgba(255, 80, 100, 0.6); }
.toast.good { color: #c8ffcf; border-color: rgba(120, 255, 150, 0.45); }
.toast.big { font-size: 15px; color: #fff; border-color: rgba(255, 63, 164, 0.6); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#tooltip { position: fixed; z-index: 40; width: 260px; background: rgba(14, 9, 28, 0.95); border: 1px solid var(--edge); padding: 10px 12px; border-radius: 16px 20px 18px 14px; font-size: 13px; pointer-events: none; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }
#tooltip kbd { font-family: var(--mono); color: var(--gold); font-size: 11px; margin-left: 4px; }
.tip-cost { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.tip-desc { margin-top: 5px; color: var(--dim); line-height: 1.4; }
#pause-ov { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; font-size: 72px; font-weight: 600; letter-spacing: 0.1em; color: #fff; background: rgba(8, 5, 18, 0.45); text-shadow: 0 0 30px var(--mag); pointer-events: none; animation: jiggle 2.4s ease-in-out infinite; }

/* ---------------- game orb (gold), menu */
#cm-orb { position: fixed; left: 70px; top: 12px; z-index: 45; width: 46px; height: 46px; padding: 0; border: 2px solid rgba(255, 205, 100, 0.8); background: radial-gradient(circle at 32% 28%, rgba(255, 217, 122, 0.45), rgba(30, 24, 10, 0.8)); cursor: pointer; box-shadow: 0 0 14px rgba(255, 174, 0, 0.35); animation: blobby 5s ease-in-out infinite; display: flex; align-items: center; justify-content: center; }
#cm-orb span { width: 22px; height: 22px; background: conic-gradient(from 0deg, #ff3fa4, #ffd84a, #9dff3a, #2fe0ff, #9b5cff, #ff3fa4); animation: blobby 2.6s ease-in-out infinite, spin 9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#cm-orb:hover { box-shadow: 0 0 22px rgba(255, 174, 0, 0.65); }
#cm-menu { position: fixed; left: 70px; top: 66px; z-index: 45; min-width: 230px; padding: 12px; border: 1px solid rgba(255, 205, 100, 0.4); background: rgba(14, 10, 26, 0.94); backdrop-filter: blur(6px); display: flex; flex-direction: column; gap: 6px; animation: softblob 7s ease-in-out infinite; }
.cm-title { font-size: 12px; letter-spacing: 0.08em; color: var(--gold); font-weight: 600; margin-bottom: 2px; }
.cm-title span { color: var(--dim); font-weight: 400; }
#cm-menu button { text-align: left; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--edge); padding: 8px 12px; font-size: 14px; border-radius: 18px 22px 20px 16px; cursor: pointer; }
#cm-menu button:hover { background: rgba(255, 216, 74, 0.18); }

/* ---------------- setup */
#setup { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 70px 16px 16px; overflow-y: auto; background: radial-gradient(ellipse at center, rgba(11, 8, 22, 0.35), rgba(11, 8, 22, 0.8)); }
.setup-card { width: min(780px, 100%); max-height: 100%; text-align: center; padding: 26px 30px 20px; background: rgba(14, 9, 28, 0.78); border: 1px solid var(--edge); backdrop-filter: blur(10px); animation: softblob 10s ease-in-out infinite; box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6); overflow-y: auto; }
.title { margin: 0; font-size: clamp(34px, 7.2vw, 74px); font-weight: 600; line-height: 1.02; letter-spacing: 0.02em; display: flex; flex-wrap: wrap; justify-content: center; column-gap: 0.4em; }
.title .w { display: inline-flex; }
.title i { font-style: normal; display: inline-block; animation: jiggle 2.2s ease-in-out infinite; text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 24px currentColor; }
.title i:nth-child(6n+1) { color: var(--mag); animation-delay: -0.1s; }
.title i:nth-child(6n+2) { color: var(--gold); animation-delay: -0.5s; }
.title i:nth-child(6n+3) { color: var(--lime); animation-delay: -0.9s; }
.title i:nth-child(6n+4) { color: var(--cyan); animation-delay: -1.3s; }
.title i:nth-child(6n+5) { color: #9b5cff; animation-delay: -1.7s; }
.title i:nth-child(6n+6) { color: #ff9a1f; animation-delay: -2.0s; }
.tag { color: var(--dim); margin: 8px 0 16px; font-size: 15px; }
.opts { display: flex; flex-direction: column; gap: 10px; margin: 0 auto 16px; max-width: 680px; }
.grp { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.grp label { width: 110px; text-align: right; color: var(--dim); font-size: 13px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pill { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--edge); padding: 7px 14px; font-size: 14px; cursor: pointer; animation: blobby 6s ease-in-out infinite; display: inline-flex; align-items: center; gap: 7px; transition: transform 0.12s, background 0.12s; }
.pill:nth-child(2n) { animation-delay: -2.5s; }
.pill:hover { transform: scale(1.06); background: rgba(255, 255, 255, 0.14); }
.pill.on { background: rgba(255, 63, 164, 0.28); border-color: var(--mag); box-shadow: 0 0 16px rgba(255, 63, 164, 0.35); }
.sw { width: 14px; height: 14px; display: inline-block; animation: blobby 3s ease-in-out infinite; }
.actions { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.big-btn { font-size: 22px; font-weight: 600; letter-spacing: 0.06em; padding: 14px 38px; border: 2px solid rgba(255, 255, 255, 0.4); cursor: pointer; color: #fff; background: linear-gradient(120deg, #ff3fa4, #9b5cff 45%, #2fe0ff); background-size: 200% 200%; animation: blobby 4s ease-in-out infinite, flow 5s ease-in-out infinite; box-shadow: 0 10px 30px rgba(255, 63, 164, 0.4); transition: transform 0.12s; }
.big-btn:hover { transform: scale(1.05); }
.big-btn:active { transform: scale(0.96); }
@keyframes flow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.tip { color: var(--ink); font-size: 13px; margin: 14px 0 4px; opacity: 0.85; }
.rank { color: var(--dim); font-size: 12px; margin: 6px auto 0; max-width: 560px; line-height: 1.45; }
.ver { color: rgba(169, 156, 200, 0.6); font-size: 11px; margin: 8px 0 0; }

/* ---------------- end */
#end { position: fixed; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center; padding: 70px 16px 16px; background: rgba(8, 5, 18, 0.55); overflow-y: auto; }
.end-card { width: min(860px, 100%); padding: 24px 28px; background: rgba(14, 9, 28, 0.9); border: 1px solid var(--edge); animation: softblob 10s ease-in-out infinite, pop 0.5s cubic-bezier(.2, 1.5, .4, 1); text-align: center; box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6); }
.end-title { margin: 0 0 6px; font-size: clamp(26px, 4.6vw, 46px); animation: jiggle 2.6s ease-in-out infinite; }
.end-title.victory { color: var(--lime); text-shadow: 0 0 30px rgba(157, 255, 58, 0.5); }
.end-title.defeat, .end-title.surrender { color: #ff7a9a; text-shadow: 0 0 30px rgba(255, 63, 100, 0.45); }
.end-score span { display: block; color: var(--dim); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; }
.end-score b { font-size: 48px; color: var(--gold); }
.end-rank { color: var(--ink); margin: 6px 0 14px; font-size: 14px; }
.apm-rank { display: inline-block; margin-top: 6px; padding: 4px 14px; background: rgba(255, 63, 164, 0.2); border: 1px solid rgba(255, 63, 164, 0.5); animation: blobby 5s ease-in-out infinite; font-weight: 600; }
.end-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; text-align: left; }
.eb-title { color: var(--dim); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
#end-graph { width: 100%; height: 150px; display: block; background: rgba(0, 0, 0, 0.25); border-radius: 18px 24px 20px 16px; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.end-stats div, .end-break div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 5px 10px; background: rgba(255, 255, 255, 0.04); border-radius: 12px; }
.end-stats div { flex-direction: column; }
.end-stats span, .end-break span { color: var(--dim); }
.end-break { display: flex; flex-direction: column; gap: 5px; }
#nogl { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 40px; text-align: center; font-size: 20px; background: var(--bg); }

@media (max-width: 820px) {
  #panel { grid-template-columns: 130px 1fr; height: auto; }
  .mm-wrap, #minimap { width: 130px; height: 130px; }
  #selbox { display: none; }
  #card { grid-template-columns: repeat(4, 50px); grid-template-rows: repeat(3, 52px); }
  .cbtn { width: 50px; height: 52px; }
  .cbtn img { width: 36px; height: 36px; }
  #clock { left: 12px; top: 66px; transform: none; font-size: 13px; padding: 4px 12px; }
  #hud { top: 104px; right: 8px; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 16px); }
  .chip { height: 34px; font-size: 13px; padding: 4px 9px 4px 6px; gap: 5px; }
  .chip b { min-width: 0; }
  .dot { width: 12px; height: 12px; }
  .chip.apm { height: 34px; grid-template-columns: 28px auto; padding: 2px 9px 2px 2px; }
  #apm-blob { width: 28px; height: 28px; }
  .apm-num b { font-size: 16px; }
  .apm-num span { font-size: 10px; }
  #apm-sub { display: none; }
  #toasts { bottom: 200px; }
  .grp label { width: 100%; text-align: center; }
  .end-cols { grid-template-columns: 1fr; }
}
