:root {
  color-scheme: light;
  --free: #aee03a;
  --free-deep: #478c1a;
  --pro: #ff7043;
  --ink: #222522;
  --muted: rgba(34, 37, 34, 0.64);
  --paper: rgba(255, 255, 255, 0.86);
  --shadow: 0 18px 44px rgba(29, 48, 36, 0.15);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #effff4;
  color: var(--ink);
}

body {
  min-height: 100svh;
  overflow-x: hidden;
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 196, 164, 0.36), transparent 30%),
    radial-gradient(circle at 92% 4%, rgba(105, 219, 199, 0.28), transparent 30%),
    linear-gradient(150deg, #f8fff6, #effff8 42%, #fff7ec);
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

#camera-screen.active {
  display: flex;
  min-height: calc(100svh - max(16px, env(safe-area-inset-top)) - max(18px, env(safe-area-inset-bottom)));
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1;
  letter-spacing: 0;
}

.topbar-title {
  text-align: right;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 900;
  color: var(--free-deep);
  letter-spacing: 0.08em;
}

.ghost-button {
  min-width: 84px;
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--free-deep);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(71, 140, 26, 0.16);
}

.hand-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 12px;
}

.hand-option {
  min-height: 74px;
  padding: 12px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  text-align: left;
  box-shadow: inset 0 0 0 1px rgba(71, 140, 26, 0.12);
}

.hand-option span,
.hand-option small {
  display: block;
}

.hand-option span {
  font-size: 18px;
  font-weight: 950;
  color: var(--ink);
}

.hand-option small {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.hand-option.active {
  background: linear-gradient(135deg, var(--free), #eaffb9);
  color: var(--free-deep);
  box-shadow: 0 10px 24px rgba(111, 170, 36, 0.24);
}

.camera-card {
  position: relative;
  height: clamp(380px, 58svh, 620px);
  overflow: hidden;
  border-radius: 30px;
  background: #16211c;
  box-shadow: var(--shadow);
}

#camera-video,
.camera-guide,
.camera-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera-video {
  object-fit: cover;
}

.camera-guide {
  object-fit: contain;
  padding: 22px;
  opacity: 0.84;
  mix-blend-mode: screen;
  pointer-events: none;
}

.camera-placeholder {
  display: grid;
  place-items: center;
  padding: 38px;
  text-align: center;
  color: white;
  background: linear-gradient(160deg, #6fe0c5, #ffd56a 52%, #ff8d82);
}

.camera-placeholder[hidden] {
  display: none;
}

.camera-placeholder img {
  width: 46%;
  max-width: 180px;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.18));
}

.camera-placeholder p {
  margin: 16px 0 0;
  font-weight: 900;
  line-height: 1.5;
}

.analysis-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(248, 255, 248, 0.72);
  backdrop-filter: blur(14px);
}

.analysis-overlay[hidden] {
  display: none;
}

.analysis-overlay p {
  margin-top: 116px;
  font-size: 22px;
  font-weight: 950;
  color: var(--free-deep);
}

.pulse-ring {
  position: absolute;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: radial-gradient(circle, white 0 34%, rgba(174, 224, 58, 0.35) 36% 58%, transparent 60%);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.88); opacity: 0.72; }
  50% { transform: scale(1.08); opacity: 1; }
}

.action-row {
  position: sticky;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 6;
  margin-top: auto;
  padding-top: 14px;
  padding-bottom: 4px;
  background: linear-gradient(180deg, rgba(248, 255, 246, 0), rgba(248, 255, 246, 0.92) 42%, rgba(248, 255, 246, 0.98));
}

.primary-button {
  width: 100%;
  min-height: 58px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--free), #e8ffad);
  color: var(--free-deep);
  font-size: 18px;
  font-weight: 950;
  box-shadow: 0 14px 28px rgba(111, 170, 36, 0.26);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.notice {
  margin: 12px 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.result-card {
  position: relative;
  overflow: hidden;
  border-radius: 30px;
  padding: 18px;
  background: white;
  box-shadow: var(--shadow);
}

.share-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.42;
}

.score-band,
.palm-visual,
.reading-copy,
.line-list,
.lucky-box {
  position: relative;
  z-index: 1;
}

.score-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 15px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
}

.score-band span {
  font-size: 12px;
  font-weight: 950;
  color: var(--free-deep);
}

.score-band strong {
  font-size: 36px;
  line-height: 1;
  color: var(--pro);
}

.palm-visual {
  width: min(88%, 330px);
  aspect-ratio: 1;
  margin: 12px auto 6px;
}

.palm-visual img,
.palm-visual svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center;
}

.palm-visual img {
  object-fit: contain;
}

.palm-visual.left #palm-base,
.palm-visual.left #palm-lines {
  transform: scaleX(-1);
}

.line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5.5;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.18));
}

.line-glow {
  fill: none;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 9.5;
  opacity: 0.95;
}

.life { stroke: #ff3f69; }
.head { stroke: #ff8c22; }
.heart { stroke: #ff3f69; }
.premium {
  stroke-width: 3.6;
  opacity: 0.88;
}

.fate { stroke: #8e5cff; }
.sun { stroke: #f4b000; }
.mercury,
.money { stroke: #00a878; }
.marriage { stroke: #00bcd4; }
.sign { stroke: #407bff; }
.premium-glow { stroke-width: 7.5; }

.reading-copy {
  margin-top: 6px;
}

.hand-label {
  margin: 0 0 7px;
  color: var(--free-deep);
  font-size: 12px;
  font-weight: 950;
}

.reading-copy h2 {
  margin: 0;
  color: var(--pro);
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.12;
  letter-spacing: 0;
}

.reading-copy p:not(.hand-label) {
  margin: 10px 0 0;
  color: rgba(34, 37, 34, 0.76);
  font-weight: 800;
  line-height: 1.68;
}

.line-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.line-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 11px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

.line-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--free);
  color: var(--free-deep);
  font-weight: 950;
}

.line-item strong,
.line-item small {
  display: block;
}

.line-item strong {
  font-size: 14px;
}

.line-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.line-item em {
  color: var(--pro);
  font-style: normal;
  font-size: 13px;
  font-weight: 950;
}

.lucky-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 13px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
}

.lucky-icon {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 22px rgba(255, 112, 67, 0.2);
}

.lucky-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 300%;
  height: 400%;
  background-image: url("assets/lucky-items.png");
  background-size: 100% 100%;
  transform: translate(var(--lucky-x, -58px), var(--lucky-y, 0px));
}

.lucky-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
}

.lucky-box strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

.pro-card {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding: 15px;
  border-radius: 22px;
  color: #3b1f12;
  background: linear-gradient(135deg, rgba(255, 224, 184, 0.92), rgba(255, 124, 78, 0.2), rgba(255, 255, 255, 0.88));
  box-shadow: inset 0 0 0 1px rgba(255, 112, 67, 0.22);
}

.pro-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pro-heading span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--pro);
  color: white;
  font-size: 12px;
  font-weight: 950;
}

.pro-heading strong {
  min-width: 0;
  color: #8a2f16;
  font-size: 13px;
  font-weight: 950;
  text-align: right;
}

.pro-summary {
  margin: 11px 0 0;
  color: rgba(59, 31, 18, 0.78);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.65;
}

.pro-palm-map {
  position: relative;
  width: min(82%, 270px);
  aspect-ratio: 1;
  margin: 12px auto 0;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 112, 67, 0.18);
}

.pro-palm-map img,
.pro-palm-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center;
}

.pro-palm-map img {
  object-fit: contain;
}

.pro-palm-map.left img,
.pro-palm-map.left svg {
  transform: scaleX(-1);
}

.pro-line-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.pro-score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.pro-score-item {
  padding: 10px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.66);
}

.pro-score-item span,
.pro-score-item strong {
  display: block;
}

.pro-score-item span {
  color: rgba(59, 31, 18, 0.62);
  font-size: 11px;
  font-weight: 950;
}

.pro-score-item strong {
  margin-top: 3px;
  color: #8a2f16;
  font-size: 24px;
  line-height: 1;
}

.pro-line-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  padding: 10px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.62);
}

.pro-line-item b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ff7043;
  color: white;
  font-size: 12px;
}

.pro-line-item strong,
.pro-line-item small {
  display: block;
}

.pro-line-item strong {
  font-size: 13px;
}

.pro-line-item small {
  margin-top: 2px;
  color: rgba(59, 31, 18, 0.68);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.42;
}

.pro-category-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.pro-category-item {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 112, 67, 0.14);
}

.pro-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pro-category-head strong {
  font-size: 13px;
}

.pro-category-head em {
  color: var(--pro);
  font-style: normal;
  font-size: 18px;
  font-weight: 950;
}

.pro-category-item p {
  margin: 6px 0 0;
  color: rgba(59, 31, 18, 0.68);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.pro-action {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #ff7043, #ff9d52);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.55;
}

.share-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.share-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  border-radius: 999px;
  font-weight: 950;
}

.share-button span {
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-button b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 17px;
  font-style: normal;
}

.share-x {
  background: #000;
  color: white;
}

.share-instagram {
  color: white;
  background: linear-gradient(135deg, #515bd4, #8134af 32%, #dd2a7b 66%, #f58529);
}

.insta-mark {
  position: relative;
  border: 2px solid white;
  border-radius: 7px;
}

.insta-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid white;
  border-radius: 50%;
}

.insta-mark::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: white;
}

.share-threads {
  background: white;
  color: #000;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

@media (max-height: 720px) {
  .camera-card {
    height: clamp(320px, 50svh, 470px);
  }

  .hand-option {
    min-height: 66px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .notice {
    display: none;
  }
}

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

  .share-button span {
    font-size: 11px;
  }
}
