@font-face { font-family: "Lilita"; src: url("/fonts/LilitaOne-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/Nunito-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --bg: #2a1d6b;
  --bg2: #4837e9;
  --ink: #1b1340;
  --paper: #fffdf6;
  --lip: rgba(0, 0, 0, .28);
  --it: 84px;
  --tray-h: calc(var(--it) + 76px);
  --s: #ff4f7a; --a: #ff9a3c; --b: #ffd43b; --c: #4fd68a; --d: #59a8ff;
}
@media (min-width: 700px) { :root { --it: 100px; } }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(120% 70% at 50% 0%, var(--bg2), var(--bg) 70%) fixed;
  color: var(--paper);
  font: 800 16px/1.3 "Nunito", system-ui, sans-serif;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--tray-h) + 24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

.top { text-align: center; margin: 4px auto 12px; max-width: 980px; }
h1, h2 { font-family: "Lilita", system-ui, sans-serif; font-weight: 400; letter-spacing: .5px; margin: 0; }
h1 { font-size: 34px; line-height: 1.05; color: #ffe066; text-shadow: 0 3px 0 var(--ink), 0 0 2px var(--ink); -webkit-text-stroke: 1.5px var(--ink); }
.how { margin: 6px 0 0; font-size: 15px; opacity: .92; }
.how b { color: #ffe066; }

#board { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }

.row { display: flex; align-items: stretch; background: var(--paper); border-radius: 20px; box-shadow: 0 5px 0 var(--lip); overflow: hidden; }
.label {
  flex: 0 0 auto; width: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink); text-align: center; padding: 6px 4px; border-right: 3px solid var(--ink);
}
.label .t { font-family: "Lilita", system-ui, sans-serif; font-size: 34px; line-height: 1; }
.label .w { font-size: 12px; line-height: 1.1; margin-top: 2px; letter-spacing: .3px; }
.row[data-tier="S"] .label { background: var(--s); }
.row[data-tier="A"] .label { background: var(--a); }
.row[data-tier="B"] .label { background: var(--b); }
.row[data-tier="C"] .label { background: var(--c); }
.row[data-tier="D"] .label { background: var(--d); }

.zone { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; padding: 6px; min-height: calc(var(--it) + 12px); }
.row .zone { background: #f3efe2; }
.zone.over { background: #fff3b0; box-shadow: inset 0 0 0 3px #ffb703; }
.row.armed .zone { box-shadow: inset 0 0 0 3px #ffb703; cursor: pointer; }

.it {
  width: var(--it); height: var(--it); padding: 0; border: 0; border-radius: 14px;
  background: #fff; box-shadow: 0 3px 0 rgba(27, 19, 64, .25), inset 0 0 0 2px rgba(27, 19, 64, .12);
  touch-action: none; cursor: grab; position: relative; flex: 0 0 auto;
}
.it img { width: 100%; height: 100%; object-fit: contain; padding: 4px; pointer-events: none; -webkit-user-drag: none; }
.it.lifted { opacity: .25; }
.it.picked { box-shadow: 0 0 0 4px #ffb703, 0 3px 0 rgba(27, 19, 64, .25); transform: translateY(-2px); }
.it:focus-visible { outline: 3px solid #ffb703; outline-offset: 2px; }

.ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  width: calc(var(--it) * 1.15); height: calc(var(--it) * 1.15); border-radius: 16px; background: #fff;
  box-shadow: 0 12px 24px rgba(0, 0, 0, .35), 0 0 0 3px #ffb703; transform: translate(-50%, -60%) rotate(-4deg);
}
.ghost img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

.tray-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(27, 19, 64, .94); border-top: 3px solid #ffe066;
  padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.tray-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1100px; margin: 0 auto 6px; }
.left { font-size: 15px; color: #ffe066; }
.tray { max-width: 1100px; margin: 0 auto; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 8px; min-height: calc(var(--it) + 14px); border-radius: 14px; }
.tray .it { touch-action: pan-x; }
.tray:empty::before { content: "All ranked! Tap Done to send it."; color: #ffe066; align-self: center; padding-left: 6px; }

.send {
  font: 400 20px/1 "Lilita", system-ui, sans-serif; letter-spacing: .5px; color: var(--ink);
  background: #b8f04a; border: 0; border-radius: 20px; padding: 12px 22px; min-height: 48px;
  box-shadow: 0 5px 0 #5c8a12; cursor: pointer;
}
.send:disabled { background: #8a86a8; box-shadow: 0 5px 0 #4b476b; color: #2c2950; cursor: default; }
.send:not(:disabled):active { transform: translateY(3px); box-shadow: 0 2px 0 #5c8a12; }

.sent { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(27, 19, 64, .7); padding: 16px; }
.sent[hidden] { display: none; }
.sent-card { position: relative; background: var(--paper); color: var(--ink); border-radius: 24px; padding: 28px 28px 24px; text-align: center; box-shadow: 0 6px 0 var(--lip); max-width: 360px; width: 100%; overflow: hidden; }
.sent-card h2 { font-size: 36px; color: #ff4f7a; -webkit-text-stroke: 1px var(--ink); }
.sent-card p { margin: 8px 0 18px; }
.burst { position: absolute; inset: -40%; background: repeating-conic-gradient(#ffe066 0 10deg, transparent 10deg 20deg); opacity: .35; animation: spin 9s linear infinite; z-index: -1; }
.sent-card > *:not(.burst) { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .burst { animation: none; } }

.oops { position: fixed; left: 50%; bottom: calc(var(--tray-h) + 24px); transform: translateX(-50%); z-index: 70; background: #ff4f7a; color: #fff; padding: 10px 16px; border-radius: 14px; box-shadow: 0 4px 0 var(--lip); max-width: 90vw; text-align: center; }
.oops[hidden] { display: none; }

@media (max-width: 480px) {
  h1 { font-size: 28px; }
  .label { width: 64px; }
  .label .t { font-size: 28px; }
  .label .w { font-size: 10px; }
}
