:root {
  --orange: #ff9800;
  --orange-deep: #ff4a0b;
  --green: #2f9d32;
  --ink: #4a4a4a;
  --muted: #777;
  --paper: #ffffff;
  --cream: #f1ecdf;
  --shadow: 0 2px 10px rgba(15, 41, 77, 0.15);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  width: 100%;
  background: #f3f3f3;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background: #f3f3f3;
  font-family: Arial, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: none;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  overflow-x: hidden;
  background: #fff;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  height: calc(56px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  color: #fff;
  background: var(--orange);
  font-size: 17px;
  font-weight: 700;
}

.topbar-title {
  line-height: 56px;
}

.auth-topbar {
  min-height: 53px;
  height: calc(53px + env(safe-area-inset-top));
}

.auth-topbar .topbar-title {
  line-height: 53px;
}

.auth-topbar .menu-toggle {
  display: none;
}

.back-button {
  position: absolute;
  top: 4px;
  left: 4px;
  display: none;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #fff;
  background: transparent;
  font-size: 34px;
  font-weight: 200;
  line-height: 1;
}

.menu-toggle {
  position: absolute;
  top: 6px;
  right: 4px;
  display: flex;
  width: 44px;
  height: 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  color: #fff;
  background: transparent;
}

.menu-toggle span {
  display: block;
  width: 23px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.menu-panel {
  position: absolute;
  top: calc(100% - 2px);
  right: 6px;
  z-index: 25;
  display: grid;
  width: min(190px, calc(100vw - 20px));
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 41, 77, 0.2);
}

.menu-panel button {
  min-height: 44px;
  padding: 0 14px;
  color: #555;
  background: transparent;
  font-size: 15px;
  text-align: left;
}

.menu-panel button + button {
  border-top: 1px solid #f0f0f0;
}

.menu-panel button:active {
  background: #fff4e5;
}

.hero {
  position: relative;
  height: 160px;
  overflow: hidden;
  background: #d8f3f7;
}

.hero-slide {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.hero-dots {
  position: absolute;
  right: 0;
  bottom: 5px;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 7px;
}

.hero-dot {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
}

.hero-dot::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ddd;
}

.hero-dot.is-active::before {
  background: #3264ff;
}

.home-content {
  padding: 0 11px;
  background: linear-gradient(180deg, #fff 80px, #f4f5f7 130px, #fff 240px);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  padding: 25px 17px 0;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 3px;
  color: #fff;
  background: linear-gradient(90deg, var(--orange-deep), var(--orange));
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 1px 1px rgba(255, 92, 0, 0.15);
}

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

.section-title {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 25px 0 28px;
}

.section-title img {
  display: block;
  width: 240px;
  height: 70px;
  object-fit: cover;
}

.section-title span {
  position: absolute;
  top: 40px;
  left: 50%;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  transform: translateX(-50%);
  white-space: nowrap;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 12px;
}

.product-card {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.art-frame {
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 0.93;
  padding: 13px;
  place-items: center;
  background: var(--cream);
}

.art-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 1px solid #d6d6d6;
  background: #fff;
  box-shadow: 0 0 0 4px #fff, 0 0 0 5px #d6d6d6;
}

.product-name {
  margin-top: 13px;
  overflow: hidden;
  color: #555;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-votes {
  margin-top: 9px;
  color: #555;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.vote-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border-radius: 3px;
  color: #fff;
  background: linear-gradient(90deg, var(--orange-deep), var(--orange));
  font-size: 15px;
  font-weight: 700;
}

.vote-button.is-voted {
  background: linear-gradient(90deg, #61a84e, #4d9a37);
}

.footer-art {
  width: calc(100% + 22px);
  height: 100px;
  margin: 34px -11px 0;
  background: url("./assets/nav-bg.png") center bottom / cover no-repeat;
}

.modal-backdrop,
.preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.5);
}

.rule-modal {
  width: min(calc(100vw - 50px), 450px);
  padding: 22px 25px 25px;
  border-radius: 7px;
  background: #fffdf5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  color: #292929;
  font-size: 18px;
  font-weight: 700;
}

.modal-heading img {
  width: 56px;
  height: 45px;
  object-fit: contain;
}

.rule-copy {
  max-height: 365px;
  overflow-y: auto;
  padding-right: 6px;
  color: #333;
  font-size: 16px;
  line-height: 2;
}

.rule-copy p {
  margin: 0 0 9px;
}

.rule-copy strong {
  display: block;
  margin-top: 10px;
  font-size: 18px;
}

.modal-close {
  width: 100%;
  min-height: 44px;
  height: 50px;
  margin-top: 17px;
  border-radius: 3px;
  color: #fff;
  background: linear-gradient(90deg, var(--orange-deep), var(--orange));
  font-size: 14px;
  font-weight: 700;
}

.preview-backdrop {
  padding: 25px;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  border: 8px solid #fff;
  background: #fff;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
}

.auth-page {
  min-height: calc(100svh - 53px);
  min-height: calc(100dvh - 53px);
  background: #fff;
}

.auth-main {
  min-height: calc(100svh - 53px);
  min-height: calc(100dvh - 53px);
  padding: 38px 25px 0;
}

.auth-logo {
  position: relative;
  width: 125px;
  height: 125px;
  margin: 0 auto 24px;
}

.auth-logo img {
  display: block;
  width: 125px;
  height: 125px;
}

.auth-title {
  color: #191919;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.auth-description {
  max-width: 340px;
  margin: 8px auto 50px;
  color: #222;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.auth-card {
  position: relative;
  min-height: 260px;
  padding: 14px 20px 16px;
  border-radius: 5px;
  background: #fff;
  box-shadow: var(--shadow);
}

.form-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 25px 44px;
  column-gap: 12px;
  min-height: 82px;
  border-bottom: 1px solid #ebedf0;
}

.form-label {
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: end;
  width: auto;
  color: #646566;
  font-size: 14px;
  white-space: nowrap;
}

.form-label::before {
  content: "*";
  margin-right: 2px;
  color: #f04444;
}

.form-row input {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  width: 100%;
  height: 44px;
  padding: 0 7px;
  border: 0;
  outline: 0;
  color: #646566;
  font-size: 14px;
}

.form-row input::placeholder {
  color: #d8d8d8;
}

.code-button {
  grid-column: 2;
  grid-row: 2;
  min-width: 58px;
  min-height: 44px;
  height: 44px;
  border-radius: 3px;
  color: #555;
  background: #f0f0f0;
  font-size: 13px;
}

.code-button:disabled {
  color: #aaa;
  cursor: default;
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  height: 44px;
  margin-top: 15px;
  border-radius: 3px;
  color: #fff;
  background: linear-gradient(90deg, var(--orange-deep), var(--orange));
  font-size: 14px;
  font-weight: 700;
}

.auth-inline-toast {
  position: absolute;
  top: 25px;
  left: 50%;
  z-index: 3;
  display: none;
  min-width: 190px;
  max-width: calc(100% - 34px);
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 6px;
  color: #fff;
  background: #555;
  font-size: 15px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
}

.auth-inline-toast.is-visible {
  display: flex;
}

.demo-note {
  margin-top: 12px;
  color: #999;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.auth-footer {
  width: calc(100% + 50px);
  height: 114px;
  margin: 72px -25px 0;
  background: url("./assets/nav-bg.png") center bottom / cover no-repeat;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 22px;
  left: 16px;
  z-index: 100;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.toast {
  max-width: 330px;
  padding: 10px 16px;
  border-radius: 5px;
  color: #fff;
  background: rgba(35, 35, 35, 0.88);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 700px) {
  .app-shell {
    max-width: 760px;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
  }

  .hero,
  .hero-slide {
    height: 220px;
  }

  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 14px;
  }

  .home-content {
    padding-right: 18px;
    padding-left: 18px;
  }

  .footer-art {
    width: calc(100% + 36px);
    margin-right: -18px;
    margin-left: -18px;
  }

  .auth-main {
    max-width: 520px;
    margin: 0 auto;
  }
}

@media (max-width: 360px) {
  .auth-main {
    padding-right: 16px;
    padding-left: 16px;
  }

  .auth-title {
    font-size: 17px;
  }

  .auth-description {
    font-size: 12px;
  }

  .auth-card {
    padding-right: 12px;
    padding-left: 12px;
  }

  .action-row {
    gap: 16px;
    padding-right: 4px;
    padding-left: 4px;
  }

  .product-card {
    padding: 9px;
  }

  .product-name,
  .product-votes {
    font-size: 15px;
  }
}
