:root {
  --page: #d8f0df;
  --ink: #17372b;
  --accent: #ff675f;
  --surface: #fffdf7;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Trebuchet MS", Arial, sans-serif;
  transition: background-color 400ms ease, color 400ms ease;
}

button, input { font: inherit; }

main {
  width: min(100% - 48px, 1080px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 38px 0;
  display: grid;
  grid-template-columns: minmax(360px, 1.18fr) minmax(310px, .82fr);
  align-items: center;
  column-gap: clamp(38px, 7vw, 94px);
}

.photo-frame {
  width: 100%;
  max-width: 540px;
  margin: 0;
  justify-self: center;
}

.photo-button {
  width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 0;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  background: #b8d5c1;
  cursor: pointer;
}

.photo-button:focus-visible { outline: 5px solid var(--accent); outline-offset: 5px; }
.photo-button img { display: block; width: 100%; height: 100%; object-fit: contain; transition: opacity 150ms ease; }
.photo-button.changing img { opacity: 0; }

.photo-count {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .03em;
}

.choice-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(30px, 7vh, 68px);
  padding: 0;
}

h1 {
  min-height: 1.18em;
  margin: 0;
  overflow: hidden;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(54px, 6vw, 86px);
  line-height: 1.08;
  letter-spacing: -.075em;
  overflow-wrap: normal;
  white-space: nowrap;
}

h1 span { display: block; padding-right: .08em; }
h1 span.slide { animation: name-up 350ms cubic-bezier(.2,.75,.25,1) both; }
h1:focus-visible { outline: 4px solid var(--accent); outline-offset: 5px; }

@keyframes name-up {
  from { transform: translateY(65%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.reactions {
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 3px solid var(--ink);
}

.reactions label {
  position: relative;
  min-height: 88px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 3px solid var(--ink);
  cursor: pointer;
  transition: padding 150ms ease, background-color 150ms ease;
}

.reactions label:hover { padding-left: 20px; background: rgba(255,255,255,.35); }
.reactions label:has(input:checked) { background: var(--surface); padding-left: 20px; }
.reactions input { position: absolute; opacity: 0; pointer-events: none; }
.reactions label:has(input:focus-visible) { outline: 4px solid var(--accent); outline-offset: -4px; }
.emoji { font-size: 42px; }
.reactions small { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.share-button {
  align-self: flex-start;
  margin-top: 22px;
  padding: 10px 15px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--surface);
  color: inherit;
  font-weight: 700;
  cursor: pointer;
}

.share-button:hover { background: var(--accent); }
.share-button:focus-visible { outline: 4px solid var(--accent); outline-offset: 4px; }
.share-message { min-height: 1.2em; margin: -10px 0 0; font-size: 14px; font-weight: 700; }
.share-menu { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -16px; }
.share-menu[hidden] { display: none; }
.share-menu a { padding: 7px 10px; border: 2px solid var(--ink); border-radius: 999px; color: inherit; font-size: 13px; font-weight: 700; text-decoration: none; }
.share-menu a:hover,.share-menu a:focus-visible { background: var(--accent); }

#emoji-layer { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.flying-emoji { position: absolute; left: var(--x); bottom: -60px; font-size: var(--size); animation: fly var(--speed) cubic-bezier(.16,.7,.24,1) forwards; }
@keyframes fly {
  0% { transform: translate(0,0) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translate(var(--drift),-115vh) rotate(var(--turn)); opacity: 0; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 780px) {
  main {
    width: min(100% - 28px, 520px);
    min-height: 100svh;
    padding: max(18px, env(safe-area-inset-top)) 0 max(18px, env(safe-area-inset-bottom));
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .photo-button { min-height: 0; max-height: none; }
  .photo-frame { max-width: 520px; }
  .photo-count { margin-top: 8px; }
  .choice-panel { gap: 18px; }
  h1 { min-height: 1.14em; font-size: clamp(49px, 15vw, 74px); }
  .reactions { display: grid; grid-template-columns: repeat(4, 1fr); border: 3px solid var(--ink); }
  .reactions label { min-height: 68px; display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 5px 2px; border: 0; border-right: 3px solid var(--ink); }
  .reactions label:last-child { border-right: 0; }
  .reactions label:hover,.reactions label:has(input:checked) { padding: 5px 2px; }
  .emoji { font-size: clamp(26px, 8vw, 36px); }
  .reactions small { font-size: 11px; }
  .share-button { align-self: stretch; margin-top: 0; }
  .share-message { margin: -8px 0 0; text-align: center; }
  .share-menu { justify-content: center; margin-top: -10px; }
}

@media (max-height: 630px) and (max-width: 780px) {
  h1 { font-size: 42px; }
  .reactions label { min-height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  body, .photo-button img, .reactions label { transition: none; }
  h1 span.slide { animation: none; }
  .flying-emoji { display: none; }
}
