/* Reset & base */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #111;
  color: #FFF;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow: hidden;
  /* prevent scroll, games occupy the viewport */
}

/* Canvas fills the viewport */
#game {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#game:focus {
  outline: none;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Overlays (Start, Game Over, Loading) */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(0, 0, 0, 0.6);
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(0, 0, 0, 1);
}

.screen .screen-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* Titles with overlapping outline/fill */
.title {
  margin: 0;
  position: relative;
  display: inline-block;
  line-height: 100%;
}

.title .title-outline,
.title .title-fill {
  display: block;
  font-weight: 950;
  letter-spacing: .5px;
  font-size: clamp(40px, 10vw, 80px);
  line-height: 100%;
  font-family: system-ui, Segoe UI, Roboto, Arial, sans-serif;
}

.title .title-outline {
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke-width: 6px;
  -webkit-text-stroke-color: #000;
  text-shadow: none;
  z-index: 0;
}

.title .title-fill {
  position: relative;
  color: #FFF;
  text-shadow: 0 4px 0 #000;
  z-index: 1;
}

/* Buttons */
.btn {
  cursor: pointer;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 950;
  font-size: clamp(24px, 6vw, 35px);
  line-height: 100%;
}

.btn.primary {
  min-width: 220px;
  border-radius: 8px;
  border: 2px solid #E04646;
  background: #FF6262;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.25);
  color: #FFF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Loading */
.loading-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(420px, 80vw);
}

.loading-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .15);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .3);
}

.loading-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #3b82f6);
  transition: width .2s ease;
}

.loading-text {
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}

/* Start screen customizer */
.customizer {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(0, 0, 0, .45);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25);
  border-radius: 16px;
  padding: 12px 14px;
}

.arrow-btn {
  appearance: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, .5);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 22px;
  line-height: 32px;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.avatar-list {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  /* don't shrink; honor computed width */
  min-width: 0;
  /* allow viewport to be narrower than content so horizontal scroll can clip */
  /* width = min(300px, viewport - paddings/border, intrinsic content width) */
  width: min(300px, calc(100vw - 28px), max-content);
  /* horizontal scroll area; hide native scrollbar cross-browser */
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  user-select: none;
  overscroll-behavior-inline: contain;
  overflow-clip-margin: content-box;
  scroll-snap-type: none;
  -ms-overflow-style: none;
  /* IE/Edge */
  scrollbar-width: none;
  /* Firefox */
}

.avatar-list::-webkit-scrollbar {
  display: none;
}

.avatar {
  position: relative;
  width: 56px;
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(0, 0, 0, .6);
  background: rgba(255, 255, 255, 0.18);
  padding: 0;
  scroll-snap-align: center;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
}

.avatar.selected {
  box-shadow: 0 0 0 3px #fff inset, 0 0 0 4px rgba(0, 0, 0, .7);
  border-color: #fff;
}

.avatar.selected::after {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 10px solid #fff;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .6));
}

.name-and-play {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  width: min(560px, 90vw);
  flex-wrap: nowrap;
}

.name-and-play .btn.primary {
  height: 56px;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: auto;
  /* override global min-width to allow side-by-side on small widths */
  flex: 0 0 auto;
  white-space: nowrap;
}

.name-input {
  flex: 1 1 auto;
  min-width: 0;
  /* allow flexbox to shrink input so it fits alongside the button */
  height: 56px;
  border-radius: 12px;
  border: 2px solid rgba(0, 0, 0, .5);
  background: rgba(255, 255, 255, 0.14);
  color: #FF6262;
  padding: 0 16px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  -webkit-text-stroke-width: 2px;
  -webkit-text-stroke-color: #000;
  font-family: 'AvenirNextWorld-Bold', 'Avenir Next World', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 52px;
  font-style: normal;
  font-weight: 950;
  line-height: 100%;
  /* 52px */
  outline: none;
}

.name-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 520px) {
  .name-and-play {
    flex-direction: row;
    /* keep side-by-side even on small screens */
    width: min(420px, 92vw);
  }

  .btn.primary {
    width: auto;
    /* don't force full width on small screens */
  }
}

/* Avenir Next World font faces (same approach as slot-machine) */
@font-face {
  font-family: 'AvenirNextWorld-Medium';
  src: url('https://firebasestorage.googleapis.com/v0/b/sticky-20bca.appspot.com/o/fonts%2FAvenirNextWorld-Medium.otf?alt=media&token=6d0c0700-529c-45a3-bfd7-dc79b07030cd') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AvenirNextWorld-Bold';
  src: url('https://firebasestorage.googleapis.com/v0/b/sticky-20bca.appspot.com/o/fonts%2FAvenirNextWorld-Bold.otf?alt=media&token=8d06a955-d494-4533-b00f-f419be3a1781') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
