/* Primordia UI: cut-paper stickers on murky water. Bone paper, ink outlines, hard offset shadows,
   slightly tilted, two typefaces (Lilita One for display, Grandstander for everything else). */
:root {
  --ink: #0d1618;
  --bone: #f1e6cf;
  --bone-2: #e3d4b4;
  --coral: #e86a4f;
  --amber: #ffc857;
  --mint: #6fd6b4;
  --deep: #0f2e33;
  --shadow: 5px 5px 0 var(--ink);
  --display: 'Lilita One', 'Arial Black', sans-serif;
  --body: 'Grandstander', 'Trebuchet MS', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--bone); font-family: var(--body); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
.hidden { display: none !important; }
button { font-family: var(--body); cursor: pointer; }
kbd { display: inline-block; font-family: var(--body); font-weight: 800; font-size: 12px; line-height: 1; padding: 4px 7px 5px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; background: var(--bone); color: var(--ink); margin: 0 2px; }

.paper { background: var(--bone); color: var(--ink); border: 3px solid var(--ink); border-radius: 18px 14px 20px 12px; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- title */
#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden; background: radial-gradient(ellipse at center, rgba(8,26,30,0.1), rgba(4,12,14,0.65)); }
.fit { display: flex; flex-direction: column; align-items: center; gap: 14px; transform-origin: center center; flex: none; }
#death { overflow: hidden; }
#logo { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(52px, 11vw, 124px); letter-spacing: 2px; line-height: 0.95; color: var(--bone); display: flex; }
#logo span { display: inline-block; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 6px 0 var(--ink); animation: bob 3.2s ease-in-out infinite; }
#logo span:nth-child(odd) { color: var(--amber); }
#logo span:nth-child(3n) { color: var(--coral); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
.tag { margin: -4px 0 6px; font-size: 18px; font-weight: 700; color: var(--bone); opacity: 0.9; text-shadow: 0 2px 0 var(--ink); }
#menu { display: grid; grid-template-columns: 240px 320px; grid-template-rows: auto auto; gap: 14px 22px; padding: 20px 22px 22px; transform: rotate(-0.6deg); max-width: 100%; }
#preview-wrap { grid-row: 1; width: 240px; height: 240px; border-radius: 50%; border: 3px solid var(--ink); background: radial-gradient(circle at 40% 35%, #25585a, #0c2327 72%); overflow: hidden; box-shadow: inset 0 0 0 8px rgba(241,230,207,0.08); align-self: center; }
#preview { width: 240px; height: 240px; display: block; }
#custom { display: flex; flex-direction: column; gap: 5px; }
.lbl { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.7; margin-top: 4px; }
#name { font-family: var(--body); font-weight: 800; font-size: 20px; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 10px 12px 9px 13px; background: #fffaf0; color: var(--ink); outline: none; width: 100%; }
#name:focus { box-shadow: 3px 3px 0 var(--coral); }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--ink); padding: 0; position: relative; transition: transform 0.1s; }
.sw.on { transform: scale(1.18); box-shadow: 0 0 0 3px var(--bone), 0 0 0 5px var(--ink); }
.chip { font-weight: 800; font-size: 13px; padding: 4px 10px 5px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fffaf0; color: var(--ink); position: relative; transition: transform 0.1s; }
.chip:hover, .sw:hover { transform: translateY(-2px); }
.chip.on { background: var(--ink); color: var(--bone); }
.locked { opacity: 0.45; cursor: not-allowed; }
.locked::after { content: ''; position: absolute; right: -5px; top: -6px; width: 13px; height: 13px; border-radius: 3px; background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Crect x='2.5' y='5.5' width='7' height='5' rx='1' fill='%23f1e6cf'/%3E%3Cpath d='M4 5.5V4a2 2 0 0 1 4 0v1.5' fill='none' stroke='%23f1e6cf' stroke-width='1.4'/%3E%3C/svg%3E") center/11px no-repeat; }
.big { grid-column: 1 / -1; font-family: var(--display); font-size: 30px; letter-spacing: 1px; padding: 10px 26px 12px; color: var(--bone); background: var(--coral); border: 3px solid var(--ink); border-radius: 14px 18px 12px 16px; box-shadow: var(--shadow); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; transition: transform 0.08s, box-shadow 0.08s; }
.big:hover { transform: translate(-1px, -2px) rotate(-0.5deg); box-shadow: 7px 8px 0 var(--ink); }
.big:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.ghost { font-weight: 800; font-size: 15px; padding: 8px 14px; border: 3px solid var(--ink); border-radius: 12px; background: transparent; color: var(--ink); }
#online { margin: 4px 0 0; font-weight: 700; text-shadow: 0 2px 0 var(--ink); }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; font-weight: 700; font-size: 14px; text-shadow: 0 2px 0 var(--ink); }

/* ---------------------------------------------------------------- hud */
#feed { position: fixed; left: 16px; top: 14px; display: flex; flex-direction: column; gap: 5px; pointer-events: none; max-width: 46vw; }
.kf { font-weight: 700; font-size: 14px; background: rgba(13,22,24,0.72); border: 2px solid rgba(241,230,207,0.25); border-radius: 10px; padding: 4px 10px; animation: kin 0.25s ease-out; width: fit-content; }
.kf b { color: var(--bone); } .kf i { font-style: normal; color: var(--coral); }
@keyframes kin { from { transform: translateX(-20px); opacity: 0; } }
#board { position: fixed; right: 16px; top: 14px; width: 212px; padding: 10px 12px 10px; transform: rotate(0.8deg); pointer-events: none; }
#board h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: 0.5px; }
#lb { margin: 0; padding: 0; list-style: none; counter-reset: n; font-weight: 700; font-size: 14px; }
#lb li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; counter-increment: n; }
#lb li::before { content: counter(n); width: 18px; opacity: 0.5; }
#lb li span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lb li.me { color: var(--coral); }
#myrank { font-size: 12px; font-weight: 800; opacity: 0.6; margin-top: 4px; }
#minimap { position: fixed; right: 16px; bottom: 16px; width: 150px; height: 150px; pointer-events: none; }

#bottom { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; pointer-events: none; }
#tierbar { position: relative; width: min(46vw, 420px); height: 30px; border: 3px solid var(--ink); border-radius: 999px; background: rgba(13,22,24,0.8); overflow: hidden; box-shadow: 4px 4px 0 var(--ink); }
#tierfill { position: absolute; inset: 0 auto 0 0; width: 0; background: repeating-linear-gradient(-45deg, var(--amber) 0 12px, #ffb938 12px 24px); transition: width 0.25s; }
#tierbar.max #tierfill { background: repeating-linear-gradient(-45deg, var(--mint) 0 12px, #54c09d 12px 24px); }
#tiertext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 17px; letter-spacing: 0.5px; color: var(--bone); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.slot { position: relative; width: 58px; height: 58px; border-radius: 50%; border: 3px solid var(--ink); background: var(--bone); color: var(--ink); display: grid; place-items: center; box-shadow: 4px 4px 0 var(--ink); overflow: hidden; }
.slot svg { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; position: relative; }
.slot kbd { position: absolute; bottom: -2px; font-size: 9px; padding: 2px 4px 3px; border-width: 2px; }
.slot .cd { position: absolute; inset: 0; background: conic-gradient(rgba(13,22,24,0.72) var(--p, 0%), transparent 0); }
.slot.ready { animation: ready 0.35s ease-out; }
@keyframes ready { 50% { transform: scale(1.18); } }
.slot.empty { opacity: 0.35; }
#slot-act:not(.empty) { background: var(--mint); }

#evolve { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) scale(var(--s, 1)); transform-origin: bottom center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.evo-title { display: flex; align-items: baseline; gap: 10px; }
.evo-title span { font-family: var(--display); font-size: 34px; color: var(--amber); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); transform: rotate(-3deg); display: inline-block; animation: pulse 1s ease-in-out infinite; }
.evo-title small { font-weight: 800; font-size: 14px; text-shadow: 0 2px 0 var(--ink); }
@keyframes pulse { 50% { transform: rotate(-3deg) scale(1.08); } }
#cards { display: flex; gap: 14px; }
.card { width: 178px; padding: 8px 10px 10px; background: var(--bone); color: var(--ink); border: 3px solid var(--ink); border-radius: 16px 12px 18px 14px; box-shadow: var(--shadow); text-align: left; position: relative; animation: deal 0.35s cubic-bezier(.2,1.6,.4,1) backwards; transition: transform 0.1s; }
.card:nth-child(1) { transform: rotate(-2.5deg); animation-delay: 0s; }
.card:nth-child(2) { transform: rotate(1deg) translateY(-6px); animation-delay: 0.06s; }
.card:nth-child(3) { transform: rotate(2.5deg); animation-delay: 0.12s; }
.card:hover { transform: rotate(0) translateY(-10px) scale(1.04); z-index: 2; }
.card.act { background: #d9f2e6; }
@keyframes deal { from { transform: translateY(80px) rotate(-10deg); opacity: 0; } }
.card canvas { width: 100%; height: 92px; display: block; border-radius: 10px; border: 2.5px solid var(--ink); background: radial-gradient(circle at 45% 40%, #25585a, #0c2327 80%); }
.card h4 { margin: 6px 0 0; font-family: var(--display); font-weight: 400; font-size: 20px; }
.card .pips { position: absolute; right: 10px; top: 106px; display: flex; gap: 3px; }
.card .pips i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); }
.card .pips i.on { background: var(--coral); }
.card p { margin: 2px 0 0; font-size: 13px; font-weight: 700; line-height: 1.2; }
.card p.lv { color: #9a3b26; font-weight: 800; }
.card .tagk { position: absolute; top: -12px; left: -10px; }
.card .tagk kbd { font-size: 15px; background: var(--amber); }
.card .kind { position: absolute; top: 12px; right: 12px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; background: var(--ink); color: var(--mint); padding: 2px 6px; border-radius: 6px; }

#toolbar { position: fixed; left: 16px; bottom: 16px; display: flex; gap: 8px; z-index: 5; }
#toolbar button { width: 40px; height: 40px; border-radius: 12px; border: 3px solid var(--ink); background: var(--bone); box-shadow: 3px 3px 0 var(--ink); display: grid; place-items: center; padding: 0; }
#toolbar button.off { opacity: 0.5; }
#toolbar svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#conn { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--coral); color: var(--ink); border: 3px solid var(--ink); padding: 6px 14px; border-radius: 12px; font-weight: 800; box-shadow: var(--shadow); z-index: 10; }

/* ---------------------------------------------------------------- death */
#death { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(4,12,14,0.45); padding: 16px; animation: fadein 0.5s; }
@keyframes fadein { from { opacity: 0; } }
#death-card { padding: 20px 26px 18px; width: min(420px, 100%); text-align: center; transform: rotate(-1deg); animation: deal 0.45s cubic-bezier(.2,1.5,.4,1); }
#death-card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 56px; color: var(--coral); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
#death-by { margin: 4px 0 12px; font-weight: 800; font-size: 17px; }
#stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.st { border: 2.5px solid var(--ink); border-radius: 12px; padding: 6px 4px; background: #fffaf0; }
.st b { display: block; font-family: var(--display); font-weight: 400; font-size: 24px; }
.st span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; }
#unlocked:empty { display: none; }
#unlocked { margin-bottom: 12px; padding: 8px; border: 2.5px dashed var(--ink); border-radius: 12px; font-weight: 800; background: #fff1c9; }
.btns { display: flex; gap: 10px; justify-content: center; align-items: center; }
.btns .big { font-size: 26px; }
.hint { margin: 10px 0 0; font-size: 13px; font-weight: 700; opacity: 0.6; }

/* ---------------------------------------------------------------- touch */
#touch { display: none; }
body.touch #touch { display: block; }
#stick { position: fixed; left: 28px; bottom: 90px; width: 130px; height: 130px; border-radius: 50%; border: 3px solid rgba(241,230,207,0.4); background: rgba(13,22,24,0.35); }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: var(--bone); border: 3px solid var(--ink); }
.tbtn { position: fixed; width: 76px; height: 76px; border-radius: 50%; border: 3px solid var(--ink); font-family: var(--display); font-size: 18px; color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
#t-dash { right: 24px; bottom: 190px; background: var(--amber); }
#t-act { right: 110px; bottom: 130px; background: var(--mint); }
body.touch #minimap { width: 100px; height: 100px; top: auto; }
body.touch #slot-dash, body.touch #slot-act { display: none; }

@media (max-height: 560px) and (min-width: 721px) { #menu { grid-template-columns: 180px 320px; } #preview-wrap, #preview { width: 180px; height: 180px; } .keys { display: none; } }
@media (max-width: 720px) {
  #menu { grid-template-columns: 1fr; justify-items: center; padding: 14px; }
  #preview-wrap, #preview { width: 160px; height: 160px; }
  #custom { width: 100%; }
  #board { width: 150px; font-size: 12px; padding: 6px 8px; }
  #board h3 { font-size: 13px; }
  #lb { font-size: 12px; }
  #lb li:nth-child(n+6) { display: none; }
  #cards { gap: 6px; }
  .card { width: 31vw; padding: 6px; }
  .card canvas { height: 60px; }
  .card p:not(.lv) { display: none; }
  .card .pips { top: 70px; }
  .card h4 { font-size: 15px; }
  #evolve { bottom: 80px; }
  #tierbar { width: 52vw; }
  .keys { display: none; }
  #feed { display: none; }
}

/* short screens (landscape phones, small laptops): compact HUD so nothing covers the soup */
@media (max-height: 560px) {
  #board { transform: rotate(0.8deg) scale(0.72); transform-origin: top right; }
  #lb li:nth-child(n+6) { display: none; }
  #minimap { width: 100px; height: 100px; }
  #feed { display: none; }
  #bottom { bottom: 10px; gap: 10px; }
  .slot { width: 46px; height: 46px; } .slot svg { width: 22px; height: 22px; }
  #tierbar { height: 24px; } #tiertext { font-size: 14px; }
  #toolbar { bottom: 10px; } #toolbar button { width: 34px; height: 34px; }
  #stick { bottom: 40px; width: 110px; height: 110px; }
  #t-dash { bottom: 110px; width: 64px; height: 64px; } #t-act { bottom: 60px; right: 96px; width: 64px; height: 64px; }
}

/* Honk Party login (sq-loader.js -> hub sso.js): sticker-style. Gold = server-verified account names only. */
.acct { color: #ffc53d !important; white-space: nowrap; }
.seal { width: 0.95em; height: 0.95em; vertical-align: -0.12em; margin-right: 0.2em; }
.seal path { fill: #ffc53d; stroke: var(--ink); stroke-width: 1.2; }
.seal .tick { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#menu .sq-gate { gap: 6px; margin-top: -2px; }
#menu .sq-or { font-weight: 800; font-size: 13px; opacity: 1; gap: 6px; }
#menu .sq-or > span { opacity: 0.6; }
#menu .sq-or > span:nth-of-type(2) { display: none; }
#menu .sq-btn { color: var(--ink); background: #fffaf0; border: 2.5px solid var(--ink); border-radius: 999px; padding: 3px 11px 4px; box-shadow: 2px 2px 0 var(--ink); line-height: 1.1; }
#menu .sq-btn[data-sq="register"] { background: var(--amber); }
#menu .sq-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); filter: none; }
#menu .sq-btn:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
#menu .sq-me { background: var(--ink); color: var(--bone); border: 3px solid var(--ink); border-radius: 10px 12px 9px 13px; padding: 7px 10px; gap: 8px; box-shadow: 3px 3px 0 var(--coral); flex-wrap: nowrap; }
#menu .sq-me small { opacity: 0.7; font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; white-space: nowrap; }
#menu .sq-me .sq-verified { font-size: 19px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#menu .sq-me .sq-seal path { stroke: none; }
#menu .sq-me .sq-btn { margin-left: auto; background: transparent; color: var(--bone); border-color: var(--bone); box-shadow: none; opacity: 0.8; font-size: 12px; padding: 2px 9px 3px; white-space: nowrap; }
#lb .acct, .kf .acct { text-shadow: 0 1px 0 var(--ink); }

/* ---------------------------------------------------------------- touch layout (phones, tablets)
   Stick appears under the finger (anywhere free), Dash / Use in the right thumb zone with cooldown rings, tier bar
   and HUD at the top, evolve cards hanging under the tier bar (the board and minimap step aside while you choose). */
html, body { overscroll-behavior: none; }
body.touch #hud, body.touch #game { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#touch, #stick, #knob { pointer-events: none; }
#touch .tbtn { pointer-events: auto; touch-action: none; }
#stick { opacity: 0.35; transition: opacity 0.15s; }
#stick.on { opacity: 1; }
.tbtn { overflow: hidden; display: grid; place-items: center; padding: 0; -webkit-tap-highlight-color: transparent; }
.tbtn .cd { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(13,22,24,0.7) var(--p, 0%), transparent 0); pointer-events: none; }
.tbtn .lbl { position: relative; font-size: 15px; line-height: 1; }
.tbtn svg { position: relative; width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: -6px; }
.tbtn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.tbtn.ready { animation: ready 0.35s ease-out; }
#t-act.empty { opacity: 0.35; }
#t-act.empty svg { display: none; }
#t-act .lbl { font-size: 12px; max-width: 64px; text-align: center; }
body.touch #t-dash { right: calc(16px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 88px; height: 88px; }
body.touch #t-act { right: calc(118px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); width: 74px; height: 74px; }
body.touch #stick { left: calc(24px + env(safe-area-inset-left)); bottom: calc(40px + env(safe-area-inset-bottom)); top: auto; }
body.touch #bottom { top: calc(10px + env(safe-area-inset-top)); bottom: auto; }
body.touch #minimap { left: calc(10px + env(safe-area-inset-left)); right: auto; top: calc(52px + env(safe-area-inset-top)); bottom: auto; width: 88px; height: 88px; }
body.touch #board { top: calc(52px + env(safe-area-inset-top)); }
body.touch #toolbar { left: auto; right: calc(10px + env(safe-area-inset-right)); bottom: auto; top: calc(10px + env(safe-area-inset-top)); }
body.touch #toolbar button { width: 32px; height: 32px; }
body.touch #toolbar svg { width: 18px; height: 18px; }
body.touch #tierbar { width: min(52vw, 360px); height: 26px; }
body.touch.evolving #board, body.touch.evolving #minimap { opacity: 0; transition: opacity 0.2s; }
body.touch #evolve { z-index: 20; transform-origin: top center; }
body.touch .card { width: min(31vw, 190px); padding: 6px 7px 8px; }
body.touch .card canvas { height: 64px; }
body.touch .card h4 { font-size: 16px; line-height: 1.05; }
body.touch .card p.lv { display: block; font-size: 12px; }
body.touch .card .pips { top: 74px; }
body.touch .card .tagk { display: none; }
body.touch .evo-title span { font-size: 28px; }
@media (hover: none) { .card:hover { transform: none; } .card:active { transform: scale(0.96); } }
@media (max-height: 560px) {
  body.touch #bottom { top: calc(6px + env(safe-area-inset-top)); }
  body.touch #minimap, body.touch #board { top: calc(40px + env(safe-area-inset-top)); }
  body.touch #t-dash { width: 72px; height: 72px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  body.touch #t-act { width: 62px; height: 62px; right: calc(100px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); }
  body.touch #stick { bottom: calc(20px + env(safe-area-inset-bottom)); }
  body.touch .card canvas { height: 44px; }
  body.touch .card .pips { top: 54px; }
}
body.touch .card p:not(.lv) { display: none; }
body.touch .card .pips, body.touch .card .pips { top: 12px; right: 13px; }
body.touch .card .kind { top: auto; bottom: auto; left: 13px; right: auto; top: 12px; }
@media (max-height: 560px) {
  body.touch .card canvas { display: none; }
  body.touch .card { padding: 8px 10px 10px; }
  body.touch .card h4 { margin-top: 14px; }
  body.touch .card .pips { top: 10px; right: 10px; }
  body.touch .card .kind { top: 8px; left: 10px; }
}
