.gi-room {
  --emerald: #0B6B4C;
  --red: #B5121B;
  --ivory: #F3EFE4;
  --cream: #F4EBD3;
  --soft: rgba(244, 235, 211, .72);
  --gold: #D9B65A;
  --hair: rgba(217, 182, 90, .85);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 72px 16px 32px;
  background: radial-gradient(70% 60% at 50% 45%, rgba(40, 26, 20, .9), rgba(6, 4, 3, .96));
}
.gi-room > * { flex: none; }
.gi-room::before, .gi-room::after { content: ''; flex: 1 1 0; }

.gi-stage { position: relative; display: grid; place-items: center; width: min(640px, 100%); }
.gi-stage > * { grid-area: 1 / 1; }

.gi-env {
  --w: min(520px, 88vw);
  position: relative;
  width: var(--w);
  height: calc(var(--w) * .66);
  margin-top: calc(var(--w) * .66 * .31);
  perspective: 1400px;
  filter: drop-shadow(0 22px 30px rgba(0, 0, 0, .5)) drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
  animation: gi-arrive .8s cubic-bezier(.2, .9, .3, 1) both;
  transition: transform .7s cubic-bezier(.5, 0, .7, .4), opacity .6s;
}
@keyframes gi-arrive {
  from { opacity: 0; transform: translateY(60px) rotate(-6deg); }
  60% { opacity: 1; }
}
.gi-paper {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .33 0 0 0 0 .22 0 0 0 .4 -.12'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23p)'/%3E%3C/svg%3E"),
    var(--ivory);
}

.gi-env-back {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 4px;
  box-shadow: inset 0 3px 0 var(--red);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .09' numOctaves='3' seed='8' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 -.32'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23t)'/%3E%3C/svg%3E"), linear-gradient(180deg, #8E0D14, var(--red) 40%);
}

.gi-env-front {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 4px;
  box-shadow: inset 0 0 0 3px var(--red);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.gi-env-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top right, transparent 49.6%, rgba(80, 60, 30, .14) 50%, transparent 50.6%),
    linear-gradient(to top left, transparent 49.6%, rgba(80, 60, 30, .14) 50%, transparent 50.6%);
}

.gi-env-flap {
  position: absolute;
  inset: 0 0 auto;
  height: 62%;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.4, .1, .25, 1);
  z-index: 3;
}
.gi-flap-face {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.gi-flap-out {
  background-color: var(--red);
  box-shadow: inset 0 -12px 18px -12px rgba(80, 60, 30, .18);
}
.gi-flap-out::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, .25), transparent 40%, rgba(80, 60, 30, .12));
}

.gi-flap-in {
  transform: rotateX(180deg);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: #EDE7D6;
}
.gi-flap-in::before {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 12%, 93% 95%, 7% 95%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='t'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .09' numOctaves='3' seed='8' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .25 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 -.32'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23t)'/%3E%3C/svg%3E"), linear-gradient(0deg, #9A0F17, var(--red) 70%);
}

.gi-flap-out::before {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(.8% 3px, 99.2% 3px, 50% calc(100% - 4.5px));
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .33 0 0 0 0 .22 0 0 0 .4 -.12'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23p)'/%3E%3C/svg%3E"),
    var(--ivory);
}
.gi-env.open .gi-env-flap {
  transform: rotateX(180deg);
  z-index: 0;
  transition: transform .75s cubic-bezier(.4, .1, .25, 1), z-index 0s .35s;
}

.gi-seal {
  position: absolute;
  left: 50%;
  top: 62%;
  z-index: 4;
  display: grid;
  place-items: center;
  width: calc(var(--w) * .2);
  aspect-ratio: 249 / 260;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  filter: drop-shadow(0 3px 3px rgba(60, 10, 10, .35)) drop-shadow(0 1px 1px rgba(0, 0, 0, .3));
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform .2s;
}

.gi-seal img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.gi-seal:hover { transform: translate(-50%, -50%) scale(1.05); }
.gi-seal:focus-visible { outline: 2px solid var(--gold); outline-offset: 5px; }
.gi-env.open .gi-seal { animation: gi-crack .35s ease-in forwards; pointer-events: none; }
@keyframes gi-crack {
  40% { transform: translate(-50%, -50%) rotate(-14deg) scale(1.1); }
  to { transform: translate(-50%, -30%) rotate(-30deg) scale(.6); opacity: 0; }
}

.gi-peek {
  position: absolute;
  left: 50%;
  bottom: 6%;
  z-index: 1;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .25);
  transform: translate(-50%, 0);
  transition: transform .8s cubic-bezier(.35, .1, .25, 1);
}
.gi-peek-in { transform-origin: 0 0; pointer-events: none; }
.gi-peek-in .gi-face { min-height: 0; height: 100%; }
.gi-env.out .gi-peek { transform: translate(-50%, -58%); }

.gi-room.presenting .gi-peek { visibility: hidden; }
.gi-room.presenting .gi-env {
  transform: translateY(90px) rotate(2deg);
  opacity: 0;
  pointer-events: none;
  transition: transform .7s cubic-bezier(.5, 0, .7, .4), opacity .5s .15s;
}

.gi-card {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  perspective: 2000px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(26%) scale(.72);
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, .55)) drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
}
.gi-room.presenting .gi-card {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
.gi-card-in {
  display: grid;
  transform-style: preserve-3d;
  transition: transform .85s cubic-bezier(.45, .05, .25, 1);
}
.gi-card.flipped .gi-card-in { transform: rotateY(180deg); }
.gi-face {
  grid-area: 1 / 1;
  position: relative;
  min-height: 400px;
  padding: 44px 48px 40px;
  border-radius: 6px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 .05 0 0 0 0 .03 0 0 0 .55 -.18'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23p)'/%3E%3C/svg%3E"),
    radial-gradient(120% 110% at 30% 15%, rgba(255, 255, 255, .08), transparent 60%),
    var(--emerald);
  color: var(--cream);
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  cursor: pointer;
}
.gi-face:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.gi-face::before, .gi-face::after {
  content: '';
  position: absolute;
  border: .75px solid var(--hair);
  border-radius: 3px;
  pointer-events: none;
}
.gi-face::before { inset: 12px; }
.gi-face::after { inset: 17px; border-color: rgba(217, 182, 90, .45); }
.gi-back { transform: rotateY(180deg); text-align: left; cursor: default; }

.gi-front { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gi-front img { width: 40px; height: 40px; margin-bottom: 18px; }
.gi-small {
  margin: 0;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--soft);
}
.gi-foil {
  margin: 10px 0 12px;
  font-family: var(--serif);
  font-size: clamp(40px, 7vw, 58px);
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  background: linear-gradient(100deg, #B8913D 0%, #F1D891 38%, #C9A24C 55%, #EBCF83 75%, #B08636 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25));
}
.gi-what {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: clamp(26px, 4.4vw, 34px);
  font-weight: 500;
  letter-spacing: .02em;
}
.gi-orn { display: flex; align-items: center; gap: 12px; margin: 22px 0 18px; color: var(--gold); font-size: 12px; }
.gi-orn::before, .gi-orn::after { content: ''; width: 54px; height: .75px; background: var(--hair); }
.gi-note { margin: 0; font-family: var(--serif); font-size: 18px; font-style: italic; color: var(--soft); }
.gi-pto {
  position: absolute;
  right: 30px;
  bottom: 26px;
  margin: 0;
  font-family: var(--sans);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(217, 182, 90, .7);
}

.gi-kicker {
  margin: 0;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--gold);
}
.gi-title {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 25px;
  font-style: italic;
  font-weight: 500;
  line-height: 1.15;
}
.gi-notes {
  margin: 16px 0 0;
  padding: 14px 0 0;
  border-top: .75px solid var(--hair);
  list-style: none;
  columns: 2;
  column-gap: 30px;
}
.gi-notes li { display: grid; grid-template-columns: 28px 1fr; break-inside: avoid; margin-bottom: 12px; }
.gi-n {
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  font-weight: 600;
  line-height: 1.25;
  color: var(--gold);
}
.gi-nt { margin: 0; font-family: var(--serif); font-size: 15.5px; font-weight: 600; line-height: 1.2; }
.gi-nb { margin: 3px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--soft); }
.gi-enter {
  display: block;
  margin: 10px auto 0;
  padding: 11px 26px;
  border: .75px solid var(--gold);
  border-radius: 999px;
  background: transparent;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .26em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.gi-enter:hover { background: var(--gold); color: #0A3D2C; }
.gi-enter:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.gi-hint {
  margin: 24px 0 0;
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: rgba(255, 244, 230, .62);
  text-align: center;
  transition: opacity .3s;
}
.gi-x {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #F3ECDD;
  color: #2C1D11;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}

@media (max-width: 640px) {
  .gi-face { min-height: 0; padding: 38px 26px 34px; }
  .gi-front { min-height: 460px; }
  .gi-notes { columns: 1; }
  .gi-title { font-size: 22px; }
  .gi-pto { right: 24px; bottom: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .gi-env, .gi-card, .gi-card-in, .gi-env-flap, .gi-seal { animation: none !important; transition: none !important; }
}
