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

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, #031525, #062d5c, #0d6efd);
  min-height: 100vh;
  overflow-x: hidden;
  color: white;
}

body::before {
  content: '';
  position: fixed;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, #ffffff20 2px, transparent 2px);
  background-size: 50px 50px;
  animation: moveBg 25s linear infinite;
  z-index: -1;
}

@keyframes moveBg {
  from {
    transform: translate(0, 0);
  }

  to {
    transform: translate(-300px, -300px);
  }
}

/* Header */

header {
  text-align: center;
  padding: 40px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

header h1 {
  font-size: 4rem;
  background: linear-gradient(to right, #fff, #7db6ff);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeDown 1s ease;
}

header p {
  opacity: .8;
  margin-top: 10px;
}

header nav {
  margin-top: 10px;
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hero */

.hero {
  text-align: center;
  padding: 30px;
}

.hero h2 {
  font-size: 2rem;
  margin-bottom: 15px;
}

.hero button {
  padding: 15px 30px;
  border: none;
  border-radius: 50px;
  background: #0d6efd;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: .4s;
  box-shadow: 0 0 20px #0d6efd;
}

.hero button:hover {
  transform: scale(1.08);
  box-shadow: 0 0 40px #0d6efd;
}

/* Stats */

.stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 30px;
  margin: 40px 0;
}

.stat {
  text-align: center;
}

.stat h2 {
  font-size: 2.5rem;
  color: #7db6ff;
}

/* Project Grid */

.projetos {
  display: block;
  padding: 60px 20px;
}

.project-section {
  margin-bottom: 70px;
}

.section-title {
  text-align: center;
  font-size: 2rem;
  color: #7db6ff;
  margin: 0 0 8px;
}

.section-subtitle {
  text-align: center;
  color: rgba(255, 255, 255, .6);
  font-size: 1rem;
  margin: 0 0 34px;
}

.grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 30px;
}

.loading {
  text-align: center;
  color: rgba(255, 255, 255, .6);
  font-size: 1.1rem;
  padding: 3rem;
  width: 100%;
}

/* Card */

.card {
  width: 320px;
  padding: 25px;
  border-radius: 25px;
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .15);
  transition: .5s;
  position: relative;
  overflow: hidden;
  animation: cardUp 1s ease;
}

@keyframes cardUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card::before {
  content: '';
  position: absolute;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, .2), transparent);
  top: -100%;
  left: -100%;
  transition: .8s;
}

.card:hover::before {
  top: 100%;
  left: 100%;
}

.card:hover {
  transform: perspective(1000px) rotateX(5deg) rotateY(-5deg) translateY(-15px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4), 0 0 30px #0d6efd;
}

.card .card-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

/* Thumbnail do jogo (projects/<id>/thumbnail.png) no topo do card */
.card.has-thumb {
  padding: 0;
}

.card .card-body {
  padding: 0;
}

.card.has-thumb .card-body {
  padding: 20px 25px 25px;
}

.card-thumb {
  position: relative;
  height: 180px;
  overflow: hidden;
  background: linear-gradient(135deg, #0a2540, #0d6efd55);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.card-thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  opacity: .8;
}

.card-thumb img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}

.card:hover .card-thumb img {
  transform: scale(1.07);
}

.card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(3, 21, 37, .45), transparent 55%);
  pointer-events: none;
}

.card-thumb-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 1;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}

.card h3 {
  margin-bottom: 5px;
  color: #8ec5ff;
  font-size: 1.2rem;
}

.card .author {
  font-size: 0.8rem;
  opacity: .6;
  margin-bottom: 10px;
}

.card .description {
  opacity: .85;
  line-height: 1.6;
  font-size: 0.9rem;
  margin-bottom: 20px;
  min-height: 3.2em;
}

.card .links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.card .github-link {
  color: rgba(255, 255, 255, .6);
  font-size: 0.85rem;
  text-decoration: none;
  transition: .3s;
}

.card .github-link:hover {
  color: #fff;
}

.card a.btn-play {
  display: inline-block;
  text-decoration: none;
  color: white;
  background: #0d6efd;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  transition: .3s;
  border: none;
  cursor: pointer;
}

.card a.btn-play:hover {
  background: #4a94ff;
}

/* Run page */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.btn-back {
  color: rgba(255, 255, 255, .8);
  text-decoration: none;
  font-weight: 400;
  font-size: 1rem;
  transition: .3s;
}

.btn-back:hover {
  color: #fff;
}

.info-card {
  width: 100%;
  margin-bottom: 30px;
}

.info-card h2 {
  font-size: 1.5rem;
  color: #8ec5ff;
  margin-bottom: 5px;
}

.info-card #project-author {
  font-size: 0.85rem;
  opacity: .6;
  margin-bottom: 10px;
}

.info-card #project-description {
  opacity: .85;
  line-height: 1.6;
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.info-card #project-github {
  color: #7db6ff;
  text-decoration: none;
  font-size: 0.9rem;
  transition: .3s;
}

.info-card #project-github:hover {
  color: #fff;
}

/* Terminal */

.terminal-wrapper {
  margin: 20px 0;
}

#terminal-container {
  position: relative;
  background: #05070d;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

#terminal {
  height: 62vh;
  min-height: 400px;
  max-height: 70vh;
  padding: 12px;
}

/* Garante fonte monoespaçada real no xterm.
   Sem isso o Poppins global quebra a medição das células
   e os cantos ╭─╮ do Rich ficam sobrepostos. */
#terminal .xterm,
#terminal .xterm-viewport,
#terminal canvas {
  font-family: 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, 'DejaVu Sans Mono', monospace !important;
  font-variant-ligatures: none !important;
  letter-spacing: 0 !important;
}

#terminal .xterm-viewport {
  overflow-y: auto;
}

#controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.btn {
  display: inline-block;
  background: #0d6efd;
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 30px;
  font-size: 1rem;
  font-weight: 400;
  cursor: pointer;
  transition: .4s;
  box-shadow: 0 0 15px #0d6efd55;
}

.btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px #0d6efd;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-pygame {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.badge-terminal {
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
  border: 1px solid rgba(52, 152, 219, 0.4);
}

.info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

/* Pygame Game Wrapper */
.game-wrapper {
  margin: 20px 0;
  width: 100%;
}

#game-container {
  background: #0a0e1a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

#game-canvas-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #05070d;
  min-height: 400px;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  outline: none;
  cursor: pointer;
  image-rendering: auto;
}

#game-canvas:focus {
  box-shadow: inset 0 0 0 2px #0d6efd;
}

/* WASM (pygbag) iframe: jogo renderizado pelo navegador do aluno */
#wasm-container {
  background: #05070d;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  overflow: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
}

#wasm-frame {
  border: 0;
  width: 1100px;
  max-width: 100%;
  height: 600px;
  max-height: 70vh;
  background: #05070d;
}

.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 13, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.game-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  color: #fff;
  padding: 20px 30px;
  border-radius: 16px;
  background: rgba(13, 110, 253, 0.2);
  border: 1px solid rgba(13, 110, 253, 0.4);
}

.overlay-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
}

.overlay-content p {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.overlay-content small {
  color: rgba(255, 255, 255, 0.7);
}

/* Game Toolbar */
#game-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-toolbar {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-toolbar:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-toolbar.audio-blocked {
  background: rgba(255, 193, 7, 0.25);
  border-color: rgba(255, 193, 7, 0.6);
  animation: pulseAudio 1.4s infinite;
}

@keyframes pulseAudio {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,193,7,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255,193,7,0); }
}

.volume-slider {
  width: 80px;
  accent-color: #0d6efd;
  cursor: pointer;
}

.game-stat {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: monospace;
}

.game-logs-section {
  margin-top: 15px;
}

.btn-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 0;
  text-decoration: underline;
  transition: 0.2s;
}

.btn-link:hover {
  color: #fff;
}

.game-logs {
  margin-top: 8px;
  background: #05070d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.game-logs pre {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #8ec5ff;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Play layout: jogo à esquerda + painel de controles à direita */
main.with-controls {
  max-width: 1600px;
}

.play-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.play-main {
  flex: 1;
  min-width: 0;
}

.controls-panel {
  width: 300px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, .08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  padding: 20px;
  position: sticky;
  top: 20px;
}

.controls-panel h3 {
  font-size: 1.1rem;
  color: #8ec5ff;
  margin-bottom: 14px;
}

.controls-group + .controls-group {
  margin-top: 14px;
}

.controls-group h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7db6ff;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.85rem;
}

.control-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 88px;
}

.control-action {
  opacity: .85;
  line-height: 1.4;
}

kbd {
  font-family: 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* Ícone de tecla especial (ex: clique do mouse) — mesma pílula do kbd */
.key-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  color: #8ec5ff;
}

@media (max-width: 1024px) {
  .play-layout {
    flex-direction: column;
  }

  .controls-panel {
    width: 100%;
    position: static;
  }

  main.with-controls {
    max-width: 1200px;
  }
}

.hidden {
  display: none !important;
}

/* Toast */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .12);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .15);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.9rem;
  z-index: 100;
  transition: opacity .3s;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Footer */

footer {
  text-align: center;
  padding: 40px;
  opacity: .7;
}

/* Featured card (Quiz Arena — site externo, só link) */

.featured-card {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 230px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 18px 14px 16px;
  border-radius: 20px;
  background: rgba(7, 17, 31, .93);
  backdrop-filter: blur(12px);
  border: 2px solid #f7c951;
  text-decoration: none;
  text-align: center;
  animation: goldGlow 2.6s ease-in-out infinite;
  transition: transform .35s ease;
}

.featured-card:hover {
  transform: translateY(-50%) scale(1.05);
  animation-play-state: paused;
  box-shadow: 0 0 30px rgba(247, 201, 81, .9), 0 0 90px rgba(247, 201, 81, .4), 0 18px 45px rgba(0, 0, 0, .5);
}

@keyframes goldGlow {
  0%, 100% {
    box-shadow: 0 0 14px rgba(247, 201, 81, .45), 0 0 42px rgba(247, 201, 81, .18), 0 18px 45px rgba(0, 0, 0, .5);
  }

  50% {
    box-shadow: 0 0 26px rgba(247, 201, 81, .85), 0 0 85px rgba(247, 201, 81, .35), 0 18px 45px rgba(0, 0, 0, .5);
  }
}

.featured-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 14px;
  border-radius: 999px;
  background: linear-gradient(100deg, #f7c951, #f6bd52);
  color: #231a05;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  box-shadow: 0 4px 14px rgba(247, 201, 81, .5);
}

.featured-card img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #1b3554;
  display: block;
}

.featured-text {
  color: #dbe8f6;
  font-size: .82rem;
  line-height: 1.45;
}

.featured-cta {
  display: inline-block;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(100deg, #f7c951, #ee9956);
  color: #231a05;
  font-weight: 700;
  font-size: .85rem;
}

@media (max-width: 1099px) {
  /* Em telas menores o card entra no fluxo, logo após o hero */
  .featured-card {
    position: static;
    transform: none;
    width: min(440px, 92%);
    margin: 6px auto 0;
  }

  .featured-card:hover {
    transform: scale(1.02);
  }
}

/* Responsive */

@media (max-width: 768px) {
  header h1 {
    font-size: 2.5rem;
  }

  .hero h2 {
    font-size: 1.5rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .projetos {
    padding: 40px 16px;
  }

  .card {
    width: 90%;
  }

  .card-thumb {
    height: 160px;
  }

  #terminal {
    height: 55vh;
    min-height: 350px;
    max-height: 60vh;
  }
}