/* Feed the Tail — game page only */

body.feed {
  margin: 0;
  font-family: var(--ui);
  color: #fff6e8;
  background:
    radial-gradient(circle at 50% -10%, #3a4a8c 0%, #1a2140 42%, #12162a 100%);
  min-height: 100dvh;
  overflow-x: hidden;
}

body.feed .topbar {
  background: rgba(18, 22, 42, .78);
  border-bottom: 3px solid #e6c15a;
  color: #fff6e8;
}

body.feed .topbar h1 {
  font-family: var(--title);
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  color: #c9a227;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip {
  border: 0;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-family: inherit;
  font-size: .9rem;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(22, 49, 92, .1);
}

.chip:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(22, 49, 92, .1); }

.playfield {
  display: flex;
  justify-content: center;
  margin: 10px auto 8px;
  padding: 0 12px;
}

.stage {
  position: relative;
  background: #7ec8ea;
  border: 4px solid #e6c15a;
  border-radius: 22px;
  overflow: hidden;
  /* sized by height, so the box is exactly the playfield and stays centered */
  aspect-ratio: 16 / 10;
  height: min(68vh, 620px);
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  box-shadow: 0 16px 0 rgba(22, 49, 92, .1);
  touch-action: none;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 8px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  font-weight: 800;
  text-shadow: 0 1px 0 #fff;
}

.hud .stat {
  background: rgba(255, 248, 232, .92);
  border: 2px solid #e6c15a;
  border-radius: 14px;
  padding: 6px 10px;
  font-size: clamp(.78rem, 2vw, 1rem);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud .num { font-size: 1.15em; color: var(--blue); }

.miss-slot {
  width: 22px;
  height: 16px;
  border-radius: 4px 4px 6px 6px;
  background: #e8d4a8;
  border: 2px solid #c9a227;
  display: inline-block;
  position: relative;
}
.miss-slot.gone {
  background: #c45d86;
  border-color: #8a2d52;
  opacity: .45;
  transform: rotate(-12deg);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(22, 49, 92, .28);
  backdrop-filter: blur(3px);
}

.overlay[hidden] { display: none !important; }

.card {
  background: rgba(255, 248, 232, .96);
  border: 4px solid #e6c15a;
  border-radius: 22px;
  padding: 14px 18px 16px;
  max-width: 460px;
  width: min(100%, 460px);
  max-height: 100%;
  overflow: auto;
  box-shadow: 0 14px 0 rgba(22, 49, 92, .12);
  text-align: center;
}

.card h2 {
  font-family: var(--title);
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  color: #c9a227;
}

.card .how {
  text-align: left;
  margin: 0 0 12px;
  padding: 0 4px 0 18px;
  font-size: .95rem;
}

.card .how li { margin: 0 0 4px; }

.scores {
  text-align: left;
  background: #fff;
  border-radius: 14px;
  padding: 8px 12px;
  margin: 10px 0 12px;
  max-height: 140px;
  overflow: auto;
}

.scores h3 {
  margin: 0 0 6px;
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--pink-deep);
}

.scores ol { margin: 0; padding-left: 22px; }
.scores li { margin: 2px 0; font-size: .92rem; }
.scores .pts { float: right; font-weight: 800; color: var(--blue); }

.overlay.magic {
  background: transparent;
  pointer-events: none;
  align-items: flex-start;
  padding-top: 18%;
}

.banner {
  font-family: var(--title);
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  background: linear-gradient(#fff1b0, #e6c15a);
  color: var(--ink);
  border: 3px solid #fff;
  border-radius: 16px;
  padding: 10px 22px;
  box-shadow: 0 10px 0 rgba(22, 49, 92, .15);
  animation: popin .35s ease;
}

@keyframes popin {
  from { transform: scale(.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.name-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 10px 0;
}

.name-row input {
  min-width: 160px;
  flex: 1;
  text-align: center;
  font-weight: 800;
}

.err {
  color: #c45d86;
  font-weight: 800;
  min-height: 1.2em;
  margin: 0 0 6px;
}

.pads {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
  padding: 8px 12px 6px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.pad {
  flex: 0 0 auto;
  width: 148px;
  height: 64px;
  border: 3px solid #e6c15a;
  border-radius: 18px;
  background: linear-gradient(#fff1b0, var(--gold));
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 1.5rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  box-shadow: 0 6px 0 #b88928;
}

.pad:active, .pad.held {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b88928;
}

.pad.zap {
  flex: 0 0 auto;
  width: 168px;
  font-size: 1.15rem;
  line-height: 1.15;
  background: linear-gradient(#efe0ff, #c9a0ef);
  border-color: #7b3fa0;
  box-shadow: 0 6px 0 #5a2d80;
}
.pad.zap:active, .pad.zap.held {
  box-shadow: 0 2px 0 #5a2d80;
}

.hint {
  text-align: center;
  font-size: .85rem;
  opacity: .75;
  margin: 0 12px 4px;
}

.credit {
  text-align: center;
  font-size: .78rem;
  opacity: .7;
  padding: 4px 12px 16px;
}

@media (max-width: 640px) {
  .stage { aspect-ratio: 5 / 4; height: 58vh; }
  .hud { flex-wrap: wrap; }
  .pads { flex-wrap: wrap; }
  .pad { height: 56px; width: 120px; }
  .pad.zap { width: 130px; }
}

.card-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 4px 0 10px;
}

.card-actions .btn {
  flex: 1 1 auto;
  min-width: 150px;
  white-space: nowrap;
}

/* The game-over card must never push a button off the stage. */
#overlay-over .card {
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

#overlay-over .scores {
  flex: 1 1 auto;
  min-height: 0;
}

.controls {
  text-align: center;
  margin: 2px auto 6px;
  font-weight: 800;
  font-size: .95rem;
  line-height: 1.5;
}

.controls .keys {
  display: inline-block;
  background: #fff;
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 3px 12px;
  margin: 3px 4px;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(22, 49, 92, .1);
}

/* keep the start card's how-to and scoreboard readable inside a short stage */
#overlay-start .card .how { font-size: .9rem; }
#overlay-start .card .scores { max-height: 110px; }

@media (max-height: 620px) {
  #overlay-start .card h2 { font-size: 1.5rem; }
  #overlay-start .card .how { font-size: .82rem; }
  #overlay-start .card .scores { max-height: 76px; }
}

/* A card can scroll, but its buttons must never scroll out of reach. */
/* Pin the buttons without touching how they look (the id selector used to
   beat .btn.gold and paint Play cream-on-cream). */
#overlay-start #btn-play {
  position: sticky;
  bottom: 2px;
  z-index: 2;
}

#overlay-over .card-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: rgba(255, 248, 232, .97);
  padding: 8px 0 4px;
  border-radius: 14px;
  box-shadow: 0 -10px 12px rgba(255, 248, 232, .97);
}

#overlay-start .card,
#overlay-over .card {
  scrollbar-width: thin;
}

.stat.mega {
  background: linear-gradient(#ff6b6b, #d2352f);
  color: #fff;
  border-color: #8e1c18;
  text-shadow: none;
  animation: megapulse .6s ease-in-out infinite alternate;
}

@keyframes megapulse {
  from { transform: scale(1); }
  to { transform: scale(1.07); }
}
