:root {
  /* Colors */
  --color-bg: #222;
  --color-text: #a3a3a3;
  --color-white: #fff;
  --color-black-alpha: rgba(0, 0, 0, 0.7);
  --color-black-alpha-dark: rgba(0, 0, 0, 0.9);

  --color-round: #000;
  --color-win: #4caf50;
  --color-lose: #f44336;
  --color-recurse-green: #23a050;

  /* Sizes */
  --game-width: 800px;
  --game-height: 600px;

  /* Typography */
  --font-family: 'Courier New', Courier, monospace;
  --font-size-small: 14px;
  --font-size-medium: 24px;
  --font-size-large: 32px;

  /* Layers */
  --z-overlay: 1000;

  /* Animations */
  --bounce-curve: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

body {
  font: var(--font-family);
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

p,
a {
  font-family: var(--font-family);
}

a {
  color: var(--color-recurse-green);
}

a:hover {
  cursor: pointer;
}

.text-center {
  text-align: center;
}

.page-container {
  max-width: max-content;
  padding-top: 3rem;
  padding-bottom: 4rem;
}

/* RC logo wrapper*/
#game-container-wrapper {
  transform: scale(0.8);
  position: relative;
  background-image: url('./recurse.svg');
  background-position: center;
  background-repeat: no-repeat;
  background-size: 961px; /* hand-calibrated to center canvas lol */
  width: 900px;
  height: 1200px;
}

#game-container {
  position: relative;
  top: 79px;
  left: 50px;
  background-color: transparent;
  width: var(--game-width);
  height: calc(var(--game-height) + 50px);
}

canvas {
  position: relative;
  background: var(--color-white);
  width: var(--game-width);
  height: var(--game-height);
}

.start-splash-overlay, .error-splash-overlay {
  font-family: var(--font-family);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: var(--color-black-alpha);
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

 .error-splash-overlay {
  background: #ff7f7f;
  color: white;
 }

.splash-content, .error-splash-content {
  text-align: center;
}

.splash-content h1 {
  font-size: 2.5em;
  margin-bottom: 1em;
}

.start-button {
  padding: 1em 2em;
  font-size: 1.2em;
  background: #4caf50;
  color: var(--color-white);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s;
  animation: pulsate 0.75s infinite;
}

.start-button:hover {
  background: #45a049;
  animation: none;
}

/* Instruction overlay */
.instruction-overlay {
  font-family: var(--font-family);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--color-black-alpha);
  color: var(--color-white);
  font-size: var(--font-size-large);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: var(--z-overlay);
}

.instruction-overlay.visible {
  opacity: 1;
  animation:
    bounceIn 0.4s var(--bounce-curve) forwards,
    fadeOut 0.3s ease forwards 0.7s;
}

/* Timer overlay */
.timer-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 10px;
  background: var(--color-black-alpha);
  border-radius: 5px;
  overflow: hidden;
  z-index: var(--z-overlay);
  border: 1px solid var(--color-bg);
}

.timer-progress {
  width: 100%;
  height: 100%;
  background: var(--color-white);
  transition: width linear;
}

/* Score overlay */
.score-overlay {
  display: flex;
  gap: 20px;
  font-family: var(--font-family);
  font-size: var(--font-size-medium);
  font-weight: bold;
  color: var(--color-white);
  z-index: var(--z-overlay);
  padding: 6px;
  border-bottom: 1px solid var(--color-text);
}

.score-overlay .round {
  color: var(--color-round);
}

.score-overlay .wins {
  color: var(--color-win);
}

.score-overlay .losses {
  color: var(--color-lose);
}

/* Author overlay */

.author-overlay {
  position: absolute;
  bottom: -30px;
  right: 0;
  font-family: var(--font-family);
  font-size: 1.1rem;
  color: var(--color-text);
  padding: 5px;
  text-align: right;
}

/* Game Directory */

.directory-button {
  font-family: var(--font-family);
  font-size: large;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.directory-overlay {
  font-family: var(--font-family);
  font-size: large;
  position: fixed;
  color: var(--color-text);
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 600px;
  max-height: 550px;
  background: var(--color-black-alpha-dark);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  overflow-y: scroll;
  touch-action: pan-y;
}

.directory-overlay a {
  text-decoration: none;
}

.directory-header {
  color: var(--color-white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
}

.directory-header h2 {
  margin: 0;
  font-size: 1.2em;
}

.directory-close-button {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-white);
  cursor: pointer;
  padding: 0 8px;
}

.directory-games-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.directory-game-entry {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.directory-game-name {
  font-weight: bold;
  margin-right: 8px;
}

.directory-game-author {
  color: var(--color-text);
}

.directory-back-entry {
  color: var(--color-white);
}

.directory-back-entry a {
  color: var(--color-white);
}

@keyframes pulsate {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }

  70% {
    transform: scale(0.9);
    opacity: 0.9;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeOut {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}
