:root {
  --bg: #004B87;
  --bg-dark: #003866;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --box: rgba(255, 255, 255, 0.12);
  --box-border: rgba(255, 255, 255, 0.45);
  --gold: #FFC72C;
  --gold-text: #2b2100;
  --warning: #ff4d4d;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px calc(56px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 16px 0 8px;
}

.logo {
  position: absolute;
  left: 0;
  top: 16px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
  border: 2px rgba(255, 255, 255, 0.5);
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.title {
  margin: 0;
  padding: 0 76px;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.01em;
}

/* ---------- Search bar ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
}

.search {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 20px auto 0;
  max-width: 460px;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 24px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: #fff;
  color: #10233a;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  outline: none;
}

.search input::placeholder {
  color: #7a8796;
  letter-spacing: normal;
}

.search input:focus { border-color: var(--gold); }
.search input.invalid { border-color: var(--warning); }

.enter-btn {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: var(--gold-text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.enter-btn:hover { filter: brightness(1.08); }
.enter-btn:active { transform: scale(0.94); }

.warning {
  color: var(--warning);
  text-align: center;
  font-weight: 600;
  margin: 10px 0 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ---------- Result ---------- */
.result { margin-top: 28px; }

.message {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 18px;
  border-radius: 14px;
  background: var(--bg-dark);
}

.section-card {
  background: var(--bg-dark);
  border-radius: 18px;
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 16px;
}

.section-head h2 { margin: 0; font-size: 1.4rem; }

.section-head .answer {
  color: var(--gold);
  font-weight: 700;
  font-size: 1.1rem;
}

/* The U shape: left column | open middle | right column, with the bottom row spanning all */
.u-shape {
  display: grid;
  grid-template-columns: minmax(84px, 140px) 1fr minmax(84px, 140px);
  grid-template-areas:
    "left   middle right"
    "bottom bottom bottom";
  gap: 8px;
}

.side { display: flex; flex-direction: column; gap: 8px; }
.side.left   { grid-area: left; }
.side.right  { grid-area: right; }
.side.bottom { grid-area: bottom; flex-direction: row; }

.middle {
  grid-area: middle;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 8px;
}

.box {
  flex: 1;
  min-height: 56px;
  min-width: 0;
  padding: 6px 8px;
  border: 2px solid var(--box-border);
  border-radius: 8px;
  background: var(--box);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.box .box-id {
  font-weight: 700;
  font-size: 0.72rem;
  opacity: 0.75;
}

.box.highlight {
  background: var(--gold);
  border-color: #fff;
  color: var(--gold-text);
  font-weight: 700;
  box-shadow: 0 0 0 3px rgba(255, 199, 44, 0.45), 0 0 18px rgba(255, 199, 44, 0.6);
  animation: pop 0.35s ease;
}

.box.highlight .box-id { opacity: 1; }

@keyframes pop {
  0%   { transform: scale(0.9); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- Footer ---------- */
.last-updated {
  position: fixed;
  right: 16px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  .logo { width: 48px; height: 48px; top: 20px; }
  .title { padding: 0 56px; }
  .u-shape { grid-template-columns: minmax(70px, 1fr) 0.4fr minmax(70px, 1fr); }
  .box { font-size: 0.72rem; min-height: 50px; }
  .middle { font-size: 0.75rem; }
}
