/* Root and Body ---------------------------------------------------- */

:root {
  --bg: #05070b;
  --ui: #141b24;
  --accent: #68f08a;
  --danger: #ff6b6b;
  --text: #ecf4ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: radial-gradient(circle at top, #18283d 0, #05070b 55%);
  color: var(--text);
  font-family: "Monofonto", monospace;
}

/* Buttons -----------------------------------------------------------*/

button {
  border: 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.06s ease-in-out,
    filter 0.15s ease-in-out,
    box-shadow 0.15s;
  color: #050b12;
  text-align: left;
}

button span.lbl {
  display: block;
  font-size: 1.125rem;
  color: rgba(11, 16, 5, 0.751);
}

button span.sub {
  display: block;
  font-size: 0.875rem;
  opacity: 0.8;
  color: rgba(11, 16, 5, 0.751);
}

button.primary {
  background: linear-gradient(145deg, #8dffb3, #35d96c);
  box-shadow: 0 5px 0 #118742;
}

button.danger {
  background: linear-gradient(145deg, #ff9d9d, #ff5858);
  box-shadow: 0 5px 0 #b93232;
}

button.meta {
  background: linear-gradient(145deg, #25d60a, #4e6625);
  box-shadow: 0 5px 0 #1a5508;
}

button.sand {
  background: #e2ca76;
  box-shadow: 0 5px 0 #a89450;
}

button.main-menu {
  background: linear-gradient(145deg, #6b9dff, #4169e1);
  box-shadow: 0 5px 0 #1e40af;
}

button.play-again {
  background: linear-gradient(145deg, #ff9966, #ff7733);
  box-shadow: 0 5px 0 #cc4400;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}

#gameSelector button {
  padding: 0.6em 1.5em;
  font-size: 1.375em;
  border: none;
  border-radius: 8px;
  background: #4e9af1;
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#gameSelector button:hover,
#gameSelector button:focus {
  background: #2566b3;
  transform: translateY(-2px) scale(1.05);
}

#gameSelector button.active {
  background: #f1c40f;
  color: #222;
}

/* Divs ------------------------------------------------------------- */

.landingDiv {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  height: 100vh;
  background: radial-gradient(circle at top, #18283d 0, #05070b 55%);
  color: var(--text);
  font-family: "Monofonto", monospace;
  gap: 1.2rem; /* space between title and selector */
}

.landingDiv h1 {
  margin-top: 5vh;
  margin-bottom: 50px;
  text-align: center;
}

#game {
  display: none;
}

#gameSelector {
  display: flex;
  justify-content: space-around;
  gap: 16px;
  margin-top: 20px;
  margin-bottom: 10px;
}

.center-game-selector-frame {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 0.5em;
}

.game-selector-frame {
  margin-bottom: 0.5em;
  gap: 10px;
  display: inline-block;
  background: rgba(10, 15, 24, 0.95);
  border-radius: 12px;
  border: 3px solid #253044;
  padding: 8px 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  width: auto;
  min-width: 0;
}

.center-game-selector-instructions {
  text-align: center;
  margin-top: 0px;
  font-size: 1.125rem;
  color: #cbdff6;
  opacity: 0.9;
  margin-bottom: 30px;
}

.game-selector-instructions {
  text-align: center;
  margin-top: 0px;
  font-size: 1.125rem;
  color: #cbdff6;
  opacity: 0.9;
}

.frame {
  background: rgba(10, 15, 24, 0.95);
  border-radius: 12px;
  border: 3px solid #253044;
  padding: 5px 5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  width: fit-content; /* Shrink to fit content */
  max-width: 100%; /* Prevent overflow */
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.game-card {
  height: auto;
  width: 300px;
  text-align: center;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s;
}

.game-card:hover {
  transform: scale(1.05);
}

.game-image {
  width: 100%;
  height: auto;
}

.game-title {
  padding: 10px;
  font-weight: bold;
}

/* Titles ------------------------------------------------------------*/

.game-selector-title {
  font-weight: bold;
  font-size: 1.35em;
  margin-bottom: 1em;
  text-align: center;
  letter-spacing: 0.5px;
}

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

.titleBar {
  /*Display stuff*/
  display: flex;
  flex: 1;
  align-items: center;
  /*Typography stuff*/
  font-size: 1.5625rem;
  font-weight: 700;
}

.badge {
  /*Box model stuff*/
  padding: 3px 10px;
  border: 1px solid #3b4b64;
  border-radius: 999px;
  background: #0a0f18;
  /*Typography stuff*/
  font-size: 1.25rem;
  color: #4e6625;
  font-weight: 700;
}

/* Text ------------------------------------------------------------- */

.caption {
  font-size: 1.3125rem;
  line-height: 1.75rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid #27364a;
  padding: 10px;
  margin: 10px;
}

.caption em {
  color: #9fe9ff;
}

.footer {
  margin-top: 10px;
  opacity: 0.8;
  text-align: center;
  font-size: 1.25rem;
}

.pathLog {
  font-size: 1.25rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pathLog.frame {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.timeline-header {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text);
  text-align: left;
  padding-left: 12px;
  margin-bottom: 8px;
}

/* Side-by-side layout refinements within path log */
.pathLog .timeline-header {
  margin: 0; /* override vertical spacing when inline */
  white-space: nowrap;
}

.pathLog .timeline-container {
  flex: 1; /* allow timeline to use remaining space */
}

.timeline-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: flex-start;
  gap: 0px;
  padding: 0px 0;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}

.timeline-dot {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.timeline-line {
  width: 100%;
  height: 10px;
  margin: 14px 0;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  align-self: center;
  background-image: url('data:image/svg+xml;utf8,<svg width="100%" height="20" viewBox="0 0 100 20" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><line x1="0" y1="10" x2="80" y2="10" stroke="%2368f08a" stroke-width="5"/><polygon points="100,10 80,0 80,20" fill="%2368f08a"/></svg>');
  background-repeat: repeat-x;
  background-size: 100% 10px;
}

.timeline-line.filled {
  background-image: url('data:image/svg+xml;utf8,<svg width="100%" height="20" viewBox="0 0 100 20" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg"><line x1="0" y1="10" x2="75" y2="10" stroke="%2368f08a" stroke-width="5"/><polygon points="100,10 80,0 80,20" fill="%2368f08a"/></svg>');
}

.timeline-label {
  font-size: 1rem;
  text-align: center;
  max-width: 140px;
  min-height: 20px;
  line-height: 1.4;
}

/* Responsive: stack header over timeline on small screens */
@media (max-width: 640px) {
  .pathLog {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .pathLog .timeline-container {
    justify-content: center;
  }
}

/* Layout --------------------------------------------------- */

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.imgBox {
  width: 100%;
  max-width: 600px;
  /* max-height: 70vh; */
  /* aspect-ratio: 1/3; */
  display: grid;
  place-items: center;
  background: #050b12;
  border-radius: 8px;
  overflow: hidden;
  margin: 0 auto;
}

img.pixel {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ui {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.choices {
  margin-top: 5px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
/* Username Screen Styles ------------------------------------ */

.usernameDiv {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.username-container {
  background: var(--ui);
  border-radius: 16px;
  padding: 20px 40px 20px 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.username-container h1 {
  margin: 0 0 10px 0;
  font-size: 2.5rem;
  color: var(--accent);
}

.username-subtitle {
  color: var(--text);
  opacity: 0.8;
  margin-bottom: 30px;
  font-size: 1.1rem;
}

.username-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.consent-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.consent-checkbox input[type="checkbox"] {
  width: 40px;
  height: 40px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
  margin: 0;
}

.consent-checkbox label {
  font-size: 0.85rem;
  line-height: 1.2;
  cursor: pointer;
  margin: 0;
  display: flex;
  align-items: center;
  text-align: left;
}

.username-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.username-buttons .username-btn,
.username-buttons .username-btn-skip {
  flex: 1 1 160px;
  text-align: center;
}

#usernameInput {
  padding: 15px 20px;
  border: 2px solid rgba(104, 240, 138, 0.3);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  font-family: "Monofonto", monospace;
  transition: border-color 0.3s ease;
  outline: none;
}

#usernameInput:focus {
  border-color: var(--accent);
}

#usernameInput::placeholder {
  color: rgba(236, 244, 255, 0.4);
}

#emailInput {
  padding: 15px 20px;
  border: 2px solid rgba(104, 240, 138, 0.3);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  font-family: "Monofonto", monospace;
  transition: border-color 0.3s ease;
  outline: none;
}

#emailInput:focus {
  border-color: var(--accent);
}

#emailInput::placeholder {
  color: rgba(236, 244, 255, 0.4);
}

#phoneInput {
  padding: 15px 20px;
  border: 2px solid rgba(104, 240, 138, 0.3);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
  font-family: "Monofonto", monospace;
  transition: border-color 0.3s ease;
  outline: none;
}

#phoneInput:focus {
  border-color: var(--accent);
}

#phoneInput::placeholder {
  color: rgba(236, 244, 255, 0.4);
}

.username-btn {
  background: var(--accent);
  color: var(--bg);
  padding: 15px 30px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-family: "Monofonto", monospace;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.username-btn:hover {
  transform: translateY(-2px);
  background: #7fff9f;
}

.username-btn:active {
  transform: translateY(0);
}

.username-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.username-btn-skip {
  background: transparent;
  color: var(--text);
  padding: 15px 30px;
  font-size: 1rem;
  border-radius: 10px;
  border: 2px solid rgba(236, 244, 255, 0.3);
  cursor: pointer;
  font-weight: 600;
  font-family: "Monofonto", monospace;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.username-btn-skip:hover {
  transform: translateY(-2px);
  border-color: var(--text);
  background: rgba(236, 244, 255, 0.1);
}

.username-btn-skip:active {
  transform: translateY(0);
}

.username-error {
  color: var(--danger);
  margin-top: 10px;
  min-height: 20px;
  font-size: 0.9rem;
}

.field-error {
  display: none;
}

#usernameInput.error {
  border: 2px solid var(--danger) !important;
  background: linear-gradient(
    to right,
    rgba(255, 107, 107, 0.05) 0%,
    rgba(255, 107, 107, 0.05) 100%
  ) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.2) !important;
}

#emailInput.error {
  border: 2px solid var(--danger) !important;
  background: linear-gradient(
    to right,
    rgba(255, 107, 107, 0.05) 0%,
    rgba(255, 107, 107, 0.05) 100%
  ) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.2) !important;
}

#phoneInput.error {
  border: 2px solid var(--danger) !important;
  background: linear-gradient(
    to right,
    rgba(255, 107, 107, 0.05) 0%,
    rgba(255, 107, 107, 0.05) 100%
  ) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.2) !important;
}

#usernameInput.error::placeholder,
#emailInput.error::placeholder,
#phoneInput.error::placeholder {
  color: var(--danger) !important;
  opacity: 1 !important;
}
/* Export Button ----------------------------------------------------- */

.export-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 16px;
  background: var(--accent);
  color: #050b12;
  font-size: 0.9rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.06s ease-in-out,
    filter 0.15s ease-in-out;
  z-index: 1000;
}

.export-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.export-btn:active {
  transform: translateY(0);
}

/* Small Screen Media Queries ---------------------------------- */

@media (max-width: 768px) {
  .landingDiv {
    padding: 20px;
    gap: 0.8rem;
  }

  .landingDiv h1 {
    margin-top: 2vh;
    margin-bottom: 20px;
    font-size: 1.8rem;
  }

  #gameSelector {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
  }

  .game-selector-frame {
    width: 100%;
    max-width: 320px;
  }

  .game-card {
    width: 100%;
    max-width: 280px;
  }

  .center-game-selector-instructions {
    font-size: 1rem;
    margin-bottom: 20px;
  }

  .game-selector-instructions {
    font-size: 1rem;
  }

  .ui {
    padding: 8px;
    gap: 2px;
  }

  .titleRow {
    display: flex;
  }

  .titleBar {
    font-size: 1.15rem;
  }

  .badge {
    font-size: 0.85rem;
    line-height: 0.7rem;
    padding: 6px;
  }

  .caption {
    font-size: 1rem;
    margin: 0px;
    padding: 8px;
    margin: 4px;
    line-height: 1rem;
  }
}

/* Landscape Orientation on Small Screens ---------------------- */

@media (max-width: 1200px) and (orientation: landscape) {
  .landingDiv {
    padding: 10px;
    gap: 0.5rem;
    justify-content: center;
  }

  .landingDiv h1 {
    margin-top: 0.5vh;
    margin-bottom: 10px;
    font-size: 1.4rem;
  }

  #gameSelector {
    flex-direction: row;
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 5px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .game-selector-frame {
    width: auto;
    max-width: none;
    padding: 4px 8px;
  }

  .game-card {
    width: auto;
    max-width: 200px;
  }

  .game-image {
    max-height: 200px;
  }

  .center-game-selector-instructions {
    font-size: 0.9rem;
    margin-bottom: 10px;
  }

  .game-selector-instructions {
    font-size: 0.9rem;
  }
}
