* {
  box-sizing: border-box;
}

:root {
  --gryffindor-dark-red: #740001;
  --gryffindor-red: #ae0001;
  --gryffindor-yellow: #eeba30;
  --gryffindor-gold: #d3a625;
  --ink: #351000;
  --shadow: rgba(48, 0, 0, 0.42);
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  background:
    radial-gradient(circle at 50% 35%, rgba(174, 0, 1, 0.56), transparent 52%),
    var(--gryffindor-dark-red);
}

button,
a {
  font: inherit;
}

.page-shell {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  padding: clamp(28px, 6vw, 64px) 24px 120px;
}

#greeting {
  position: relative;
  z-index: 30;
  width: fit-content;
  max-width: calc(100vw - 40px);
  margin: 0 auto;
  padding: 14px 24px 16px;
  text-align: center;
  color: var(--ink);
  background: var(--gryffindor-yellow);
  border: 2px solid var(--ink);
  border-radius: 5px;
  box-shadow: 6px 6px 0 var(--shadow);
  font-size: clamp(2rem, 5.6vw, 4.4rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
  transition: opacity 280ms ease, transform 280ms ease, visibility 0s linear 280ms;
}

body.games-open #greeting {
  opacity: 0;
  transform: translateY(-18px);
  visibility: hidden;
}

.animal-field {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.animal {
  position: absolute;
  left: 0;
  top: 0;
  width: clamp(48px, 6vw, 92px);
  max-height: 105px;
  object-fit: contain;
  filter: drop-shadow(3px 4px 2px rgba(0, 0, 0, 0.18));
  transform-origin: center;
  will-change: transform, opacity;
  transition: opacity 180ms ease;
}

.games-panel {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 24px;
  width: min(320px, calc(100vw - 36px));
  min-height: 50px;
  transform: translateX(-50%);
  overflow: hidden;
  color: var(--ink);
  background: var(--gryffindor-yellow);
  border: 2px solid var(--ink);
  border-radius: 5px;
  box-shadow: 6px 6px 0 var(--shadow);
  transition:
    width 430ms cubic-bezier(.2,.8,.2,1),
    min-height 430ms cubic-bezier(.2,.8,.2,1),
    bottom 430ms cubic-bezier(.2,.8,.2,1),
    padding 430ms cubic-bezier(.2,.8,.2,1),
    background-color 220ms ease;
}

.games-panel.open {
  width: min(570px, calc(100vw - 34px));
  min-height: min(510px, calc(100vh - 90px));
  bottom: max(22px, calc((100vh - min(510px, calc(100vh - 90px))) / 2));
  padding: 18px 22px 20px;
  background: var(--gryffindor-yellow);
}

.games-toggle {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  cursor: pointer;
  font-weight: 700;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  letter-spacing: 0.01em;
}

.games-panel.open .games-toggle {
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  text-decoration: none;
  cursor: default;
}

.games-content {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition:
    max-height 360ms ease,
    opacity 240ms ease 80ms,
    transform 320ms ease 70ms,
    visibility 0s linear 360ms;
}

.games-panel.open .games-content {
  max-height: 420px;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition:
    max-height 420ms ease 70ms,
    opacity 260ms ease 115ms,
    transform 320ms ease 95ms,
    visibility 0s;
}

.game-links {
  display: grid;
  gap: 11px;
  margin-top: 8px;
}

.game-links a {
  display: block;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(255, 241, 179, 0.62);
  border: 1px solid rgba(53, 16, 0, 0.48);
  border-radius: 3px;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  transition: transform 120ms ease, opacity 180ms ease, background-color 120ms ease;
}

.game-links a:hover {
  transform: translateY(-1px);
  background: rgba(255, 244, 196, 0.92);
}

.game-links a.played-today {
  opacity: 0.30;
}

.game-links a.played-today:hover {
  opacity: 0.45;
}

.back-button {
  display: block;
  margin: 20px auto 0;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

#confettiCanvas {
  position: fixed;
  z-index: 100;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (max-width: 700px) {
  .animal {
    width: clamp(42px, 12vw, 72px);
  }

  .games-panel.open {
    min-height: min(500px, calc(100vh - 70px));
  }
}

@media (prefers-reduced-motion: reduce) {
  #greeting,
  .animal,
  .games-panel,
  .games-content {
    transition: none;
  }
}
