/* ══════════════════════════════════════════
   HACHIKO INU PFP — Dark Theme UI v5
══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Luckiest+Guy&family=Nunito:wght@400;700;800;900&display=swap');

:root {
  --yellow: #f5a623;
  --yellow-bright: #ffc107;
  --yellow-text: #f5a800;
  --bg-dark: #0d0d0d;
  --panel-bg: rgba(20, 20, 24, 0.97);
  --text-white: #ffffff;
  --font-display: 'Luckiest Guy', cursive;
  --font-body: 'Nunito', sans-serif;
  --r-card: 24px;
  --r-item: 14px;
  --r-pill: 999px;
  --btn-shadow-color: hsla(35, 90%, 40%, 0.4);
}

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

/* ══════════════════════════════
   BODY — dark + animated paw pattern
══════════════════════════════ */
body {
  font-family: var(--font-body);
  min-height: 100vh;
  background-color: var(--bg-dark);
  color: var(--text-white);
  overflow-x: hidden;
  position: relative;
}

/* Animated floating paws */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='%23ffffff' opacity='0.055'%3E%3Cellipse cx='60' cy='76' rx='19' ry='15'/%3E%3Ccircle cx='40' cy='54' r='8'/%3E%3Ccircle cx='60' cy='47' r='8'/%3E%3Ccircle cx='80' cy='54' r='8'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23ffffff' opacity='0.025'%3E%3Cellipse cx='40' cy='52' rx='13' ry='10'/%3E%3Ccircle cx='27' cy='37' r='5'/%3E%3Ccircle cx='40' cy='32' r='5'/%3E%3Ccircle cx='53' cy='37' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px, 80px 80px;
  background-position: 0 0, 40px 40px;
  pointer-events: none;
  z-index: 0;
  animation: pawDrift 18s linear infinite;
}

@keyframes pawDrift {
  0%   { background-position: 0 0, 40px 40px; }
  100% { background-position: 0 -120px, 40px -40px; }
}

.scene-bg { display: none !important; }

/* ══════════════════════════════
   KEYFRAMES
══════════════════════════════ */

@keyframes glitchShift {
  0%   { text-shadow: 4px 4px 0 rgba(0,0,0,0.6), 0 0 50px rgba(245,168,0,0.18); transform: translate(0,0); }
  10%  { text-shadow: -3px 2px 0 #ff003c, 5px -2px 0 #00f7ff; transform: translate(-2px, 1px); }
  20%  { text-shadow: 4px 4px 0 rgba(0,0,0,0.6); transform: translate(2px, -1px); }
  30%  { text-shadow: 3px -2px 0 #ff003c, -4px 3px 0 #00f7ff; transform: translate(-1px, 2px); }
  40%  { text-shadow: 4px 4px 0 rgba(0,0,0,0.6); transform: translate(1px, 0); }
  50%  { text-shadow: -4px 1px 0 #ff003c, 4px -1px 0 #00f7ff; transform: translate(-2px, -2px); clip-path: inset(20% 0 30% 0); }
  60%  { text-shadow: 4px 4px 0 rgba(0,0,0,0.6); transform: translate(0,0); clip-path: inset(0); }
  70%  { text-shadow: 2px -3px 0 #ff003c, -2px 4px 0 #00f7ff; transform: translate(2px, 1px); }
  80%  { text-shadow: 4px 4px 0 rgba(0,0,0,0.6); transform: translate(-1px, -1px); }
  90%  { text-shadow: -2px 2px 0 #ff003c, 3px -2px 0 #00f7ff; transform: translate(1px, 2px); }
  100% { text-shadow: 4px 4px 0 rgba(0,0,0,0.6), 0 0 50px rgba(245,168,0,0.18); transform: translate(0,0); }
}

@keyframes spacePulse {
  0%   { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.06); }
  25%  { box-shadow: 0 0 0 4px #f5a623, 0 0 30px 8px rgba(245,166,0,0.4), 0 28px 64px rgba(0,0,0,0.65); }
  50%  { box-shadow: 0 0 0 6px #00f7ff, 0 0 50px 12px rgba(0,247,255,0.25), 0 28px 64px rgba(0,0,0,0.65); }
  75%  { box-shadow: 0 0 0 4px #ff003c, 0 0 30px 8px rgba(255,0,60,0.3), 0 28px 64px rgba(0,0,0,0.65); }
  100% { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.06); }
}

@keyframes scanlines {
  0%   { background-position: 0 0; }
  100% { background-position: 0 100px; }
}

@keyframes bubbles {
  from { transform: translate(0, 0); }
  to   { transform: translate(0, -66.666%); }
}

/* ══════════════════════════════
   APP SHELL
══════════════════════════════ */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════
   TOP BAR — logo + title + subheading centered column
══════════════════════════════ */
.top-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 40px 0;
  gap: 12px;
  flex-shrink: 0;
}

/* Hide old spacer and back button */
.top-spacer,
.btn-back,
.btn-reset-link { display: none !important; }

/* Logo circle — centered at top */
.top-logo-circle {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--yellow);
  box-shadow: 0 4px 18px rgba(245,166,0,0.4);
  background: #c8843a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s, box-shadow .2s;
}

.top-logo-circle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 26px rgba(245,166,0,0.6);
}

.top-logo-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Center title */
.top-title {
  text-align: center;
  pointer-events: auto;
  white-space: nowrap;
  cursor: default;
}

.title-text {
  font-family: var(--font-display);
  font-size: 4.4rem;
  color: var(--yellow-text);
  letter-spacing: 5px;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.6), 0 0 50px rgba(245,168,0,0.18);
  -webkit-text-stroke: 1px rgba(0,0,0,0.2);
  display: inline-block;
  transition: color .1s;
}

.top-title:hover .title-text {
  animation: glitchShift 0.6s steps(1) forwards;
  color: #fff;
}

.title-accent { color: var(--yellow-text); }

/* Subheading below title */
.top-subheading {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  text-align: center;
  margin-top: -2px;
}

/* ══════════════════════════════
   MAIN LAYOUT
══════════════════════════════ */
.main-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 24px 44px 36px;
  min-height: 0;
}

/* ══════════════════════════════
   LEFT SIDEBAR
══════════════════════════════ */
.sidebar {
  width: 500px;
  flex-shrink: 0;
  background: var(--panel-bg);
  border-radius: var(--r-card);
  padding: 22px 20px 18px;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 560px;
}

.sidebar-heading {
  font-family: var(--font-display);
  font-size: 1rem;
  color: rgba(255,255,255,0.9);
  text-align: center;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── TABS ── */
.category-tabs {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border-radius: var(--r-pill);
  padding: 5px 6px;
  border: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  padding: 7px 16px;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .8px;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}

.tab-btn .tab-icon { display: none; }

.tab-btn:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.07);
}

.tab-btn.active {
  background: var(--yellow);
  color: #1a0f00;
  box-shadow: 0 3px 12px rgba(245,166,0,0.4);
  font-weight: 900;
}

/* ── PANEL LABEL ── */
.panel-label {
  font-family: var(--font-body);
  font-size: .65rem;
  font-weight: 900;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 2.5px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

/* ══════════════════════════════
   TRAIT PANELS + SCROLLABLE GRID
══════════════════════════════ */
.trait-panels {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.trait-panel { display: none; }
.trait-panel.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.trait-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: 82px;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  padding-bottom: 6px;
  align-content: start;
  flex: 1;
  min-height: 0;
}

.trait-grid::-webkit-scrollbar { width: 4px; }
.trait-grid::-webkit-scrollbar-track { background: transparent; }
.trait-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
}

/* ── TRAIT ITEMS ── */
.trait-item {
  width: 100%;
  height: 82px;
  border-radius: var(--r-item);
  background: #ffffff;
  border: 2.5px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: transform .17s ease, box-shadow .17s ease, border-color .17s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  position: relative;
}

.trait-item:hover {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  border-color: rgba(245,166,0,0.55);
}

.trait-item.active {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(245,166,0,0.25), 0 6px 18px rgba(245,166,0,0.2);
}

.trait-item.active::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: .6rem;
  font-weight: 900;
  color: var(--yellow);
}

.trait-item img {
  max-width: 80%;
  max-height: 80%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.trait-name { display: none; }

/* ══════════════════════════════
   AVATAR CARD
══════════════════════════════ */
.preview-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.avatar-card {
  width: 500px;
  height: 500px;
  border-radius: 26px;
  overflow: hidden;
  background: #000000;
  padding: 8px;
  box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.06);
  transition: box-shadow .3s ease;
  position: relative;
  cursor: pointer;
}

.avatar-card:hover {
  animation: borderCycle 1.2s ease-in-out infinite !important;
}

.avatar-card:hover::after {
  opacity: 1;
  animation: scanlines 2s linear infinite;
}

.avatar-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(0,247,255,0.03) 2px, rgba(0,247,255,0.03) 4px
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
  z-index: 2;
}

.avatar-card:hover::after {
  opacity: 1;
  animation: scanlines 2s linear infinite;
}

#avatarCanvas {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  background: #000000;
  display: block;
  position: relative;
  z-index: 1;
}

/* ══════════════════════════════
   ACTION BUTTONS
══════════════════════════════ */
.action-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* SVG icon inside buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ══════════════════════════════
   RANDOMIZE — bubble btn, pill shape
══════════════════════════════ */
.btn-random {
  position: relative;
  padding: 12px 26px;
  border: 1.5px solid rgba(255,255,255,0.12);
  background-color: #2a2a2a;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.88rem;
  letter-spacing: 1px;
  border-radius: var(--r-pill);
  z-index: 0;
  overflow: hidden;
  transition: box-shadow .2s ease, transform .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  box-shadow: rgba(255,255,255,0.12) 2px 2px 22px;
}

.btn-random:focus { outline-color: transparent; }
.btn-random:hover { transform: translateY(-2px); }
.btn-random:active { transform: translateY(0) scale(.97); }

.btn-random::before {
  content: '';
  pointer-events: none;
  opacity: 0.5;
  background:
    radial-gradient(circle at 20% 35%, transparent 0, transparent 2px, rgba(255,255,255,0.9) 3px, rgba(255,255,255,0.9) 4px, transparent 4px),
    radial-gradient(circle at 75% 44%, transparent 0, transparent 2px, rgba(255,255,255,0.9) 3px, rgba(255,255,255,0.9) 4px, transparent 4px),
    radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, rgba(255,255,255,0.9) 5px, rgba(255,255,255,0.9) 6px, transparent 6px);
  width: 100%;
  height: 300%;
  top: 0;
  left: 0;
  position: absolute;
  animation: bubbles 5s linear infinite both;
}

.btn-random .left,
.btn-random .right {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
}

.btn-random .right { left: 66%; }
.btn-random .left  { right: 66%; }

.btn-random .right::after {
  content: var(--content);
  display: block;
  position: absolute;
  white-space: nowrap;
  padding: 40px 40px;
  pointer-events: none;
  top: -30px;
  left: calc(-66% - 20px);
  background-color: var(--bg-dark);
  color: transparent;
  transition: transform .4s ease-out;
  transform: translate(0, -90%) rotate(0deg);
}

.btn-random:hover .right::after          { transform: translate(0, -47%) rotate(0deg); }
.btn-random .right:hover::after          { transform: translate(0, -50%) rotate(-7deg); }
.btn-random .left:hover ~ .right::after  { transform: translate(0, -50%) rotate(7deg); }

/* ══════════════════════════════
   RESET — bubble btn, pill shape
══════════════════════════════ */
.btn-reset {
  position: relative;
  padding: 12px 26px;
  border: 1.5px solid rgba(245,166,0,0.25);
  background-color: #2a2a2a;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.88rem;
  letter-spacing: 1px;
  border-radius: var(--r-pill);
  z-index: 0;
  overflow: hidden;
  transition: box-shadow .2s ease, transform .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--yellow);
  box-shadow: rgba(245,166,0,0.3) 2px 2px 22px;
}

.btn-reset:focus { outline-color: transparent; }
.btn-reset:hover { transform: translateY(-2px); }
.btn-reset:active { transform: translateY(0) scale(.97); }

.btn-reset::before {
  content: '';
  pointer-events: none;
  opacity: 0.5;
  background:
    radial-gradient(circle at 20% 35%, transparent 0, transparent 2px, var(--yellow) 3px, var(--yellow) 4px, transparent 4px),
    radial-gradient(circle at 75% 44%, transparent 0, transparent 2px, var(--yellow) 3px, var(--yellow) 4px, transparent 4px),
    radial-gradient(circle at 46% 52%, transparent 0, transparent 4px, var(--yellow) 5px, var(--yellow) 6px, transparent 6px);
  width: 100%;
  height: 300%;
  top: 0;
  left: 0;
  position: absolute;
  animation: bubbles 5s linear infinite both;
}

.btn-reset .left,
.btn-reset .right {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
}

.btn-reset .right { left: 66%; }
.btn-reset .left  { right: 66%; }

.btn-reset .right::after {
  content: var(--content);
  display: block;
  position: absolute;
  white-space: nowrap;
  padding: 40px 40px;
  pointer-events: none;
  top: -30px;
  left: calc(-66% - 20px);
  background-color: var(--bg-dark);
  color: transparent;
  transition: transform .4s ease-out;
  transform: translate(0, -90%) rotate(0deg);
}

.btn-reset:hover .right::after         { transform: translate(0, -47%) rotate(0deg); }
.btn-reset .right:hover::after         { transform: translate(0, -50%) rotate(-7deg); }
.btn-reset .left:hover ~ .right::after { transform: translate(0, -50%) rotate(7deg); }

/* ══════════════════════════════
   DOWNLOAD — pill shape, slide-fill white
══════════════════════════════ */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  height: auto;
  border: none;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 0;
  transition: color .32s ease, transform .15s ease, box-shadow .2s ease;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform: translateX(-102%);
  transition: transform .38s cubic-bezier(.4, 0, .2, 1);
  z-index: -1;
}

.btn:hover::before { transform: translateX(0); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.97); }

.btn-download {
  background: var(--yellow);
  color: #1a0a00;
  font-weight: 900;
  border: 1.5px solid transparent;
  box-shadow: var(--btn-shadow-color) 2px 2px 22px;
}

.btn-download::before { background: #ffffff; }

.btn-download:hover {
  color: #111111;
  box-shadow: rgba(245,166,0,0.5) 2px 2px 28px;
}

/* ══════════════════════════════
   RESPONSIVE — tablet
══════════════════════════════ */
@media (max-width: 1200px) {
  .main-layout {
    flex-direction: column-reverse;
    align-items: center;
    overflow-y: auto;
    padding: 16px 20px 30px;
    gap: 24px;
  }

  body { overflow-y: auto; }

  .sidebar {
    width: 100%;
    max-width: 520px;
    height: 460px;
  }

  .avatar-card {
    width: 440px;
    height: 440px;
  }

  .trait-grid { grid-auto-rows: 76px; }
}

/* ══════════════════════════════
   RESPONSIVE — mobile
══════════════════════════════ */
@media (max-width: 700px) {
  .top-bar {
    padding: 20px 16px 0;
    gap: 8px;
  }

  .top-logo-circle {
    width: 68px;
    height: 68px;
  }

  .title-text {
    font-size: 2.6rem;
    letter-spacing: 3px;
  }

  .top-subheading {
    font-size: .82rem;
    letter-spacing: 1.5px;
  }

  .main-layout {
    flex-direction: column;
    padding: 14px 14px 28px;
    gap: 18px;
  }

  .avatar-card {
    width: min(90vw, 360px);
    height: min(90vw, 360px);
  }

  .sidebar {
    width: 100%;
    max-width: 100%;
    height: 400px;
    padding: 16px 12px 14px;
  }

  .trait-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 68px;
    gap: 8px;
  }

  .action-buttons {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .btn-random,
  .btn-reset,
  .btn-download {
    font-size: .78rem;
    padding: 10px 20px;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: .7rem;
    letter-spacing: .4px;
  }
}

@media (max-width: 400px) {
  .title-text {
    font-size: 2rem;
    letter-spacing: 2px;
  }

  .top-subheading {
    font-size: .75rem;
    letter-spacing: 1px;
  }

  .trait-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 64px;
  }

  .avatar-card {
    width: 88vw;
    height: 88vw;
  }
}
/* ══════════════════════════════
   SWIPEABLE TABS — mobile touch
══════════════════════════════ */
.trait-panels {
  touch-action: pan-y;
}

/* Always-on border glow (replaces hover-only spacePulse) */
@keyframes borderCycle {
  0%   { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.06), 0 0 0 2px rgba(245,166,0,0.15); }
  20%  { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 3px #f5a623, 0 0 28px 6px rgba(245,166,0,0.35); }
  40%  { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 3px #00f7ff, 0 0 28px 6px rgba(0,247,255,0.2); }
  60%  { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 3px #ff003c, 0 0 28px 6px rgba(255,0,60,0.25); }
  80%  { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 3px #ffffff, 0 0 28px 6px rgba(255,255,255,0.1); }
  100% { box-shadow: 0 28px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.06), 0 0 0 2px rgba(245,166,0,0.15); }
}

/* Override old hover-only animation — now always runs */
.avatar-card {
  animation: borderCycle 4s ease-in-out infinite !important;
}

/* On hover: scanlines stay + extra intensity */
.avatar-card:hover {
  animation: borderCycle 1.2s ease-in-out infinite !important;
}

.avatar-card:hover::after {
  opacity: 1;
  animation: scanlines 2s linear infinite;
}

