*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f0f0f3;
  overflow: hidden;
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
}

.hidden {
  display: none !important;
}

.error {
  font-size: 0.85rem;
  color: #e74c3c;
  font-weight: 700;
  text-align: center;
}

/* ── Background + Vignette ─────────────────────────────────── */

.bg-wrapper {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.blur-vignette {
  --radius: 0px;
  --inset: 40px;
  --transition-length: 150px;
  --blur: 12px;
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  --r: max(var(--transition-length), calc(var(--radius) - var(--inset)));
  --corner-size: calc(var(--r) + var(--inset)) calc(var(--r) + var(--inset));
  --corner-gradient: transparent 0px,
    transparent calc(var(--r) - var(--transition-length)), black var(--r);
  --fill-gradient: black, black var(--inset),
    transparent calc(var(--inset) + var(--transition-length)),
    transparent calc(100% - var(--transition-length) - var(--inset)),
    black calc(100% - var(--inset));
  --fill-narrow-size: calc(100% - (var(--inset) + var(--r)) * 2);
  --fill-farther-position: calc(var(--inset) + var(--r));
  -webkit-mask-image: linear-gradient(to right, var(--fill-gradient)),
    linear-gradient(to bottom, var(--fill-gradient)),
    radial-gradient(at bottom right, var(--corner-gradient)),
    radial-gradient(at bottom left, var(--corner-gradient)),
    radial-gradient(at top left, var(--corner-gradient)),
    radial-gradient(at top right, var(--corner-gradient));
  -webkit-mask-size:
    100% var(--fill-narrow-size),
    var(--fill-narrow-size) 100%,
    var(--corner-size),
    var(--corner-size),
    var(--corner-size),
    var(--corner-size);
  -webkit-mask-position:
    0 var(--fill-farther-position),
    var(--fill-farther-position) 0,
    0 0,
    100% 0,
    100% 100%,
    0 100%;
  -webkit-mask-repeat: no-repeat;
}

.noise {
  position: absolute;
  inset: 0;
  background: url('https://www.ui-layouts.com/noise.gif');
  opacity: 0.03;
  pointer-events: none;
  z-index: 1;
}

/* ── Search Panel ─────────────────────────────────────────── */

.search-panel {
  position: relative;
  z-index: 2;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-panel--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: #fffef8;
  border: 3px solid #222;
  border-radius: 4px;
  box-shadow: 4px 4px 0 #222, inset 0 0 40px rgba(0, 0, 0, 0.03);
  padding: 2.5rem 2rem 2rem;
  width: 460px;
}

.search-panel--center .search-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.search-panel--top {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  background: #fffef8;
  border: 3px solid #222;
  border-radius: 4px;
  box-shadow: 3px 3px 0 #222;
  padding: 0.5rem 0.75rem;
  width: auto;
}

.search-panel--top .title,
.search-panel--top .subtitle {
  display: none;
}

.search-panel--top .search-row {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
}

.search-panel--top .input-wrapper {
  width: 200px;
  margin-top: 0;
}

.search-panel--top #analyze-btn {
  width: auto;
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  box-shadow: 2px 2px 0 #222;
}

.search-panel--top .error {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  white-space: nowrap;
  background: #fffef8;
  border: 2px solid #e74c3c;
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* ── Title ─────────────────────────────────────────────────── */

.title {
  font-size: 2rem;
  font-weight: 700;
  color: #111;
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 #ddd;
}

.subtitle {
  font-size: 0.95rem;
  color: #777;
  margin-top: -0.5rem;
  font-style: italic;
}

/* ── Input ─────────────────────────────────────────────────── */

.input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  margin-top: 0.5rem;
  border: 2px solid #333;
  border-radius: 3px;
  background: #fff;
  overflow: hidden;
  box-shadow: 2px 2px 0 #ccc;
  transition: box-shadow 0.15s;
}

.input-wrapper:focus-within {
  border-color: #e74c3c;
  box-shadow: 2px 2px 0 #e74c3c;
}

.at {
  font-size: 1.1rem;
  font-weight: 700;
  color: #999;
  padding: 0 0 0 0.75rem;
  user-select: none;
}

#username {
  flex: 1;
  padding: 0.75rem 0.75rem 0.75rem 0.35rem;
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  font-size: 1rem;
  font-weight: 700;
  color: #222;
  background: transparent;
  border: none;
  outline: none;
}

#username::placeholder {
  color: #bbb;
  font-weight: 400;
}

/* ── Button ────────────────────────────────────────────────── */

#analyze-btn {
  width: 100%;
  padding: 0.8rem;
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fff;
  background: #e74c3c;
  border: 2px solid #222;
  border-radius: 3px;
  box-shadow: 3px 3px 0 #222;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}

#analyze-btn:hover {
  background: #c0392b;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #222;
}

#analyze-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #222;
}

#analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 3px 0 #222;
}

/* ── ID Card ──────────────────────────────────────────────── */

.id-card {
  position: relative;
  z-index: 1;
  width: 520px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: #fffef8;
  border: 3px solid #222;
  border-radius: 4px;
  box-shadow: 5px 5px 0 #222;
  animation: cardIn 0.4s ease-out;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Derp Loader ─────────────────────────────────────────── */

.derp-loader {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: auto;
  padding-top: 8vh;
}

.derp-loader-img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border: 3px solid #222;
  border-radius: 4px;
  box-shadow: 4px 4px 0 #222;
  background: #fff;
  animation: derpBounce 0.5s ease-in-out infinite alternate,
             derpWobble 1.2s ease-in-out infinite;
}

@keyframes derpBounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-18px); }
}

@keyframes derpWobble {
  0%   { rotate: -4deg; }
  25%  { rotate: 4deg; }
  50%  { rotate: -4deg; }
  75%  { rotate: 3deg; }
  100% { rotate: -4deg; }
}

.derp-loader-text {
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  font-size: 1.1rem;
  font-weight: 700;
  color: #222;
  letter-spacing: 0.12em;
  animation: derpPulse 0.8s ease-in-out infinite alternate;
}

@keyframes derpPulse {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

.id-card-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.4rem 1.25rem;
  background: #e74c3c;
  border-bottom: 3px solid #222;
}

.id-card-stamp {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2em;
}

.id-card-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 2px dashed #ddd;
  gap: 0.5rem;
}

.id-card-pfp-frame {
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  border: 4px solid #222;
  border-radius: 4px;
  box-shadow: 4px 4px 0 #222;
  overflow: hidden;
  background: #eee;
}

.id-card-pfp-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.id-username {
  font-size: 2rem;
  font-weight: 700;
  color: #222;
  line-height: 1.1;
  text-align: center;
}

.id-class {
  font-size: 0.75rem;
  font-weight: 700;
  color: #888;
  line-height: 1.3;
  text-align: center;
  letter-spacing: 0.05em;
}

.id-header-score {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  background: #e74c3c;
  padding: 0.3rem 1rem;
  border: 3px solid #222;
  border-radius: 3px;
  box-shadow: 3px 3px 0 #222;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

.id-section {
  padding: 0.4rem 1.25rem;
}

.id-bio {
  font-size: 0.7rem;
  color: #555;
  line-height: 1.45;
  border-bottom: 2px dashed #ddd;
  font-style: italic;
}

.id-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 2px dashed #ddd;
}

.id-columns .id-section:first-child {
  border-right: 2px dashed #ddd;
}

.id-section h3 {
  font-size: 0.55rem;
  font-weight: 700;
  color: #e74c3c;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
}

.id-section ul {
  list-style: none;
  font-size: 0.62rem;
  color: #555;
  line-height: 1.5;
}

.id-section ul li::before {
  content: "• ";
  color: #ccc;
  font-weight: 700;
}

.id-catchphrase {
  padding: 0.4rem 1.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #222;
  text-align: center;
  border-bottom: 2px dashed #ddd;
  background: #fdf6e3;
}

.id-catchphrase::before {
  content: '\201C';
}

.id-catchphrase::after {
  content: '\201D';
}

.id-card-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 1.25rem;
  font-size: 0.5rem;
  font-weight: 700;
  color: #aaa;
  letter-spacing: 0.08em;
}

.id-card-promo {
  color: #e74c3c;
  font-size: 0.55rem;
  letter-spacing: 0.05em;
}

/* ── Card Action Buttons ──────────────────────────────────── */

.card-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.action-btn {
  padding: 0.6rem 1.5rem;
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 2px solid #222;
  border-radius: 3px;
  box-shadow: 3px 3px 0 #222;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}

.action-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #222;
}

.action-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #222;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 3px 0 #222;
}

.save-btn {
  color: #222;
  background: #fffef8;
}

.save-btn:hover { background: #f0efe8; }

.regen-btn {
  color: #fff;
  background: #e74c3c;
}

.regen-btn:hover { background: #c0392b; }

.post-btn {
  color: #fff;
  background: #000;
}

.post-btn:hover { background: #333; }

/* ── Music Player ────────────────────────────────────────── */

.music-player {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: rgba(255, 254, 248, 0.92);
  border: 2px solid #222;
  border-radius: 4px;
  box-shadow: 3px 3px 0 #222;
  font-family: 'Comic Neue', 'Comic Sans MS', cursive;
  backdrop-filter: blur(6px);
}

.mp-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
}

.mp-btn:hover { opacity: 0.7; }

.mp-track {
  font-size: 0.65rem;
  font-weight: 700;
  color: #e74c3c;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.mp-volume {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.mp-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #e74c3c;
  border: 2px solid #222;
  border-radius: 50%;
  cursor: pointer;
}

.mp-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #e74c3c;
  border: 2px solid #222;
  border-radius: 50%;
  cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 560px) {
  .search-panel--center { width: 95%; }
  .id-card { width: 95%; }
  .id-card-top { flex-direction: column; align-items: center; text-align: center; }
  .id-columns { grid-template-columns: 1fr; }
  .id-columns .id-section:first-child { border-right: none; border-bottom: 2px dashed #ddd; }
  .search-panel--top { right: 0.5rem; top: 0.5rem; }
  .search-panel--top .input-wrapper { width: 150px; }
}
