:root {
  --ink: #102f39;
  --ink-soft: #516b72;
  --paper: #f4f0e7;
  --card: #fffdf8;
  --teal: #073b4c;
  --teal-2: #0e5c68;
  --mint: #a8dad0;
  --mint-pale: #e4f3ef;
  --coral: #ee755f;
  --yellow: #f2c75c;
  --line: #d9ded8;
  --shadow: 0 20px 55px rgba(10, 52, 63, 0.1);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(100%, 700px);
  margin: 0 auto;
  padding: 18px 16px 34px;
}

.hero {
  position: relative;
  padding: 20px;
  color: #f8fbf8;
  border-radius: 20px;
  background: var(--teal);
}

.hero::before,
.hero::after {
  display: none;
}

.hero::before {
  width: 210px;
  height: 210px;
  top: -98px;
  right: -52px;
}

.hero::after {
  width: 132px;
  height: 132px;
  top: -60px;
  right: -13px;
}

.hero__eyebrow,
.section-kicker,
.result-card__eyebrow {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.hero__topbar {
  display: flex;
  position: relative;
  z-index: 2;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero__eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--mint);
}

.hero__globe {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  line-height: 1;
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 17px 0 9px;
  max-width: none;
  font-family: Georgia, "Noto Serif TC", "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
}

.hero h1 br {
  display: none;
}

.hero h1 .hero-title-accent {
  margin-left: 0.22em;
  color: var(--yellow);
}

.language-switch {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.language-switch button {
  min-width: 43px;
  min-height: 30px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.68);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}

.language-switch button[aria-pressed="true"] {
  color: var(--teal);
  background: var(--yellow);
}

.language-switch button:hover {
  color: #fff;
}

.language-switch button[aria-pressed="true"]:hover {
  color: var(--teal);
}

.language-switch button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.hero__intro {
  position: relative;
  z-index: 1;
  max-width: 30rem;
  margin: 0;
  color: rgba(248, 251, 248, 0.76);
  font-size: 0.84rem;
  line-height: 1.5;
}

.game-meta {
  display: flex;
  position: relative;
  z-index: 1;
  align-items: stretch;
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.meta-item {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  gap: 5px;
}

.meta-item--right {
  align-items: flex-end;
}

.meta-item__label {
  color: rgba(248, 251, 248, 0.5);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.meta-item__value {
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
}

.meta-item__value strong {
  color: var(--yellow);
  font-size: 1.35rem;
}

.meta-divider {
  width: 1px;
  margin: 0 17px;
  background: rgba(255, 255, 255, 0.13);
}

.game-card,
.result-card {
  position: relative;
  margin-top: 16px;
  padding: 20px;
  border: 1px solid rgba(7, 59, 76, 0.08);
  border-radius: 18px;
  background: var(--card);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-kicker {
  display: none;
}

.section-heading h2,
.history-title-row h2 {
  margin: 0;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}

.section-step {
  display: none;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 750;
}

.combobox-wrap {
  position: relative;
}

.input-shell {
  display: flex;
  align-items: center;
  height: 54px;
  border: 1.5px solid #cad5d2;
  border-radius: 14px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-shell:focus-within {
  border-color: var(--teal-2);
  box-shadow: 0 0 0 4px rgba(14, 92, 104, 0.11);
}

.search-icon {
  width: 16px;
  height: 16px;
  margin-left: 17px;
  border: 2px solid #71858a;
  border-radius: 50%;
}

.search-icon::after {
  display: block;
  width: 6px;
  height: 2px;
  margin: 11px 0 0 11px;
  content: "";
  transform: rotate(45deg);
  border-radius: 2px;
  background: #71858a;
}

#country-input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
}

#country-input::placeholder {
  color: #9aa8aa;
}

.clear-button {
  display: grid;
  width: 32px;
  height: 32px;
  margin-right: 9px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: #edf1ef;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.clear-button:hover {
  color: var(--teal);
  background: #dde7e4;
}

.clear-button:focus-visible,
.primary-button:focus-visible,
.share-button:focus-visible,
.option-button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.options-list {
  position: absolute;
  z-index: 20;
  width: 100%;
  max-height: 310px;
  margin: 7px 0 0;
  padding: 7px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid #d1dad7;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(7, 59, 76, 0.16);
}

.option-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.option-button:hover,
.option-button.is-active {
  background: var(--mint-pale);
}

.option-button:disabled {
  color: #8e9b9d;
  background: #f5f6f3;
  cursor: not-allowed;
}

.option-name {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.option-name strong {
  font-size: 0.91rem;
}

.option-name small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-code,
.option-used {
  flex: 0 0 auto;
  color: var(--teal-2);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.option-used {
  color: var(--coral);
}

.wheel-option:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.country-wheel-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #d1dad7;
  border-radius: 15px;
  background: #f8faf7;
}

.wheel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1px 6px 8px;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.country-wheel {
  position: relative;
  height: 216px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  scrollbar-color: var(--mint) transparent;
  scrollbar-width: thin;
  border-block: 1px solid #dce4df;
  background:
    linear-gradient(#f8faf7 0%, rgba(248, 250, 247, 0) 22%),
    linear-gradient(rgba(248, 250, 247, 0) 78%, #f8faf7 100%),
    #fff;
}

.country-wheel::before,
.country-wheel::after {
  display: block;
  height: 72px;
  content: "";
}

.wheel-option {
  display: grid;
  width: 100%;
  min-height: 52px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.wheel-option:hover,
.wheel-option.is-selected {
  background: var(--mint-pale);
}

.wheel-option:disabled {
  color: #8e9b9d;
  background: #f1f3f0;
  cursor: not-allowed;
}

.wheel-letter {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--teal-2);
  background: #e8efec;
  font-size: 0.68rem;
  font-weight: 900;
}

.wheel-country-name {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.wheel-country-name strong,
.wheel-country-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-country-name strong {
  font-size: 0.86rem;
}

.wheel-country-name small {
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.wheel-country-code,
.wheel-country-used {
  color: var(--teal-2);
  font-size: 0.65rem;
  font-weight: 900;
}

.wheel-country-used {
  color: var(--coral);
}


.form-message {
  min-height: 1.2em;
  margin: 7px 2px 0;
  color: #b44234;
  font-size: 0.78rem;
  font-weight: 700;
}

.primary-button,
.share-button {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--teal);
  font-weight: 800;
  cursor: pointer;
  transition: transform 130ms ease, background 130ms ease, box-shadow 130ms ease;
}

.primary-button:hover,
.share-button:hover {
  background: var(--teal-2);
  box-shadow: 0 8px 18px rgba(7, 59, 76, 0.2);
}

.primary-button:active,
.share-button:active {
  transform: translateY(1px) scale(0.99);
}

.primary-button:disabled {
  color: #819096;
  background: #dce2df;
  box-shadow: none;
  cursor: not-allowed;
}

.primary-button span:last-child {
  font-size: 1.3rem;
}

.history-section {
  margin-top: 28px;
}

.history-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 13px;
  border-bottom: 1px solid #cfd7d2;
}

.history-title-row h2 {
  margin: 0;
  font-size: 1.35rem;
}

.history-title-row span {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.empty-history {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 9px;
  color: #7c8d90;
  text-align: center;
}

.empty-history__compass {
  display: none;
}

.empty-history p {
  margin: 0;
  font-size: 0.8rem;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
}

.guess-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid rgba(7, 59, 76, 0.09);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 7px 20px rgba(7, 59, 76, 0.045);
  animation: record-in 260ms ease both;
}

.guess-item--correct {
  border-color: rgba(14, 92, 104, 0.32);
  background: var(--mint-pale);
}

.guess-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: var(--teal);
  background: #e8eeeb;
  font-size: 0.72rem;
  font-weight: 850;
}

.guess-item--correct .guess-index {
  color: #fff;
  background: var(--teal-2);
}

.guess-country {
  min-width: 0;
}

.guess-country strong,
.guess-country small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guess-country strong {
  font-size: 0.93rem;
}

.guess-country small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.guess-clue {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 7px;
  text-align: right;
}

.guess-distance {
  font-size: 0.76rem;
  font-weight: 800;
}

.guess-direction {
  color: var(--ink-soft);
  font-size: 0.64rem;
}

.guess-arrow {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 50%;
  color: var(--teal);
  background: var(--mint-pale);
  font-size: 1.15rem;
}

.guess-correct-label {
  color: var(--teal-2);
  font-size: 0.8rem;
  font-weight: 850;
}

.result-card {
  overflow: hidden;
  margin-top: 26px;
  padding: 30px 22px;
  text-align: center;
  background:
    linear-gradient(155deg, rgba(168, 218, 208, 0.44), transparent 60%),
    var(--card);
}

.result-card::before {
  position: absolute;
  width: 95px;
  height: 95px;
  top: -48px;
  right: -40px;
  content: "";
  border: 18px solid rgba(242, 199, 92, 0.22);
  border-radius: 50%;
}

.result-card__eyebrow {
  color: var(--coral);
}

.result-card h2 {
  margin: 10px 0 8px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 2.1rem;
  letter-spacing: -0.04em;
}

.result-answer {
  margin: 0;
  color: var(--teal-2);
  font-size: 1.08rem;
  font-weight: 850;
}

.result-detail {
  margin: 9px 0 22px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.6;
}

.share-button {
  max-width: 330px;
  margin: 0 auto;
  background: var(--coral);
}

.share-button:hover {
  background: #d95e49;
}

.tomorrow-note {
  margin: 16px 0 0;
  color: #718286;
  font-size: 0.73rem;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding: 0 4px;
  color: #77898b;
  font-size: 0.7rem;
  letter-spacing: 0.07em;
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  min-width: 150px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 12px 30px rgba(7, 59, 76, 0.25);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

@keyframes record-in {
  from {
    transform: translateY(-6px);
    opacity: 0;
  }
}

@media (min-width: 560px) {
  .page-shell {
    padding: 28px 24px 48px;
  }

  .hero {
    padding: 24px 28px;
  }

  .game-card,
  .result-card {
    padding: 28px 30px;
  }

  .guess-item {
    padding: 16px 18px;
  }
}

@media (max-width: 359px) {
  .page-shell {
    padding-inline: 12px;
  }

  .hero,
  .game-card {
    border-radius: 20px;
  }

  .hero {
    padding-inline: 18px;
  }

  .hero__eyebrow {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
  }

  .language-switch button {
    min-width: 38px;
    padding-inline: 7px;
  }

  .guess-item {
    gap: 8px;
    padding: 12px 10px;
  }

  .guess-arrow {
    width: 30px;
    height: 30px;
  }

  .guess-direction {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
