/* =============================================================
   /tamagotchi — embedded game + persistent flock leaderboard
   ============================================================= */

.tama-body {
  min-height: 100vh; min-height: 100svh;
  background: radial-gradient(120% 100% at 50% 0%, #1A0938 0%, #06030F 70%);
  color: var(--cream); overflow-x: hidden;
}

.tama-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.tama-bg__grid {
  position: absolute; left: 50%; bottom: -10%;
  transform: translateX(-50%) rotateX(58deg);
  width: 220vw; height: 70vh;
  background:
    linear-gradient(rgba(91,141,239,.16) 1px, transparent 1px) 0 0 / 70px 70px,
    linear-gradient(90deg, rgba(199,125,255,.16) 1px, transparent 1px) 0 0 / 70px 70px;
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 30%, transparent 80%);
          mask-image: linear-gradient(to top, #000 0%, #000 30%, transparent 80%);
  filter: drop-shadow(0 0 12px rgba(157,78,223,.4));
  animation: tamaGrid 9s linear infinite;
}
@keyframes tamaGrid { to { background-position: 0 70px, 70px 0; } }
.tama-bg__scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay; opacity: .5;
}
.tama-bg__halo { position: absolute; width: 80vmax; height: 80vmax; border-radius: 50%; filter: blur(80px); opacity: .35; mix-blend-mode: screen; animation: tamaHalo 22s ease-in-out infinite alternate; }
.tama-bg__halo--violet  { background: radial-gradient(circle, #9D4EDF, transparent 60%); top: -30%; left: -20%; }
.tama-bg__halo--blue    { background: radial-gradient(circle, #5B8DEF, transparent 60%); top: 10%; right: -25%; animation-delay: -8s; }
.tama-bg__halo--magenta { background: radial-gradient(circle, #E831A0, transparent 60%); bottom: -25%; left: 35%; animation-delay: -14s; }
@keyframes tamaHalo { 0% { transform: translate3d(0,0,0) scale(1); } 100% { transform: translate3d(2vw,-2vh,0) scale(1.08); } }

.tama-header {
  position: relative; z-index: 4;
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(18px, 3vw, 32px) clamp(20px, 5vw, 48px);
}
.tama-header__brand {
  display: inline-flex; align-items: center; gap: .55em;
  color: var(--cream); text-decoration: none;
  font: 700 1.05rem/1 var(--display); letter-spacing: -0.02em;
}
.tama-header__brand em {
  font-style: italic; background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.tama-header__brand svg { width: 14px; height: 14px; color: var(--neon-2); transition: transform .25s var(--ease); }
.tama-header__brand:hover svg { transform: translateX(-3px); }
.tama-header__mark {
  display: inline-flex; align-items: center; gap: .5em;
  font: 700 .68rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .28em; text-transform: uppercase; color: rgba(242,237,228,.65);
  padding: .55em .9em; border-radius: 100px;
  border: 1px solid rgba(199,125,255,.3);
  background: rgba(20,12,30,.55); backdrop-filter: blur(10px);
}
.tama-header__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--neon-2); box-shadow: 0 0 10px rgba(199,125,255,.9); animation: pulse 1.6s infinite; }

.tama-main {
  position: relative; z-index: 3;
  display: grid; grid-template-columns: 1fr minmax(300px, 380px);
  gap: clamp(24px, 4vw, 48px);
  padding: clamp(12px, 2vh, 24px) clamp(20px, 5vw, 56px) clamp(40px, 6vh, 80px);
  align-items: start;
}

/* ----- Stage: framed iframe ----- */
.tama-stage { display: flex; flex-direction: column; gap: 16px; }
.tama-screen {
  position: relative; width: 100%; aspect-ratio: 9 / 16; max-height: 78vh;
  border-radius: 24px; overflow: hidden; background: #000;
  border: 1px solid rgba(199,125,255,.3);
  box-shadow:
    0 60px 160px -40px rgba(0,0,0,.95),
    0 0 80px -10px rgba(157,78,223,.45),
    0 0 140px -20px rgba(91,141,239,.4);
}
.tama-screen__glow {
  position: absolute; inset: -2px; border-radius: inherit; pointer-events: none; z-index: 0;
  background: conic-gradient(from var(--tspin, 0deg) at 50% 50%,
    #5B8DEF 0%, #9D4EDF 25%, #E831A0 50%, #9D4EDF 75%, #5B8DEF 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  padding: 2px; opacity: .65; animation: tamaRing 14s linear infinite; filter: blur(.5px);
}
@keyframes tamaRing { to { --tspin: 360deg; } }
@property --tspin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.tama-screen__bezel { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.tama-screen__corner { position: absolute; width: 24px; height: 24px; border-color: rgba(199,125,255,.85); filter: drop-shadow(0 0 6px rgba(157,78,223,.7)); }
.tama-screen__corner--tl { top: 10px; left: 10px; border-top: 1px solid; border-left: 1px solid; }
.tama-screen__corner--tr { top: 10px; right: 10px; border-top: 1px solid; border-right: 1px solid; }
.tama-screen__corner--bl { bottom: 10px; left: 10px; border-bottom: 1px solid; border-left: 1px solid; }
.tama-screen__corner--br { bottom: 10px; right: 10px; border-bottom: 1px solid; border-right: 1px solid; }
.tama-screen__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; z-index: 1; background: #000; }
.tama-screen__scan {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay; opacity: .3;
}
.tama-screen__hud {
  position: absolute; top: clamp(12px, 2vw, 20px); left: clamp(12px, 2vw, 20px); right: clamp(12px, 2vw, 20px);
  z-index: 3;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
.tama-screen__hud > * { pointer-events: auto; }
.tama-screen__hud-pill {
  font: 700 .66rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .24em; text-transform: uppercase; color: #fff;
  padding: .55em .85em; border-radius: 100px;
  background: rgba(20,12,30,.7); backdrop-filter: blur(10px);
  border: 1px solid rgba(143,182,255,.5);
  display: inline-flex; align-items: center; gap: .55em;
}
.tama-screen__hud-pill i { width: 6px; height: 6px; border-radius: 50%; background: #6CFF92; box-shadow: 0 0 8px rgba(108,255,146,.9); animation: pulse 1.6s infinite; }
.tama-screen__pop {
  display: inline-flex; align-items: center; gap: .35em;
  font: 700 .66rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .24em; text-transform: uppercase; color: #fff; text-decoration: none;
  padding: .55em .8em; border-radius: 100px;
  background: rgba(20,12,30,.7); backdrop-filter: blur(10px);
  border: 1px solid rgba(199,125,255,.5);
}
.tama-screen__pop:hover { background: rgba(157,78,223,.25); }

.tama-stage__hint { margin: 0; text-align: center; font: 500 .72rem/1.5 'Inter', sans-serif; color: rgba(242,237,228,.55); }
.tama-stage__hint a { color: var(--neon-2); text-decoration: underline; }

/* ----- Side: leaderboard panel ----- */
.tama-side {
  position: sticky; top: 16px;
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(26,11,34,.85), rgba(6,3,15,.85));
  border: 1px solid rgba(199,125,255,.22);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(8px);
}
.tama-side__kicker {
  display: inline-flex; align-items: center; gap: .55em;
  font: 700 .68rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .28em; text-transform: uppercase; color: var(--neon-2);
  text-shadow: 0 0 10px rgba(199,125,255,.55);
  margin: 0 0 .8em;
}
.tama-side__pip { width: 7px; height: 7px; border-radius: 50%; background: var(--neon-2); box-shadow: 0 0 8px rgba(199,125,255,.9); animation: pulse 1.6s infinite; }
.tama-side__title {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.6rem, 2.6vw, 2rem); line-height: 1.05; letter-spacing: -.02em;
  margin: 0 0 .5em; color: #F2EBFF;
  text-shadow: 0 0 2px rgba(255,255,255,.4), 0 0 14px rgba(199,125,255,.45), 0 0 30px rgba(157,78,223,.3);
}
.tama-side__lede { margin: 0; color: rgba(242,237,228,.6); font-size: .9rem; line-height: 1.55; }

/* Submit form */
.tama-submit { display: flex; flex-direction: column; gap: 10px; }
.tama-submit__row { display: flex; flex-direction: column; gap: 4px; }
.tama-submit__row span {
  font: 600 .68rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: .2em; text-transform: uppercase; color: rgba(242,237,228,.55);
}
.tama-submit__row input {
  background: rgba(255,255,255,.04); color: var(--cream);
  border: 1px solid rgba(199,125,255,.22); border-radius: 12px;
  padding: .65rem .85rem; font: 600 .95rem/1 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
}
.tama-submit__row input:focus { outline: none; border-color: rgba(199,125,255,.7); background: rgba(255,255,255,.06); }
.tama-submit__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  margin-top: 4px; padding: .85em 1.1em; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, #5B8DEF, #9D4EDF 55%, #E831A0); color: #fff;
  font: 700 .92rem/1 var(--display); border: 1px solid rgba(199,125,255,.45);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.7), 0 0 22px -4px rgba(157,78,223,.6);
  transition: transform .25s ease, box-shadow .25s ease;
}
.tama-submit__btn:hover { transform: translateY(-1px); box-shadow: 0 16px 36px -10px rgba(0,0,0,.85), 0 0 30px -2px rgba(157,78,223,.85); }
.tama-submit__btn:disabled { opacity: .55; cursor: progress; transform: none; }
.tama-submit__hint { margin: 4px 0 0; font-size: .72rem; color: rgba(242,237,228,.45); line-height: 1.5; }
.tama-submit__hint.is-ok  { color: #6CFF92; }
.tama-submit__hint.is-err { color: #FF8AB8; }

/* Leaderboard list */
.tama-board { position: relative; min-height: 80px; }
.tama-board__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tama-board__row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  padding: .55rem .7rem; border-radius: 10px;
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(199,125,255,.12);
}
.tama-board__rank {
  font: 800 .78rem/1 'JetBrains Mono', ui-monospace, monospace;
  color: var(--neon-2); text-align: center; text-shadow: 0 0 8px rgba(199,125,255,.6);
  font-variant-numeric: tabular-nums;
}
.tama-board__row--mine {
  background: linear-gradient(135deg, rgba(91,141,239,.12), rgba(232,49,160,.12));
  border-color: rgba(199,125,255,.55);
  box-shadow: 0 0 16px rgba(157,78,223,.35);
}
.tama-board__row--podium .tama-board__rank { color: #fff; text-shadow: 0 0 10px rgba(255,77,184,.7); }
.tama-board__name { font: 600 .9rem/1.2 'Inter', sans-serif; color: var(--cream); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.tama-board__name b { color: var(--neon-2); font-weight: 700; }
.tama-board__score { font: 800 .92rem/1 'JetBrains Mono', ui-monospace, monospace; color: #fff; font-variant-numeric: tabular-nums; }
.tama-board__days  { display: block; font: 500 .62rem/1 'JetBrains Mono', ui-monospace, monospace; color: rgba(242,237,228,.45); letter-spacing: .14em; margin-top: 4px; text-transform: uppercase; }
.tama-board__empty { margin: 0; text-align: center; font-size: .82rem; color: rgba(242,237,228,.55); padding: .8rem .4rem; }
.tama-board.is-empty .tama-board__empty { display: block; }
.tama-board:not(.is-empty) .tama-board__empty { display: none; }

.tama-side__foot { margin: 0; font-size: .68rem; color: rgba(242,237,228,.4); text-align: center; letter-spacing: .08em; }

/* Mobile */
@media (max-width: 900px) {
  .tama-main { grid-template-columns: 1fr; gap: 24px; }
  .tama-side { position: static; }
  .tama-screen { aspect-ratio: 16 / 9; max-height: none; min-height: 70vh; }
}
@media (max-width: 540px) {
  .tama-header { padding: 14px 16px; }
  .tama-main { padding: 8px 14px 28px; }
  .tama-screen__corner { display: none; }
  .tama-screen__hud { top: 10px; left: 10px; right: 10px; }
  .tama-side { padding: 14px; }
  .tama-side__title { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tama-bg__grid, .tama-bg__halo, .tama-screen__glow { animation: none; }
}
