:root {
  --gallery-blue: #006f99;
  --gallery-blue-line: #afd1e6;
  --gallery-white: #fdfdfc;
  --gallery-canvas: #f4f9fc;
  --gallery-paper: #fff3df;
  --gallery-orange: #cb5100;
}

.gallery-page {
  width: min(100%, 560px);
  min-height: 0;
  margin-inline: auto;
  padding: 15px 0 45px;
  container-type: inline-size;
  --gutter: max(16px, 5.5cqw);
}

body:has(.gallery-page:not([hidden])) { background: var(--gallery-white); }
body:has(.bottom-navigation[hidden]) { padding-bottom: env(safe-area-inset-bottom); }
html:has(.bottom-navigation[hidden]) { scroll-padding-bottom: env(safe-area-inset-bottom); }
body:has(.gallery-page:not([hidden])) .header-row {
  width: min(100% - 22px, 538px);
  min-height: 66px;
  gap: 4px;
}
body:has(.gallery-page:not([hidden])) .brand img { width: clamp(116px, 31vw, 148px); }
.gallery-back {
  display: grid;
  flex: 0 0 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.gallery-back::after, .gallery-ticket-stub::after, .gallery-ticket-saved::after {
  content: "";
  width: .45em;
  height: .45em;
  border-top: .12em solid currentColor;
  border-right: .12em solid currentColor;
  transform: rotate(45deg);
}
.gallery-back::after { width: .65em; height: .65em; border-width: .15em; transform: rotate(-135deg); }

.gallery-heading { padding-inline: var(--gutter); padding-bottom: clamp(12px, 3.2cqw, 20px); }
.gallery-heading h1 {
  font-size: clamp(29px, 9.5cqw, 53px);
  font-weight: 900;
  letter-spacing: -.045em;
  line-height: 1.15;
}
.gallery-heading p { margin-top: 8px; font-size: clamp(14px, 4.65cqw, 25px); line-height: 1.42; }
.draw-heading { padding-top: 4px; }
.draw-heading::before {
  content: "";
  display: block;
  width: clamp(42px, 13cqw, 64px);
  height: clamp(7px, 2.35cqw, 11px);
  margin-bottom: clamp(9px, 3.3cqw, 19px);
  border-radius: 20px;
  background: var(--gallery-orange);
}
.draw-heading h1 { font-size: clamp(34px, 10.8cqw, 57px); }
.draw-heading p { color: #303b4f; font-weight: 680; }
#submit-load, #submit-archive, #submit-reload, #draw-alert, #draw-content > .button { margin-inline: var(--gutter); }

.upload-paper { position: relative; }
.upload-art, .gallery-ticket-art { width: 100%; height: auto; display: block; }
.upload-art { aspect-ratio: 853 / 945; }
.upload-camera {
  position: absolute;
  top: 34.2%;
  left: 50%;
  width: 24%;
  height: 17.6%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  transform: translateX(-50%);
}
.upload-camera img { width: 100%; height: 100%; object-fit: contain; }
.button.gallery-pick {
  position: absolute;
  top: 56.1%;
  left: 17.35%;
  width: 65.9%;
  height: 12.5%;
  min-height: 44px;
  padding-inline: 4px;
  border-color: var(--gallery-orange);
  border-radius: clamp(10px, 3.2cqw, 20px);
  background: var(--gallery-orange);
  font-size: clamp(16px, 5.9cqw, 32px);
  font-weight: 850;
}
.gallery-files {
  position: absolute;
  top: 71.9%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: .38em;
  min-height: 44px;
  padding: 0 .25em;
  transform: translateX(-50%);
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--gallery-blue);
  font-size: clamp(14px, 4.7cqw, 24px);
  font-weight: 800;
  white-space: nowrap;
}
.gallery-files img { width: 1.42em; height: 1.42em; object-fit: contain; }
.gallery-files:hover { text-decoration: underline; text-underline-offset: .18em; }
.gallery-limit { padding: 7px var(--gutter) 0; text-align: center; font-size: clamp(13px, 3.75cqw, 19px); }
.gallery-page .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-inline: var(--gutter); }
.gallery-page .stepper li { white-space: nowrap; }
.gallery-page .stepper span { flex: 0 0 auto; }
.gallery-page .stepper li[aria-current="step"] { border-color: var(--gallery-orange); }
.gallery-page .stepper li.complete { border-color: var(--gallery-blue-line); }
.gallery-page .stepper li.complete span { background: var(--gallery-canvas); color: var(--gallery-blue); }
.gallery-form-card {
  margin: 12px var(--gutter) 0;
  border: 1px solid var(--gallery-blue-line);
  border-radius: 14px;
  padding: clamp(12px, 4.5cqw, 24px);
}
.gallery-form-card h2 { margin-bottom: 12px; font-size: clamp(22px, 5.6cqw, 28px); }
#child-heading { display: flex; align-items: center; gap: 8px; }
.gallery-form-card .field select, .gallery-form-card .field input { border-radius: 9px; }
.gallery-form-card .field:last-child { margin-bottom: 0; }
.gallery-form-card .entry-summary { border-color: var(--gallery-blue); background: var(--gallery-canvas); }
.gallery-form-card .choices { gap: 7px; }
.gallery-form-card .choice { padding: 9px; border-radius: 8px; background: var(--gallery-canvas); }
.gallery-form-actions { margin-inline: var(--gutter); }
.gallery-form-actions .primary { min-width: min(56%, 172px); }
.gallery-submit-choices { display: grid; gap: 9px; justify-content: stretch; }
.gallery-submit-choices #previous-step { justify-self: start; }
#entry-alert, :is(#submit-session, #draw-content) > .family-session { margin-inline: var(--gutter); }
.gallery-file-preview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 8px var(--gutter) 0;
  padding: 8px;
  border: 1px solid #f2daba;
  border-radius: 12px;
  background: var(--gallery-paper);
}
.gallery-file-preview small, .gallery-file-preview strong { display: block; }
.gallery-file-preview small { color: var(--muted); }
.gallery-file-preview strong { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.gallery-file-preview .button { min-height: 44px; padding-inline: 9px; font-size: 13px; }
#file-preview-image {
  width: 48px;
  height: 48px;
  border: 1px solid #efd8b7;
  border-radius: 7px;
  object-fit: cover;
}
.gallery-file-preview + .gallery-child-toggle { margin-top: 12px; }
.gallery-page #entry-alert { margin-inline: var(--gutter); }

.draw-panel.gallery-ticket {
  position: relative;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--gallery-paper);
}
.gallery-ticket-art { aspect-ratio: 852 / 764; }
.gallery-ticket-copy { position: absolute; top: 32.1%; left: 10.2%; width: 56%; text-align: center; }
.gallery-ticket-copy > *:not(.visually-hidden) { display: block; margin-inline: auto; }
.gallery-ticket-title { font-size: clamp(15px, 5.7cqw, 32px); line-height: 1.2; font-weight: 850; }
.gallery-ticket-amount {
  color: var(--gallery-orange);
  font: 900 clamp(34px, 19cqw, 105px)/1.05 var(--sans);
  letter-spacing: -.05em;
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}
.gallery-ticket-amount span { font-size: .79em; }
.gallery-ticket-copy .gallery-ticket-saved {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35em;
  min-height: 44px;
  padding: .2em .7em;
  border-radius: 30px;
  font-size: clamp(10px, 3.75cqw, 19px);
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
}
.gallery-ticket-saved::before {
  content: "";
  position: absolute;
  inset: 8px 0;
  z-index: -1;
  border-radius: inherit;
  background: #ffdfaf;
}
.gallery-ticket-saved:hover { text-decoration: underline; text-underline-offset: .12em; }
.gallery-ticket-stub {
  position: absolute;
  top: 28.2%;
  left: 67.6%;
  width: 23%;
  height: 44%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .22em;
  border-radius: 5px 20px 18px 5px;
  color: var(--ink);
  font-size: clamp(12px, 4cqw, 23px);
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}
.gallery-ticket-stub:hover { text-decoration: underline; text-underline-offset: .2em; }
.gallery-ticket-stub:focus-visible { outline-offset: -4px; }
.gallery-poster-card {
  display: grid;
  grid-template-columns: 44% minmax(0, 1fr);
  align-items: center;
  gap: clamp(8px, 3.5cqw, 20px);
  margin: clamp(19px, 6.2cqw, 34px) max(9px, 2.4cqw) 0;
  padding: clamp(11px, 4.2cqw, 24px) clamp(6px, 2.6cqw, 17px);
  border: 1px solid #f3e0c4;
  border-radius: clamp(12px, 3.2cqw, 18px);
  background: var(--gallery-paper);
  box-shadow: 0 6px 13px #8b553319;
}
.gallery-poster-photo {
  margin: 5% 4% 5% 2%;
  aspect-ratio: 1.05;
  overflow: hidden;
  transform: rotate(-6deg);
  border: clamp(4px, 1.6cqw, 8px) solid #fffcf6;
  background: var(--gallery-canvas);
  box-shadow: 0 7px 12px #75422040;
}
.gallery-poster-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 49% center; }
.gallery-poster-card h2 { font-size: clamp(16px, 6.25cqw, 33px); font-weight: 890; letter-spacing: -.035em; }
.gallery-poster-card p { margin: .4em 0 .65em; color: #3e495b; font-size: clamp(12px, 3.8cqw, 19px); line-height: 1.42; }
.gallery-poster-card .button {
  justify-content: space-between;
  gap: 3px;
  width: 100%;
  min-height: 44px;
  padding-inline: clamp(4px, 2.5cqw, 15px);
  border-radius: clamp(8px, 2.5cqw, 14px);
  font-size: clamp(13px, 4.6cqw, 25px);
  font-weight: 850;
}
.archive-heading {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column;
  gap: 0;
  min-height: clamp(135px, 30vw, 265px);
  margin-bottom: 16px;
  padding: clamp(15px, 4vw, 48px);
  border-radius: 16px;
  background: var(--gallery-paper) url('/assets/gallery-album.jpg') 57% center / cover no-repeat;
}
.archive-heading h1 { font-size: clamp(30px, 7.5vw, 59px); font-weight: 900; letter-spacing: -.045em; }
.archive-heading p { width: 48%; color: #303b4f; font-size: clamp(12px, 3.1vw, 17px); line-height: 1.42; }
#archive-add, #archive-logout { margin-bottom: 16px; }
#archive-add:not([hidden]) + #archive-logout { margin-left: 8px; }
.family-session { padding: clamp(16px, 5vw, 26px); border: 1px solid var(--gallery-blue-line); border-radius: 16px; background: var(--gallery-canvas); }
.family-session p { margin-top: 8px; color: var(--muted); }
.family-session .button { margin-top: 14px; }
.entry-benefits { margin-bottom: 16px; }
.entry-benefits .credit-grid { margin: 8px 0 0; }
:is(#archive-view, #rules-view, #center-view, #story-view) .back-link { color: var(--gallery-blue); }
:is(.child-card, .empty) { border-color: var(--gallery-blue-line); border-radius: 16px; }
#archive-view:has(.upload-receipt) { width: min(calc(100% - 28px), 448px); padding-top: 0; }
#archive-view:has(.upload-receipt) > .back-link { margin: 0; min-height: 40px; }
#archive-receipt:not(:empty) { min-height: calc(100svh - 158px); margin-bottom: 22px; }
.upload-receipt { border: 1px solid #d6e5eb; border-radius: 20px; background: #fff; overflow: hidden; }
.receipt-exhibit { width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; object-position: center 68%; }
.receipt-paper { padding: clamp(16px, 5vw, 24px); }
.receipt-heading { display: flex; align-items: center; gap: 9px; }
.receipt-heading h2 { color: var(--ink); font-size: clamp(26px, 7.4vw, 35px); font-weight: 850; letter-spacing: -.045em; }
.receipt-check { display: grid; flex: 0 0 23px; height: 23px; place-items: center; border-radius: 50%; background: #ddf4f5; }
.receipt-check::after { content: ""; width: 9px; height: 5px; border: solid #096e79; border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.receipt-work { margin-top: 4px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.receipt-benefit {
  display: flex; align-items: stretch; gap: 12px; margin-top: 17px; border-block: 1px solid #f5dfbc; border-radius: 12px;
  padding: 12px 14px; color: #51351d; background: #fff4e3;
}
.receipt-benefit-body { flex: 1; align-self: center; min-width: 0; }
.receipt-benefit h3 { font-size: 16px; font-weight: 750; }
.receipt-benefit p { margin-top: 5px; color: #71523b; font-size: 13px; line-height: 1.5; }
.receipt-value { display: flex; align-items: baseline; align-self: center; gap: 2px; padding-left: 13px; border-left: 1px dashed #dfbd89; color: #af4807; font: 750 clamp(32px, 9vw, 44px)/1.25 var(--sans); font-variant-numeric: tabular-nums; }
.receipt-value small { font-size: .5em; }
.receipt-next { margin-top: 16px; }
.receipt-next p { margin-bottom: 7px; color: #334657; font-size: 14px; }
.receipt-next .button.primary { width: 100%; min-height: 46px; border-radius: 12px; background: #bd4802; border-color: #bd4802; font-size: 17px; }
.receipt-next .button.primary:hover { background: var(--accent-deep); }
.receipt-poster-link {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 57px; margin-top: 14px;
  padding: 7px 13px; border: 0; border-radius: 11px; background: #eff7fa; color: #15546b; font-weight: 700; text-align: left;
}
.receipt-preview { width: 31px; height: 40px; object-fit: cover; background: white; border: 2px solid white; box-shadow: 0 1px 4px #254d602f; transform: rotate(-4deg); }
.receipt-preview.generated-poster { object-fit: contain; }
.receipt-poster-link::after { content: ""; margin-left: auto; margin-right: 2px; width: 7px; height: 7px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }
.receipt-archive-link { display: flex; width: fit-content; align-items: center; margin: 4px auto -8px; min-height: 44px; padding: 6px 14px; color: var(--gallery-blue); font-size: 14px; font-weight: 650; text-decoration: none; }
.empty, .credit-grid, .consent-edit { background: var(--gallery-canvas); }
.credit-grid { border-radius: 12px; }
.entry-status { border-radius: 18px; }
.entry-row { padding-top: 15px; }
.entry-actions > a { color: var(--gallery-blue); }
.draw-panel:not(.gallery-ticket) { align-items: center; border-radius: 13px; background: var(--gallery-paper); }
.draw-panel .draw-result strong { color: var(--gallery-orange); }
.draw-panel .button { color: var(--ink); }
.draw-panel .button.primary { color: #fff; }
.reading .page-intro, #center-view .page-intro { background: var(--gallery-canvas); }
.poster-stage { background: var(--gallery-paper); }

.guide { width: min(100% - 28px, 620px); padding-top: 0; }
.rules-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}
.rules-tabs a {
  padding-inline: 3px;
  border-color: #c6e1ef;
  border-radius: 8px;
  background: var(--gallery-canvas);
  text-align: center;
}
.rules-tabs a[aria-current="location"] { border-color: var(--blue); background: var(--blue); color: var(--white); }
@media (max-width: 350px) {
  .rules-tabs a { font-size: 12px; }
}
.rules-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: clamp(11px, 3.15vw, 20px);
  border: 1px solid #c6e1ef;
  border-radius: 14px;
  background: linear-gradient(135deg, #f3f9fd, #e2f4fc);
}
.rules-banner h2 {
  font-size: clamp(24px, 6.4vw, 38px);
  font-weight: 850;
  letter-spacing: -.025em;
}
.rules-banner h2::before {
  display: block;
  content: "";
  width: 25px;
  height: 3px;
  margin-bottom: 5px;
  border-radius: 3px;
  background: var(--orange);
}
.rules-banner .rules-summary { margin-top: 4px; }
.rules-art { width: clamp(70px, 23vw, 128px); height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 9px; }
.rules-card {
  margin-top: 10px;
  padding: clamp(11px, 3.35vw, 21px);
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--white);
}
.rules-card h3 { margin-bottom: 5px; font-size: clamp(17px, 4.65vw, 21px); }
.rules-card h4 { margin: 9px 0 5px; font-size: 15px; }
.guide-panel p, .guide-panel dd { font-size: max(14px, .94em); line-height: 1.55; color: var(--muted); }
.rules-card p + p { margin-top: 6px; }
.rules-card .rules-action { display: flex; width: 100%; margin-top: 10px; }

.guide-steps { margin: 0; padding: 0; list-style: none; counter-reset: guide-step; }
.guide-steps li {
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  counter-increment: guide-step;
}
.guide-steps li + li { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.guide-steps li::before {
  content: counter(guide-step);
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #e7f4fc;
  color: var(--gallery-blue);
  font-size: 13px;
  font-weight: 780;
}
.guide-steps strong { display: block; line-height: 1.35; margin-bottom: 2px; }

.guide-categories, .guide-milestones { margin: 5px 0 0; }
.guide-categories > div, .guide-milestones > div { border-top: 1px solid var(--border); padding-block: 7px; }
.guide-categories > div:last-child, .guide-milestones > div:last-child { padding-bottom: 0; }
.guide-categories dt { display: flex; justify-content: space-between; gap: 6px; font-weight: 750; }
.guide-categories dt span { color: var(--accent-deep); white-space: nowrap; }
.guide-categories dd, .guide-milestones dd { margin: 2px 0 0; }
.guide-milestones dt { font-weight: 750; }
.guide-milestones dd p { margin-top: 4px; }
.guide-panel .guide-draw-status { margin-top: 8px; color: var(--gallery-blue); font-weight: 700; }
.guide-prizes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.guide-prizes li, .guide-panel .rules-award { border-radius: 8px; background: #fff4e6; padding: 6px 8px; }
.guide-prizes li { display: grid; place-items: center; }
.guide-prizes strong, .rules-award strong { color: var(--accent-deep); font-size: 20px; font-variant-numeric: tabular-nums; }
.guide-prizes small, .rules-award span { font-size: 13px; }
.guide-panel .rules-award { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; color: var(--ink); }
.rules-ticket-heading, .from-ticket .rules-draw-heading { display: none; }
.from-ticket .rules-ticket-heading { display: revert; }
.rules-articles { margin-top: 10px; }
.rules-articles a { border-radius: 8px; }

.poster-stage { padding: clamp(9px, 2.8vw, 16px); border: 1px solid #f0dfc2; }
.poster-stage #poster-image { border-radius: 5px; }

@media (max-width: 365px) {
  .gallery-page .stepper { gap: 5px; }
  .gallery-page .stepper li { gap: 4px; font-size: 12px; }
  .gallery-page .stepper span { width: 20px; height: 20px; }
  .gallery-poster-card h2 { font-size: 5.8cqw; }
}

@media (min-width: 720px) {
  .gallery-page { width: clamp(455px, 50dvh, 560px); }
  body:has(.gallery-page:not([hidden])) .header-row { width: calc(clamp(455px, 50dvh, 560px) - 22px); }
}
