body {
  margin: 0;
  min-height: 100vh;
  background: #151a2a;
  color: #fff;
  font-family: Georgia, serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  width: min(90vw, 760px);
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
}

#game[hidden] {
  display: none;
}

#presentsArea {
  flex: 1;
  min-height: 0;
  container-type: size;
}

#home {
  width: min(90vw, 640px);
  text-align: center;
}

#home h1 {
  margin: 0 0 6px;
  color: #ffcf6e;
  font-size: clamp(1.8rem, 7vh, 3.2rem);
}

#homePresent {
  display: block;
  margin: 0 auto 6px;
  width: min(40vw, 24vh);
  aspect-ratio: 1;
  object-fit: contain;
}

#home {
  position: relative;
  z-index: 1;
}

#homeCharacters {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

#homeCharacters img {
  position: absolute;
  width: min(18vw, 18vh);
  aspect-ratio: 1;
  object-fit: contain;
  transform: translate(-50%, -50%);
  animation: float 5s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translate(-50%, -50%) rotate(-6deg); }
  50% { transform: translate(-50%, calc(-50% - 3vh)) rotate(6deg); }
}

#mode {
  width: min(90vw, 460px);
  text-align: center;
}

#mode h2 {
  margin: 0 0 18px;
  color: #ffcf6e;
  font-size: 1.8rem;
}

#credits {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 8px;
  margin: 0;
  padding: 0 12px;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #8f98b3;
}

#credits a {
  color: #b9c2e0;
}

#homeButtons, #modeButtons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

#play, #playFriend, #playBot {
  padding: 12px 22px;
  font: inherit;
  font-size: 1.1rem;
  color: #fff;
  background: #b3202a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#play {
  padding: 12px 40px;
  font-size: 1.3rem;
}

#warning {
  width: min(90vw, 460px);
  text-align: center;
  line-height: 1.5;
}

#warning[hidden] {
  display: none;
}

#warning h1 {
  color: #ff6b6b;
  font-size: 2rem;
  margin: 0 0 12px;
}

#warning p {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

#warningContinue {
  margin-top: 8px;
  padding: 12px 26px;
  font: inherit;
  font-size: 1.05rem;
  color: #fff;
  background: #b3202a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#select {
  width: min(90vw, 760px, calc((100vh - 110px) * 1.5));
  text-align: center;
}

#selectTitle {
  font-size: 1.4rem;
  margin: 0 0 16px;
}

#characters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); /* equal columns, even with a long name like Gingerbread Man */
  gap: 12px;
}

.character {
  background: none;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 4px;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.character:hover {
  border-color: #ffcf6e;
}

.character img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}

#nameScreen {
  width: min(90vw, 360px);
  text-align: center;
}

#namePic {
  width: 55%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

#nameTitle {
  font-size: 1.4rem;
  margin: 0 0 14px;
}

#nameInput {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font: inherit;
  font-size: 1.2rem;
  text-align: center;
  color: #fff;
  background: #0d1120;
  border: 2px solid #3a4468;
  border-radius: 8px;
  margin-bottom: 14px;
}

#nameInput:focus {
  outline: none;
  border-color: #ffcf6e;
}

#nameContinue {
  padding: 10px 26px;
  font: inherit;
  font-size: 1.05rem;
  color: #fff;
  background: #b3202a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#nameContinue:disabled {
  opacity: 0.4;
  cursor: default;
}

#wheelScreen {
  width: min(90vw, 460px);
  text-align: center;
}

#wheelTitle {
  font-size: 1.3rem;
  margin: 0 0 14px;
}

#wheelBox {
  position: relative;
  width: min(80vw, 420px, calc(100vh - 300px));
  margin: 0 auto 12px;
}

#wheel {
  width: 100%;
  display: block;
  border-radius: 50%;
}

#pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 30px solid #ffcf6e;
  filter: drop-shadow(0 2px 3px #000);
}

#wheelLegend {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

#wheelResult {
  min-height: 1.6em;
  margin: 10px 0;
  font-size: 1.3rem;
  color: #ffcf6e;
}

#spin, #startSuddenDeath {
  padding: 10px 26px;
  font: inherit;
  font-size: 1.05rem;
  color: #fff;
  background: #b3202a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#spin:disabled {
  opacity: 0.4;
  cursor: default;
}

#startSuddenDeath[hidden] {
  display: none;
}

#score {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 0 0 6px;
  font-size: 1.1rem;
}

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

.scoreItem img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

#turn {
  margin: 0 0 6px;
  text-align: center;
  font-size: 1.1rem;
}

#turn {
  color: #ffcf6e;
}

#message {
  min-height: 2.8em;
  margin: 0 0 8px;
  text-align: center;
  font-size: 1.1rem;
}

#homeButton,
#mute {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

#homeButton {
  right: auto;
  left: 8px;
}

#homeButton[hidden] {
  display: none;
}

@media (max-width: 700px) {
  #game {
    padding-top: 52px;
  }
}

#scare {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #3a0000;
  overflow: hidden;
  animation: shake 0.25s infinite;
}

#scare[hidden] {
  display: none;
}

#scare img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#scare::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #ff0000;
  mix-blend-mode: multiply;
  animation: flash 0.5s infinite alternate; /* one flash a second, well under the 3 a second seizure limit */
}

@keyframes shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-6px, 4px); }
  50% { transform: translate(5px, -5px); }
  75% { transform: translate(-4px, -3px); }
  100% { transform: translate(6px, 5px); }
}

@keyframes flash {
  from { opacity: 0.15; }
  to { opacity: 0.4; }
}

/* people who ask their device for less motion get a still red picture */
@media (prefers-reduced-motion: reduce) {
  #homeCharacters img,
  #scare,
  #scare::after,
  #result,
  #resultCard,
  .present .inside {
    animation: none;
  }

  #scare::after {
    opacity: 0.3;
  }
}

/* round and game result pop-up; under the home and mute buttons so they still work */
#result {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 12px 12px;
  box-sizing: border-box;
  background: rgba(8, 10, 20, 0.7);
  animation: resultFade 0.25s ease-out;
}

#result[hidden] {
  display: none;
}

#resultCard {
  width: min(100%, 520px);
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 20px 18px 18px;
  text-align: center;
  background: #1f2640;
  border: 2px solid #ffcf6e;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: resultPop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

#resultTitle {
  margin: 0 0 6px;
  color: #ffcf6e;
  font-size: 1.6rem;
}

#resultText {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

#resultPlayers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.resultPlayer {
  padding: 10px 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: 12px;
}

.resultPlayer.winner {
  border-color: #ffcf6e;
  background: rgba(255, 207, 110, 0.12);
}

.resultPlayer img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.resultPlayer p {
  margin: 4px 0;
}

.resultName {
  font-weight: bold;
  overflow-wrap: anywhere;
}

.resultPoints {
  font-size: 0.9rem;
  color: #ffcf6e;
}

.resultLabel {
  font-size: 0.8rem;
  color: #b9bfd3;
}

.prizeList {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
  font-size: 1.15rem;
  color: #b9bfd3;
}

.prizeList:not(:has(.prizeChip)) {
  font-size: 0.85rem;
}

.prizeChip {
  white-space: nowrap;
  color: #fff;
}

.prizeChip.rare {
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(120, 200, 255, 0.2);
  box-shadow: 0 0 10px rgba(120, 200, 255, 0.6);
}

#resultButton {
  padding: 10px 26px;
  font: inherit;
  font-size: 1.1rem;
  color: #fff;
  background: #b3202a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#resultButton:focus-visible {
  outline: 3px solid #ffcf6e;
  outline-offset: 2px;
}

@keyframes resultFade {
  from { opacity: 0; }
}

@keyframes resultPop {
  from { transform: scale(0.85); opacity: 0; }
}

#presents {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 8px;
  width: min(100cqw, 100cqh);
  aspect-ratio: 1;
  margin: 0 auto;
}

.present {
  position: relative;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* an opened present shows what was inside instead of the box */
.present.opened img {
  visibility: hidden;
}

.present .inside {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(13cqmin, 4.5rem);
  color: #fff; /* a disabled button's see-through text color would fade the emoji */
  animation: insidePop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.present .inside.rare {
  filter: drop-shadow(0 0 10px rgba(120, 200, 255, 0.9));
  animation: insidePop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1), sparkle 1.2s ease-in-out 0.35s infinite;
}

@keyframes insidePop {
  from { transform: scale(0.2); opacity: 0; }
}

@keyframes sparkle {
  50% { transform: scale(1.15); }
}

.present img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
}
