:root {
  --ink: #2A2E45;
  --sky: #EEF6FF;
  --white: #fff;
  --red: #FF9B9B;
  --green: #B5EBC6;
  --yellow: #FFE9A8;
  --lilac: #DCD3FF;
  --blue: #BFE0FF;
  --line: 2px solid var(--ink);
  --shadow: 3px 3px 0 var(--ink);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #DDE9F7;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  height: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--sky);
  overflow: hidden;
}

@media (min-width: 520px) {
  #app { border-left: var(--line); border-right: var(--line); }
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: absolute;
  top: calc(var(--sat) + 12px);
  left: 12px;
  right: 60px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.pill {
  background: var(--white);
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 7px 12px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.pill b { font-weight: 800; }
#score { font-size: 12px; }
#score b { font-size: 15px; }
#hearts { gap: 4px; }
#hearts svg { width: 19px; height: 19px; display: block; }
#hearts .lost { transform: scale(.85); }
#hearts .pop { animation: pop .35s ease-out; }

.icon-btn {
  position: absolute;
  top: calc(var(--sat) + 12px);
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: var(--line);
  background: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  z-index: 5;
  color: var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

#level-banner {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.6);
  width: min(300px, calc(100% - 48px));
  background: var(--lilac);
  border: var(--line);
  border-radius: 20px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 14px 16px 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
#level-banner b { display: block; font-size: 34px; font-weight: 800; line-height: 1.05; }
#level-banner span { display: block; margin-top: 2px; font-size: 17px; font-weight: 800; }
#level-banner small { display: block; margin-top: 8px; padding-top: 8px; border-top: 2px dashed rgba(42, 46, 69, .25); font-size: 13px; font-weight: 700; }
#level-banner.show { animation: banner 2.8s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6) rotate(-4deg); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06) rotate(1deg); }
  20% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(.95); }
}

#toast {
  position: absolute;
  top: calc(var(--sat) + 66px);
  left: 50%;
  transform: translate(-50%, -8px);
  width: max-content;
  max-width: calc(100% - 32px);
  background: var(--white);
  border: var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 9px 14px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.reject { background: var(--red); }
#toast.pool { background: var(--green); }
#toast.interview { background: var(--yellow); }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 16px) 16px calc(var(--sab) + 16px);
  background: rgba(238, 246, 255, .55);
  overflow-y: auto;
  z-index: 4;
}
.screen[hidden] { display: none; }

.card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  background: var(--white);
  border: var(--line);
  border-radius: 22px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 22px 20px 18px;
  text-align: center;
  animation: rise .3s ease-out;
}

h1, h2 { margin: 0 0 8px; line-height: 1.1; }
h1 { font-size: 40px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 21px; font-weight: 800; }

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  padding: 3px 10px;
  border: var(--line);
  border-radius: 999px;
  background: var(--lilac);
  font-size: 12px;
  font-weight: 700;
}

.howto {
  list-style: none;
  margin: 6px 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 14px;
  align-items: center;
  text-align: left;
  font-size: 17px;
  font-weight: 700;
}
.howto li { display: contents; }
.howto li > :first-child { justify-self: end; }
.chips { display: inline-flex; gap: 6px; }

.chip {
  display: inline-block;
  padding: 4px 10px;
  border: var(--line);
  border-radius: 999px;
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 800;
  font-size: 13px;
}
.chip.reject { background: var(--red); }
.chip.pool { background: var(--green); }
.chip.interview { background: var(--yellow); }

.key {
  display: inline-block;
  min-width: 58px;
  padding: 4px 10px;
  border: var(--line);
  border-radius: 10px;
  box-shadow: 2px 2px 0 var(--ink);
  background: var(--white);
  font-weight: 800;
  font-size: 13px;
  text-align: center;
}

.codename {
  margin: 0 0 14px;
  padding: 9px;
  border-radius: 14px;
  background: var(--sky);
  font-size: 13px;
  font-weight: 600;
}
.codename b { font-size: 16px; font-weight: 800; }

.btn {
  display: block;
  width: 100%;
  margin: 0 0 10px;
  padding: 13px 16px;
  border: var(--line);
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow);
  font: 800 17px var(--font);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--yellow); }
.btn.cta { background: var(--blue); }
.btn.ghost { box-shadow: none; border-color: transparent; padding: 8px; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost:active { transform: none; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid #6B8CFF; outline-offset: 2px; }

.sad { width: 120px; height: 86px; margin: -4px auto 4px; }
.sad svg { display: block; width: 100%; height: 100%; }
.pick-label { margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.pick { display: flex; justify-content: center; gap: 14px; margin: 0 0 14px; }
.pick-opt {
  width: 78px;
  height: 78px;
  padding: 0;
  border: var(--line);
  border-radius: 18px;
  background: var(--sky);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  opacity: .55;
  transition: transform .1s, opacity .1s;
}
.pick-opt img { display: block; width: 100%; height: 100%; }
.pick-opt[aria-checked="true"] { opacity: 1; background: var(--yellow); box-shadow: 4px 4px 0 var(--ink); transform: translate(-1px, -1px); }
.pick-opt:focus-visible { outline: 3px solid #6B8CFF; outline-offset: 2px; }

.final { margin: 12px 0 2px; font-size: 52px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.final small { display: block; font-size: 13px; font-weight: 700; opacity: .7; margin-top: 4px; }
.lasted { margin: 8px 0 0; font-weight: 800; font-size: 17px; }
.rank { margin: 2px 0 12px; font-size: 14px; font-weight: 600; opacity: .75; min-height: 1.2em; }
.verdict {
  margin: 0 0 16px;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.35;
}
.board-title { margin: 18px 0 0; font-size: 16px; font-weight: 800; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}
.stats div {
  background: var(--sky);
  border-radius: 12px;
  padding: 8px 4px;
}
.stats dt { font-size: 11px; font-weight: 700; opacity: .75; }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

.board {
  list-style: none;
  margin: 14px 0 12px;
  padding: 0;
  text-align: left;
  font-size: 14px;
  counter-reset: r;
}
.board:empty { display: none; }
.board li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  counter-increment: r;
}
.board li::before { content: counter(r); width: 18px; font-weight: 800; opacity: .6; }
.board li span { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li b { font-variant-numeric: tabular-nums; }
.board li:nth-child(odd) { background: var(--sky); }
.board li.me { background: var(--yellow); outline: var(--line); }
.board .empty::before { content: none; }

.fine { margin: 6px 0 0; font-size: 11px; opacity: .65; line-height: 1.4; }

.recruiter {
  display: block;
  margin: 2px auto 0;
  padding: 6px 14px;
  border: 2px dashed var(--ink);
  border-radius: 999px;
  background: var(--white);
  font: 800 14px var(--font);
  color: var(--ink);
  cursor: pointer;
}
.sheet {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  background: rgba(42, 46, 69, .35);
}
.sheet-panel {
  width: 100%;
  background: var(--white);
  border-top: var(--line);
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(var(--sab) + 10px);
  animation: slide-up .22s ease-out;
}
.sheet-panel h3 { margin: 0 0 4px; text-align: center; font-size: 20px; font-weight: 800; }
.sheet-sub { margin: 0 0 14px; text-align: center; font-size: 14px; font-weight: 600; line-height: 1.4; }
.contact-opt { display: flex; align-items: center; justify-content: center; gap: 10px; }
.contact-opt.wa { background: #D3F5DF; }
.contact-opt.em { background: var(--yellow); }
.contact-opt.li { background: #D6E8FA; }
.em .ico { background: var(--white); }
@keyframes slide-up { from { transform: translateY(100%); } }

.share-label { margin: 4px 0 8px; font-size: 14px; font-weight: 800; }
.share-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.share-row .btn { margin: 0; }
.share-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px 4px; font-size: 14px; }
.share-btn.more { background: var(--white); }
.more .ico { background: var(--white); }
.share-hint { margin: 8px 0 12px; font-size: 12px; font-weight: 600; opacity: .7; }
.share-btn.li { background: #D6E8FA; }
.share-btn.wa { background: #D3F5DF; }
.ico {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font: 800 14px var(--font);
  color: #fff;
}
.ico svg { width: 16px; height: 16px; }
.li .ico { background: #0A66C2; }
.wa .ico { background: #25D366; border-radius: 50%; }
#toast { z-index: 7; }

@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.35); } }

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  #level-banner.show { animation: none; opacity: 1; transform: translate(-50%, -50%); }
}
