/* Header Section */
header {
  background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background */
  padding: 4px 8px;
  color: white;
}

/* Adjust the width of the logo */
.logo {
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 260px;
  width: 34%;
}

h1 {
  font-size: 24px;
  line-height: 1;
  margin: 5px;
}

body {
  text-align: center;
  background: #8fbc8f;
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
}

body.game-is-playing,
body.screen-is-open {
  height: 100vh;
  height: 100dvh;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  width: 100%;
}

h1, p {
  margin: 5px;
}

#keyboard {
  opacity: 0;
}

.keyboard-link {
  display: none;
}

#gameArea {
  position: relative;
}

#gameCabinet {
  margin: 12px auto 24px;
  width: min(505px, 96vw);
}

#canvasMount canvas {
  height: auto;
  margin: 0 auto;
  max-width: 100%;
  touch-action: none;
  width: 100%;
}

canvas {
  display: block;
  margin: 12px auto 0;
}

.quote-ticker {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.98), rgba(6, 30, 14, 0.92), rgba(0, 0, 0, 0.98));
  border: 3px solid #071f10;
  border-top: 0;
  box-shadow:
    inset 0 0 18px rgba(52, 255, 89, 0.22),
    0 8px 24px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  height: 42px;
  margin-top: -76px;
  overflow: hidden;
  position: relative;
  width: 100%;
  z-index: 3;
}

.quote-ticker::before,
.quote-ticker::after {
  content: "";
  height: 100%;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 70px;
  z-index: 2;
}

.quote-ticker::before {
  background: linear-gradient(90deg, #000, rgba(0, 0, 0, 0));
  left: 0;
}

.quote-ticker::after {
  background: linear-gradient(270deg, #000, rgba(0, 0, 0, 0));
  right: 0;
}

.quote-track {
  animation: quote-scroll 32s linear infinite;
  color: #39ff5a;
  display: inline-flex;
  font-family: "Courier New", Courier, monospace;
  font-size: 19px;
  font-weight: bold;
  gap: 34px;
  line-height: 42px;
  min-width: max-content;
  padding-left: 100%;
  text-shadow:
    0 0 4px rgba(57, 255, 90, 0.95),
    0 0 12px rgba(57, 255, 90, 0.85),
    0 0 22px rgba(57, 255, 90, 0.55);
  text-transform: uppercase;
  white-space: nowrap;
}

.quote-track span::before {
  color: #f4d03f;
  content: ">";
  margin-right: 10px;
  text-shadow: 0 0 8px rgba(244, 208, 63, 0.9);
}

@keyframes quote-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

.mobile-controls {
  display: none;
}

.dpad-button,
.dpad-center {
  align-items: center;
  border: 0;
  border-radius: 8px;
  display: flex;
  font-size: 24px;
  font-weight: bold;
  height: 58px;
  justify-content: center;
  touch-action: manipulation;
  width: 58px;
}

.dpad-button {
  background: rgba(0, 0, 0, 0.78);
  box-shadow:
    inset 0 0 14px rgba(57, 255, 90, 0.24),
    0 4px 12px rgba(0, 0, 0, 0.35);
  color: #39ff5a;
  cursor: pointer;
  text-shadow: 0 0 10px rgba(57, 255, 90, 0.9);
}

.dpad-button:active {
  background: rgba(57, 255, 90, 0.28);
  transform: translateY(1px);
}

.dpad-center {
  background: rgba(244, 208, 63, 0.2);
  color: rgba(244, 208, 63, 0.8);
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
}

.dpad-center {
  grid-column: 2;
  grid-row: 2;
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
}

.dpad-down {
  grid-column: 2;
  grid-row: 3;
}

.game-screen {
  align-items: flex-start;
  background:
    linear-gradient(rgba(7, 22, 18, 0.82), rgba(7, 22, 18, 0.82)),
    url("../images/stone-block.png");
  box-sizing: border-box;
  display: none;
  height: 100vh;
  height: 100dvh;
  inset: 0;
  justify-content: center;
  overflow-y: auto;
  padding: 18px 18px 28px;
  position: fixed;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  z-index: 20;
}

.game-screen.is-visible {
  display: flex;
}

.menu-scene {
  background: rgba(14, 35, 28, 0.94);
  border: 4px solid #f4d03f;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  color: #fff;
  margin: auto;
  max-width: 640px;
  padding: 22px;
  width: min(92vw, 640px);
}

.menu-banner {
  display: block;
  height: auto;
  margin: 0 auto 12px;
  max-width: 440px;
  width: 88%;
}

.hero-lineup {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  margin: 8px auto 12px;
  max-width: 420px;
}

.hero-lineup img {
  height: 104px;
  object-fit: contain;
  width: 100%;
}

.menu-scene h2 {
  color: #f4d03f;
  font-size: 42px;
  line-height: 1.05;
  margin: 8px 0;
  text-shadow: 3px 3px 0 #111;
}

.menu-scene p {
  color: #f8f8f8;
  font-size: 18px;
  line-height: 1.35;
  margin: 10px auto 18px;
  max-width: 440px;
}

.button-primary,
.button-secondary {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  min-width: 150px;
  padding: 13px 20px;
}

.button-primary {
  background: #f44336;
  color: #fff;
}

.button-primary:hover,
.button-primary:focus {
  background: #ff6659;
}

.button-secondary {
  background: #f4d03f;
  color: #14231d;
}

.button-secondary:hover,
.button-secondary:focus {
  background: #ffe36d;
}

.menu-help-button {
  font-size: 17px;
  margin: 2px 0 8px;
  min-width: 132px;
  padding: 9px 14px;
}

.game-over-icon {
  height: 116px;
  object-fit: contain;
  width: 116px;
}

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.start-high-score {
  background: #f4d03f;
  border: 3px solid #111;
  border-radius: 6px;
  color: #14231d;
  display: inline-block;
  font-size: 22px;
  font-weight: bold;
  margin: 4px 0 18px;
  padding: 10px 16px;
}

.creator-credit {
  color: #d9f7de;
  font-size: 12px;
  letter-spacing: 0;
  margin: 12px 0 0;
  opacity: 0.82;
}

.character-select {
  margin: 14px auto 16px;
  max-width: 500px;
}

.character-select h3 {
  color: #f4d03f;
  font-size: 18px;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.character-options {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
}

.character-option {
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: bold;
  min-height: 126px;
  padding: 8px 6px;
}

.character-option img {
  display: block;
  height: 66px;
  margin: 0 auto 6px;
  object-fit: contain;
  width: 100%;
}

.character-option span,
.character-option small {
  display: block;
}

.character-option small {
  color: #d9f7de;
  font-size: 12px;
  line-height: 1.15;
  margin-top: 4px;
}

.character-option:hover,
.character-option:focus {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.5);
}

.character-option.is-selected {
  background: rgba(244, 208, 63, 0.22);
  border-color: #f4d03f;
  color: #f4d03f;
}

.character-option.is-selected small {
  color: #fff7bf;
}

.character-card-overlay,
.instructions-overlay {
  align-items: center;
  background: rgba(0, 0, 0, 0.76);
  display: none;
  inset: 0;
  justify-content: center;
  overflow-y: auto;
  padding: 22px;
  position: fixed;
  z-index: 30;
}

.character-card-overlay.is-visible,
.instructions-overlay.is-visible {
  display: flex;
}

.character-card,
.instructions-card {
  background:
    linear-gradient(145deg, rgba(7, 24, 15, 0.98), rgba(18, 61, 32, 0.98)),
    url("../images/grass-block.png");
  border: 5px solid #f4d03f;
  border-radius: 8px;
  box-shadow:
    0 26px 64px rgba(0, 0, 0, 0.55),
    inset 0 0 28px rgba(57, 255, 90, 0.18);
  color: #fff;
  max-width: 380px;
  padding: 16px;
  position: relative;
  text-align: left;
  width: min(92vw, 380px);
}

.instructions-card {
  max-width: 520px;
  width: min(92vw, 520px);
}

.character-card::before,
.instructions-card::before {
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  content: "";
  inset: 8px;
  pointer-events: none;
  position: absolute;
}

.character-card-close {
  background: #f44336;
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  padding: 8px 12px;
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
}

.card-header {
  padding-right: 86px;
  position: relative;
  z-index: 1;
}

.instructions-header strong {
  font-size: 32px;
}

.card-role {
  color: #f4d03f;
  display: block;
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
}

.card-header strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin-top: 4px;
  text-shadow: 3px 3px 0 #111;
}

.card-art-frame {
  background: radial-gradient(circle, rgba(57, 255, 90, 0.32), rgba(0, 0, 0, 0.7));
  border: 3px solid rgba(244, 208, 63, 0.9);
  border-radius: 8px;
  margin: 16px auto;
  min-height: 178px;
  position: relative;
  z-index: 1;
}

.card-art-frame img {
  display: block;
  height: 178px;
  margin: 0 auto;
  object-fit: contain;
  width: 80%;
}

.card-stats,
.card-abilities {
  position: relative;
  z-index: 1;
}

.card-stats {
  background: rgba(0, 0, 0, 0.36);
  border-radius: 8px;
  padding: 10px 12px;
}

.card-stats p {
  font-size: 15px;
  line-height: 1.25;
  margin: 5px 0;
}

.card-stats strong,
.card-abilities h3 {
  color: #f4d03f;
}

.card-abilities h3 {
  font-size: 17px;
  margin: 14px 0 8px;
  text-transform: uppercase;
}

.card-abilities ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-abilities li {
  background: rgba(255, 255, 255, 0.09);
  border-left: 4px solid #39ff5a;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.25;
  margin-bottom: 7px;
  padding: 8px 10px;
}

.instructions-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

.instructions-grid section {
  background: rgba(255, 255, 255, 0.09);
  border-left: 4px solid #39ff5a;
  border-radius: 4px;
  padding: 10px;
}

.instructions-grid h3 {
  color: #f4d03f;
  font-size: 16px;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.instructions-grid p,
.instructions-tagline {
  color: #fff;
  font-size: 15px;
  line-height: 1.3;
  margin: 0;
}

.instructions-tagline {
  color: #d9f7de;
  font-weight: bold;
  margin-top: 14px;
  position: relative;
  text-align: center;
  z-index: 1;
}

.high-score-form {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(244, 208, 63, 0.75);
  border-radius: 8px;
  margin: 12px auto;
  max-width: 440px;
  padding: 14px;
}

.high-score-form label {
  color: #f4d03f;
  display: block;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.initials-row {
  align-items: stretch;
  display: flex;
  gap: 10px;
  justify-content: center;
}

#initialsInput {
  border: 3px solid #111;
  border-radius: 6px;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 0;
  max-width: 90px;
  padding: 8px;
  text-align: center;
  text-transform: uppercase;
}

.score-save-message {
  color: #fff;
  font-size: 14px;
  min-height: 20px;
}

.leaderboard {
  margin: 12px auto 18px;
  max-width: 440px;
  text-align: left;
}

.leaderboard h3 {
  color: #f4d03f;
  margin: 0 0 8px;
  text-align: center;
}

#highScoreList {
  background: rgba(0, 0, 0, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  list-style-position: inside;
  margin: 0;
  max-height: 142px;
  overflow-y: auto;
  padding: 8px 12px;
}

#highScoreList li {
  color: #fff;
  display: flex;
  font-size: 18px;
  font-weight: bold;
  justify-content: space-between;
  padding: 5px 2px;
}

#highScoreList .empty-score {
  display: block;
  font-size: 16px;
  text-align: center;
}

@media (max-width: 700px) {
  header {
    padding: 3px 6px;
  }

  .logo {
    max-width: 210px;
    width: 52%;
  }

  h1 {
    font-size: 20px;
    margin: 3px;
  }

  #gameCabinet {
    margin-top: 6px;
  }

  .menu-scene {
    padding: 14px;
  }

  .menu-scene h2 {
    font-size: 30px;
    margin: 4px 0;
  }

  .menu-scene p {
    font-size: 15px;
    margin: 6px auto 10px;
  }

  .hero-lineup img {
    height: 64px;
  }

  .menu-banner {
    margin-bottom: 6px;
    width: 74%;
  }

  .hero-lineup {
    margin: 6px auto 8px;
  }

  .character-options {
    grid-template-columns: repeat(2, minmax(112px, 1fr));
  }

  .character-select {
    margin: 10px auto 12px;
  }

  .character-option {
    min-height: 104px;
    padding: 6px;
  }

  .character-option img {
    height: 54px;
  }

  .start-high-score {
    font-size: 17px;
    margin-bottom: 12px;
    padding: 8px 12px;
  }

  .button-primary,
  .button-secondary {
    font-size: 18px;
    padding: 11px 16px;
  }

  .instructions-grid {
    grid-template-columns: 1fr;
  }

  .instructions-header strong {
    font-size: 28px;
  }
}

@media (max-width: 700px), (pointer: coarse) {
  .mobile-controls {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, 58px);
    grid-template-rows: repeat(3, 58px);
    justify-content: center;
    margin: 14px auto 6px;
    user-select: none;
  }

  #keyboard,
  .keyboard-link {
    display: none !important;
  }
}

@media (max-width: 420px) {
  #gameCabinet {
    width: min(505px, 98vw);
  }

  .quote-ticker {
    height: 36px;
    margin-top: -68px;
  }

  .quote-track {
    font-size: 16px;
    line-height: 36px;
  }

  .dpad-button,
  .dpad-center {
    height: 52px;
    width: 52px;
  }

  .mobile-controls {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
  }
}
