/* Polymorph — multiplayer platformer client styles.
 * Follows the pacman/nightfall overlay conventions (shared style.css provides
 * .overlay, .overlay-card, .btn-primary, .btn-secondary, .spinner, .hidden,
 * .volume-slider, .back-to-games). This file adds the Polymorph-specific look:
 * a neon "morphing cube" logo, the lobby card, the 3D canvas shell, the
 * spectator banner and the fun-stats awards grid.
 */

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Outfit", Arial, sans-serif;
  background: #05040c;
  color: #e8f2ff;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.polymorph-card {
  width: min(92vw, 560px);
}

.polymorph-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #00f3ff, #9d00ff);
  box-shadow: 0 0 28px rgba(0, 243, 255, 0.35);
  animation: polymorphLogoSpin 6s linear infinite;
}

.polymorph-logo-core {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #0b1a2e;
  box-shadow: inset 0 0 0 3px rgba(0, 243, 255, 0.8);
}

@keyframes polymorphLogoSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.name-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(0, 243, 255, 0.35);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #e8f2ff;
  font: inherit;
  margin-bottom: 12px;
}

.name-input:focus {
  outline: none;
  border-color: #00f3ff;
}

.btn-primary {
  background: #00f3ff;
  color: #06121f;
}

.btn-secondary {
  border-color: rgba(0, 243, 255, 0.35);
  color: #e8f2ff;
}

.btn-secondary:hover {
  border-color: #00f3ff;
  color: #00f3ff;
}

.back-to-games {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: #7fa8c9;
  text-decoration: none;
  transition: color 0.2s;
}

.back-to-games:hover {
  color: #00f3ff;
  text-decoration: underline;
}

.player-list,
.rankings-table,
.placements-list {
  width: 100%;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.player-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 12px;
}

.player-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}

.player-name {
  flex: 1;
  text-align: left;
}

.host-badge {
  color: #00f3ff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.waiting-text,
.winner-text,
.rankings-empty p {
  color: #e8f2ff;
}

.waiting-text {
  margin-top: 12px;
  color: #7fa8c9;
}

.countdown-number {
  color: #00f3ff;
  font-size: clamp(96px, 20vw, 180px);
  font-weight: 900;
  text-shadow:
    0 0 18px rgba(0, 243, 255, 0.85),
    0 0 48px rgba(0, 243, 255, 0.45);
  animation: polymorphCountdownPulse 1s ease-in-out infinite;
}

@keyframes polymorphCountdownPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.75; transform: scale(1.14); }
}

.score-card {
  width: min(92vw, 640px);
}

.placements-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0;
}

.awards-section {
  margin: 18px 0 20px;
  text-align: left;
}

.awards-section h2 {
  margin: 0 0 12px;
  color: #00f3ff;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
}

.awards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.award-card {
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 243, 255, 0.04);
}

.award-card strong {
  display: block;
  color: #00f3ff;
  margin-bottom: 6px;
}

.award-card .award-player {
  display: block;
  color: #e8f2ff;
  font-weight: 700;
}

.award-card .award-meta {
  display: block;
  margin-top: 4px;
  color: #7fa8c9;
  font-size: 0.84rem;
}

.placement-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 243, 255, 0.35);
  background: rgba(0, 0, 0, 0.45);
}

.placement-rank {
  color: #00f3ff;
  font-weight: 700;
}

.rankings-empty {
  padding: 16px 0 20px;
}

.rankings-empty h2 {
  color: #00f3ff;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

#rankingsTableWrap {
  max-height: 340px;
  overflow: auto;
  margin: 18px 0;
}

.rankings-table {
  border-collapse: collapse;
}

.rankings-table th,
.rankings-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.25);
  text-align: left;
}

.rankings-table th {
  color: #00f3ff;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  pointer-events: none;
  color: #e8f2ff;
}

#hud.hidden {
  display: none !important;
}

.hud-panel {
  background: rgba(10, 15, 30, 0.5);
  border: 1px solid rgba(124, 63, 255, 0.28);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 0.92rem;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 220px;
}

#hudLevel {
  color: #4db8a0;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#hudPulse {
  color: #4db8a0;
}

#hudPulse.cooling {
  color: #9fb2c9;
}

.hp-track {
  width: 176px;
  height: 15px;
  border-radius: 8px;
  background: rgba(0, 18, 38, 0.6);
  overflow: hidden;
  position: relative;
}

.hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #00e5ff 0%, #3affe0 48%, #a855ff 100%);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.85);
  transition: width 0.45s ease;
  background-size: 200% 100%;
  animation: poly-liquid-flow 1.6s linear infinite;
}

.hp-fill.low {
  background: linear-gradient(90deg, #ff2d6b, #ff6ba6);
  box-shadow: 0 0 12px rgba(255, 45, 107, 0.85);
}

@keyframes poly-liquid-flow {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}

.spectator-banner {
  /* Pinned to the BOTTOM, not the top: #hud is fixed at top:0 with z-index 20
     and used to paint straight over this bar, clipping the switch buttons. The
     bottom edge is also the thumb-reachable half on a phone.
     z-index has to clear #canvasWrap (fixed, inset 0) or the canvas swallows
     every click on the arrows. */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 8px 12px;
  text-align: center;
  background: rgba(0, 243, 255, 0.18);
  border-top: 1px solid rgba(0, 243, 255, 0.8);
  color: #00f3ff;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.spectator-banner.hidden {
  display: none;
}

/* Step the spectator camera between players. Sized for a thumb, because these
   buttons are the only way to switch targets without a keyboard. */
.spectate-arrow {
  min-width: 40px;
  min-height: 32px;
  padding: 2px 10px;
  border: 1px solid rgba(0, 243, 255, 0.8);
  border-radius: 6px;
  background: rgba(0, 243, 255, 0.12);
  color: #00f3ff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.spectate-arrow:hover {
  background: rgba(0, 243, 255, 0.28);
}

.spectate-arrow.hidden {
  display: none;
}

#canvasWrap {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #05040c;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.audio-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  justify-content: center;
}

.audio-controls input[type="range"] {
  width: 150px;
  margin: 0;
}

.lobby-chat-area {
  margin-top: 14px;
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px;
}

.lobby-chat-messages {
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: #cfe4f7;
  margin-bottom: 6px;
}

.lobby-chat-input-row {
  display: flex;
}

.lobby-chat-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #e8f2ff;
  font: inherit;
}

.lobby-chat-input:focus {
  outline: none;
  border-color: #00f3ff;
}

/* The AFK warning shares the banner's shape but must not read as information —
 * it is a countdown to being removed from the level, so it is amber and it
 * pulses. The server kills a player 30s after they stop playing, because a
 * level only ends when every survivor reaches the portal and one idler
 * otherwise holds the whole lobby there indefinitely. */
.afk-banner {
  background: rgba(255, 176, 32, 0.2);
  border-bottom-color: rgba(255, 176, 32, 0.85);
  color: #ffd479;
  animation: afk-pulse 1s ease-in-out infinite;
}

@keyframes afk-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .afk-banner { animation: none; }
}
