:root {
  color-scheme: light;
  --bg: #fffaf0;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #fff8e6;
  --ink: #24180a;
  --muted: #705f43;
  --gold: #f2c84b;
  --teal: #4bc7a4;
  --red: #d94134;
  --line: rgba(117, 86, 21, 0.16);
  --shadow: rgba(101, 69, 12, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  background:
    linear-gradient(180deg, #fff8e7 0%, #ffffff 46%, #fff3dc 100%);
  color: var(--ink);
  overflow: hidden;
}

html.reward-embedded,
body.reward-embedded {
  background: transparent;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: 0;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 253, 235, 0.92) 0 34px, transparent 36px),
    radial-gradient(circle at 29% 54%, rgba(147, 39, 29, 0.78) 0 31px, transparent 33px),
    radial-gradient(circle at 70% 54%, rgba(217, 188, 88, 0.82) 0 31px, transparent 33px),
    linear-gradient(90deg, transparent 0 11%, rgba(255, 255, 255, 0.28) 11% 12%, transparent 12% 88%, rgba(255, 255, 255, 0.28) 88% 89%, transparent 89%),
    linear-gradient(180deg, rgba(53, 122, 93, 0.75), rgba(47, 91, 75, 0.8) 42%, rgba(134, 95, 43, 0.62) 42%, rgba(177, 126, 58, 0.72));
  filter: saturate(0.95);
}

body::after {
  z-index: 0;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 227, 132, 0.28), transparent 18rem),
    rgba(255, 247, 229, 0.46);
  backdrop-filter: blur(5px);
}

body.reward-embedded::before,
body.reward-embedded::after {
  display: none;
}

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

button {
  border: 0;
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  height: 100svh;
  width: min(100%, 430px);
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: max(64px, calc(env(safe-area-inset-top) + 48px)) 16px max(18px, env(safe-area-inset-bottom));
}

body.reward-embedded .app-shell {
  width: 100%;
  height: 100%;
  padding: 8px;
}

.preview-tools {
  position: fixed;
  z-index: 5;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 360px);
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0;
}

.tool-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 7px 18px rgba(132, 90, 12, 0.08);
}

.screen {
  width: 100%;
  min-height: 0;
  display: grid;
  align-items: center;
  gap: 16px;
}

.notice-card,
.action-panel,
.download-panel {
  width: 100%;
  max-height: none;
  overflow: visible;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 42px var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-overflow-scrolling: touch;
}

.notice-shell {
  width: 100%;
  display: grid;
  gap: 9px;
  animation: prizePopupIn 520ms cubic-bezier(0.18, 0.9, 0.24, 1.18) both;
  transform-origin: 50% 58%;
}

.notice-art-panel {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 18px 42px var(--shadow);
  background: #fff3d8;
}

.notice-art {
  display: block;
  width: 100%;
  height: auto;
}

.notice-art-content {
  position: absolute;
  left: 25.4%;
  top: 20%;
  width: 49.2%;
  height: 54%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  text-align: center;
}

.notice-card-preview {
  display: block;
  width: min(54%, 88px);
  aspect-ratio: 900 / 1300;
  object-fit: contain;
  border-radius: 5px;
  transform: translateY(-5px);
  box-shadow:
    0 7px 16px rgba(93, 42, 11, 0.22),
    0 0 0 1px rgba(137, 74, 16, 0.16);
}

.notice-button-tray {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(117, 86, 21, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(101, 69, 12, 0.12);
  backdrop-filter: blur(14px);
}

.notice-accept-button,
.notice-decline-button {
  min-width: 0;
  min-height: 42px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 950;
}

.notice-accept-button {
  border: 1px solid rgba(131, 31, 16, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.56), transparent 44%),
    linear-gradient(180deg, #f6503a 0%, #b62016 100%);
  color: #fff8df;
  box-shadow:
    0 3px 0 rgba(98, 22, 13, 0.72),
    0 8px 16px rgba(151, 35, 20, 0.22),
    inset 0 0 0 1px rgba(255, 221, 111, 0.42);
  text-shadow: 0 1px 0 rgba(72, 16, 9, 0.72);
}

.notice-decline-button {
  border: 1px solid rgba(169, 70, 51, 0.22);
  background:
    linear-gradient(180deg, #fffdf9 0%, #fff1e6 100%);
  color: #9c3027;
  box-shadow:
    0 3px 0 rgba(158, 95, 57, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.notice-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 18px;
  padding: 24px 20px 20px;
  border-radius: 18px;
  text-align: center;
  animation: prizePopupIn 520ms cubic-bezier(0.18, 0.9, 0.24, 1.18) both;
  transform-origin: center;
}

.notice-card::before,
.notice-card::after {
  content: "";
  position: absolute;
  inset: auto;
  pointer-events: none;
  border-radius: 999px;
}

.notice-card::before {
  width: 190px;
  height: 190px;
  left: 50%;
  top: -78px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 222, 106, 0.7), transparent 68%);
  animation: noticeGlow 2.7s ease-in-out infinite;
}

.notice-card::after {
  width: 100px;
  height: 100px;
  right: -34px;
  top: 58px;
  background: radial-gradient(circle, rgba(75, 199, 164, 0.24), transparent 70%);
}

.notice-card > * {
  position: relative;
  z-index: 1;
}

.notice-kicker {
  width: fit-content;
  margin: 0 auto;
  padding: 6px 12px;
  border: 1px solid rgba(204, 139, 0, 0.24);
  border-radius: 999px;
  background: #fff7dc;
  color: #a16600;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.notice-title {
  margin: 0;
  font-size: clamp(32px, 9vw, 44px);
  line-height: 1.05;
  font-weight: 950;
  letter-spacing: 0;
}

.notice-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.notice-rank {
  color: var(--ink);
  font-size: 22px;
}

.primary-button,
.secondary-button,
.ghost-button,
.photo-special-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 13px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.primary-button {
  background: linear-gradient(180deg, #ffe389 0%, #d19d22 100%);
  color: #1c1304;
  box-shadow: 0 9px 0 rgba(95, 61, 4, 0.75), 0 16px 28px rgba(0, 0, 0, 0.28);
}

.secondary-button {
  border: 1px solid rgba(112, 95, 67, 0.24);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.ghost-button {
  border: 1px solid rgba(112, 95, 67, 0.18);
  background: transparent;
  color: var(--muted);
}

.photo-special-button {
  position: relative;
  overflow: hidden;
  flex-direction: column;
  gap: 3px;
  min-height: 52px;
  border-radius: 14px;
  padding: 7px 16px 8px;
  border: 1px solid rgba(183, 118, 255, 0.36);
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.95), transparent 28%),
    linear-gradient(180deg, #fff1ff 0%, #e8d6ff 48%, #caa7ff 100%);
  color: #392050;
  box-shadow: 0 0 0 0 rgba(190, 130, 255, 0.44), 0 12px 24px rgba(119, 66, 161, 0.18);
  animation: softPulse 2.1s ease-in-out infinite;
}

.photo-special-button > span {
  position: relative;
  z-index: 1;
}

.special-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #7a36ac;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px rgba(150, 79, 211, 0.18);
}

.photo-special-button::after {
  content: "";
  position: absolute;
  inset: -40% -70%;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.72) 50%, transparent 65%);
  transform: translateX(-38%);
  animation: softShimmer 3.2s ease-in-out infinite;
}

.danger-button {
  min-height: 48px;
  border-radius: 13px;
  padding: 0 16px;
  background: linear-gradient(180deg, #ff7669 0%, #cf342b 100%);
  color: #fff8f4;
  box-shadow: 0 8px 0 rgba(109, 26, 20, 0.58), 0 14px 22px rgba(151, 35, 28, 0.18);
}

.button-row {
  display: grid;
  gap: 8px;
}

.action-panel,
.download-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  animation: prizePopupIn 520ms cubic-bezier(0.18, 0.9, 0.24, 1.18) both;
  transform-origin: center;
}

.action-panel .primary-button,
.action-panel .secondary-button,
.action-panel .photo-special-button,
.action-panel .danger-button,
.download-panel .primary-button,
.download-panel .secondary-button,
.download-panel .photo-special-button,
.download-panel .danger-button {
  min-height: 40px;
  border-radius: 11px;
  padding: 0 12px;
  font-size: 13px;
}

.action-panel .photo-special-button,
.download-panel .photo-special-button {
  min-height: 48px;
}

.reward-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

.reward-heading h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.reward-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}

.rank-pill {
  min-width: 58px;
  padding: 7px 8px;
  border-radius: 10px;
  background: #fff5cf;
  border: 1px solid rgba(211, 148, 0, 0.28);
  color: #9b6500;
  text-align: center;
  font-weight: 950;
  font-size: 13px;
}

.card-stage {
  width: min(100%, 170px);
  margin: 0 auto;
}

.card-preview,
.result-image,
.camera-card {
  display: block;
  width: 100%;
  aspect-ratio: 900 / 1300;
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 18px 38px rgba(101, 69, 12, 0.24);
}

.card-preview {
  height: auto;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.result-image {
  height: auto;
  object-fit: contain;
  -webkit-user-select: auto;
  user-select: auto;
}

.privacy-note,
.save-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.save-note {
  text-align: center;
}

.save-note-strong {
  padding: 8px 10px;
  border: 1px solid rgba(211, 148, 0, 0.22);
  border-radius: 10px;
  background: #fff8df;
  color: #6b4b08;
  font-size: 12px;
  font-weight: 900;
}

.camera-card {
  position: relative;
  overflow: hidden;
}

.camera-window {
  position: absolute;
  overflow: hidden;
  background: #050505;
}

.camera-window video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.camera-error {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(231, 104, 77, 0.14);
  color: #8d2a1e;
  font-size: 13px;
  line-height: 1.6;
}

.gallery-grid {
  width: 100%;
  max-height: calc(100svh - 92px);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 16px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px var(--shadow);
}

.gallery-item {
  display: grid;
  gap: 8px;
}

.gallery-item h2 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.gallery-item .card-preview {
  width: min(100%, 320px);
  margin: 0 auto;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(41, 27, 7, 0.28);
  backdrop-filter: blur(10px);
}

.confirm-dialog {
  width: min(100%, 360px);
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(82, 52, 6, 0.2);
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.confirm-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@keyframes softPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(190, 130, 255, 0.28), 0 12px 24px rgba(119, 66, 161, 0.18);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(190, 130, 255, 0.06), 0 16px 30px rgba(119, 66, 161, 0.22);
    filter: brightness(1.04);
  }
}

@keyframes softShimmer {
  0%, 55%, 100% {
    transform: translateX(-38%);
    opacity: 0;
  }
  70% {
    transform: translateX(38%);
    opacity: 1;
  }
}

@keyframes prizePopupIn {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.92) rotate(-0.7deg);
    filter: saturate(1.1) brightness(1.06);
  }
  62% {
    opacity: 1;
    transform: translateY(-3px) scale(1.025) rotate(0.35deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
    filter: saturate(1) brightness(1);
  }
}

@keyframes noticeGlow {
  0%, 100% {
    opacity: 0.58;
    transform: translateX(-50%) scale(0.96);
  }
  50% {
    opacity: 0.96;
    transform: translateX(-50%) scale(1.06);
  }
}

#work-canvas {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 900px;
  height: 1300px;
  pointer-events: none;
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .action-panel,
  .download-panel {
    padding: 10px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .photo-special-button,
  .danger-button {
    min-height: 46px;
    font-size: 14px;
  }
}
