:root {
  color-scheme: light;
  --ink: #15120f;
  --muted: #6d6259;
  --paper: #fffaf2;
  --panel: #ffffff;
  --gold: #c08a3f;
  --line: rgba(20, 17, 14, 0.16);
  --shadow: 0 18px 55px rgba(58, 42, 25, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.portal-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
}

.wordmark-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.wordmark-logo img {
  width: 108%;
  height: 108%;
  object-fit: contain;
}

.wordmark strong {
  font-size: 18px;
  letter-spacing: 0;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.mail-button,
.token-button {
  width: 128px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(20, 17, 14, 0.24);
  background: #fff;
  color: #422b10;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.mail-button {
  width: 128px;
  gap: 7px;
  border: 1px solid rgba(20, 17, 14, 0.24);
  box-shadow: none;
}

.mail-button span {
  font-size: 14px;
  line-height: 1;
}

.portal {
  min-height: 100svh;
}

.portal-stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(92px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom));
}

.portal-board {
  position: relative;
  width: min(1120px, calc(100vw - 48px), calc((100svh - 132px) * 1.3658));
  aspect-ratio: 1120 / 820;
}

.crest-stage {
  position: absolute;
  left: 50%;
  top: 0;
  width: 58%;
  height: 64%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
}

.crest {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.secret-entry {
  position: absolute;
  z-index: 4;
  left: 50.8%;
  top: 68%;
  width: 14%;
  aspect-ratio: 1;
  height: auto;
  display: block;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.secret-entry:focus-visible {
  outline: 3px solid rgba(192, 138, 63, 0.72);
  outline-offset: 4px;
}

.portal-tiles {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 90%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  justify-content: center;
  gap: 2.2%;
}

.portal-tile {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 1vw, 12px) 2px;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  transition: transform 180ms ease, color 180ms ease;
}

.portal-tile:hover {
  transform: translateY(-2px);
  color: var(--gold);
}

.portal-tile strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(14px, 2.4vw, 30px);
  line-height: 1;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.wedding-rings {
  position: relative;
  width: clamp(22px, 3.1vw, 36px);
  height: clamp(15px, 2.1vw, 25px);
  display: inline-block;
}

.wedding-rings::before,
.wedding-rings::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 58%;
  aspect-ratio: 1;
  border: clamp(1px, 0.18vw, 2px) solid currentColor;
  border-radius: 50%;
  transform: translateY(-50%);
}

.wedding-rings::before {
  left: 4%;
}

.wedding-rings::after {
  right: 4%;
}

.mail-page {
  min-height: 100svh;
  background: #fff;
}

.mail-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(106px + env(safe-area-inset-top)) 22px calc(34px + env(safe-area-inset-bottom));
}

.mail-card {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  background: #fff;
  padding: clamp(24px, 5vw, 54px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mail-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 7vw, 68px);
  line-height: 0.95;
  letter-spacing: 0;
}

.mail-copy {
  max-width: 560px;
  margin: 18px 0 30px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.send-form {
  display: grid;
  gap: 18px;
}

.send-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.send-form input,
.send-form textarea {
  width: 100%;
  border: 1px solid rgba(20, 17, 14, 0.22);
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  padding: 13px 14px;
  outline: none;
}

.send-form textarea {
  resize: vertical;
  min-height: 190px;
}

.send-form input:focus,
.send-form textarea:focus {
  border-color: rgba(192, 138, 63, 0.78);
  box-shadow: 0 0 0 3px rgba(192, 138, 63, 0.16);
}

.send-form button {
  justify-self: start;
  min-width: 190px;
  min-height: 44px;
  border: 1px solid #15120f;
  background: #15120f;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.mail-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.mail-status--success {
  margin: 0 0 20px;
  color: #166534;
}

.mail-status--error {
  margin: 0 0 20px;
  color: #9f1239;
}

@media (max-width: 1120px) {
  .portal-board {
    width: min(calc(100vw - 48px), calc((100svh - 132px) * 1.3658));
  }
}

@media (max-height: 760px) and (min-width: 621px) {
  .portal-stage {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .portal-board {
    width: min(1040px, calc(100vw - 48px), calc((100svh - 112px) * 1.3658));
  }
}

@media (max-width: 620px) {
  .portal-header {
    height: 74px;
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .wordmark {
    min-width: 0;
  }

  .wordmark-logo {
    width: 38px;
    height: 38px;
  }

  .wordmark strong {
    font-size: 16px;
  }

  .token-button {
    width: 112px;
    height: 34px;
    font-size: 9px;
  }

  .header-actions {
    gap: 10px;
  }

  .mail-button {
    width: 112px;
    height: 34px;
    font-size: 9px;
    gap: 5px;
  }

  .portal-stage {
    padding: calc(88px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  }

  .portal-board {
    width: min(calc(100vw - 32px), calc((100svh - 112px) * 1.3658));
  }

  .crest-stage {
    width: 66%;
    height: 64%;
  }

  .portal-tile {
    min-height: 32px;
    padding: 4px 2px;
  }

  .portal-tile strong {
    font-size: clamp(10px, 3.2vw, 13px);
  }

  .wedding-rings {
    width: clamp(20px, 6.4vw, 26px);
    height: clamp(14px, 4.6vw, 19px);
  }
}
