*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink-top: #0e2b39;
  --ink-bot: #16465b;
  --tag: #e7d7b0;
  --tag-hi: #f0e4c7;
  --tag-edge: #cdb98c;
  --tag-ink: #22323b;
  --muted: #7a6b48;
  --field: #fbf4e2;
  --stamp: #c0472f;
  --string: #cbba8d;
}

html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--tag-ink);
  background: linear-gradient(165deg, var(--ink-top), var(--ink-bot));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(52px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
}

/* ---- The luggage tag ---- */
.tag {
  position: relative;
  background: var(--tag);
  background-image: linear-gradient(180deg, var(--tag-hi), var(--tag) 42%);
  border-radius: 16px;
  padding: 22px 22px 26px;
  box-shadow: 0 22px 44px rgba(0,0,0,.36), inset 0 0 0 1px rgba(0,0,0,.04);
  transform-origin: 50% 16px;
  animation: sway 1s cubic-bezier(.2,.72,.2,1) both;
}
/* the string, hanging above the tag */
.tag::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 2px;
  height: 52px;
  background: linear-gradient(var(--ink-top), var(--string));
  transform: translateX(-50%);
}

@keyframes sway {
  0% { transform: rotate(-2.4deg); }
  62% { transform: rotate(1.4deg); }
  100% { transform: rotate(0); }
}
@media (prefers-reduced-motion: reduce) { .tag { animation: none; } }

.tag-head {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 20px;
  margin-bottom: 14px;
}
.grommet {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink-top);
  box-shadow: 0 0 0 3px var(--stamp), inset 0 1px 2px rgba(0,0,0,.6);
}

/* All three screens share one grid cell, so the tag is always sized to the
   tallest screen (the form). Switching screens never changes the tag size. */
.tag-body { display: grid; }
.screen { grid-area: 1 / 1; align-self: center; }
.screen[hidden] { display: block; visibility: hidden; }

/* ---- Language screen: flags only ---- */
.flags {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.flag-btn {
  appearance: none;
  cursor: pointer;
  background: var(--field);
  border: 1.5px solid var(--tag-edge);
  border-radius: 12px;
  padding: 16px 10px 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  color: var(--tag-ink);
  transition: border-color .12s ease, transform .08s ease, background .12s ease;
}
.flag-btn:active { transform: scale(.97); }
.flag-btn:focus-visible { outline: none; border-color: var(--stamp); box-shadow: 0 0 0 3px rgba(192,71,47,.28); }
@media (hover: hover) { .flag-btn:hover { border-color: var(--stamp); background: #fff; } }
.flag-btn .flag {
  height: 40px;
  width: auto;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.flag-btn .label {
  font-size: 15px;
  font-weight: 700;
}

/* ---- Form + thanks ---- */
.back {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: .06em;
  padding: 0 0 14px;
}
.tag h1 {
  font-family: "Bricolage Grotesque", -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: clamp(22px, 6.4vw, 27px);
  line-height: 1.16;
  letter-spacing: -.01em;
  margin: 0 0 10px;
  color: var(--tag-ink);
}
.sub {
  margin: 0 0 22px;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--muted);
}

form { text-align: left; }
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0 0 6px;
  color: var(--tag-ink);
}
input {
  width: 100%;
  font-size: 17px;
  padding: 13px 14px;
  color: var(--tag-ink);
  background: var(--field);
  border: 1.5px solid var(--tag-edge);
  border-radius: 10px;
  margin-bottom: 18px;
}
input:focus {
  outline: none;
  border-color: var(--stamp);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(192,71,47,.18);
}
.locbtn {
  width: 100%;
  appearance: none;
  cursor: pointer;
  background: transparent;
  color: var(--tag-ink);
  border: 1.5px solid var(--tag-edge);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  margin-bottom: 12px;
}
.locbtn.done {
  border-color: #2e8b57;
  color: #2e8b57;
  background: rgba(46,139,87,.08);
}
.locbtn:disabled { cursor: default; }

.send {
  width: 100%;
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--stamp);
  color: #fdf3e6;
  font-family: "Bricolage Grotesque", -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 15px;
  border-radius: 10px;
  transition: transform .08s ease, filter .12s ease;
}
.send:active { transform: scale(.985); }
.send:disabled { filter: saturate(.5) brightness(.96); cursor: default; }
.err {
  margin: 14px 0 0;
  text-align: center;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--stamp);
}

/* ---- Thanks ---- */
#screen-thanks { text-align: center; }
.stamp {
  color: #2e8b57;
  margin: 4px 0 14px;
}
.stamp svg { display: block; margin: 0 auto; }
#screen-thanks .sub { margin-bottom: 4px; }
