:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --text: #17171c;
  --muted: #6f717b;
  --line: #e8e8ee;
  --accent: #6c5ce7;
  --accent-dark: #5747ce;
  --shadow: 0 18px 60px rgba(31, 27, 62, 0.12);
  --radius: 28px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, textarea, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
a { color: inherit; }

.site-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}
.brand {
  text-decoration: none;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .language-link {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  border: 1px solid rgba(23,23,28,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 6px 20px rgba(25,23,51,.06);
  backdrop-filter: blur(14px);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}
.language-link { padding: 0 14px; font-size: .8rem; font-weight: 800; }

.hero {
  position: relative;
  display: flex;
  min-height: 100svh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: clamp(18px, 2.5vh, 28px);
  padding: 88px 20px 52px;
}
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .52;
  pointer-events: none;
}
.hero::before {
  width: min(58vw, 720px);
  aspect-ratio: 1;
  top: -32%;
  right: -18%;
  background: radial-gradient(circle, rgba(255,211,95,.28), rgba(255,211,95,0) 70%);
}
.hero::after {
  width: min(64vw, 760px);
  aspect-ratio: 1;
  bottom: -40%;
  left: -18%;
  background: radial-gradient(circle, rgba(108,92,231,.20), rgba(108,92,231,0) 70%);
}

.wheel-stage {
  position: relative;
  width: min(72vh, 82vw, 610px);
  aspect-ratio: 1;
  z-index: 1;
  filter: drop-shadow(0 22px 38px rgba(34, 29, 68, .18));
}
.pointer {
  position: absolute;
  z-index: 4;
  top: -2px;
  left: 50%;
  width: clamp(28px, 5.2vw, 46px);
  height: clamp(40px, 7.2vw, 64px);
  transform: translateX(-50%);
  background: #181820;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 8px;
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.15));
}
.wheel-button {
  position: absolute;
  inset: clamp(18px, 3.2vw, 28px);
  display: block;
  width: calc(100% - clamp(36px, 6.4vw, 56px));
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.wheel-button:focus-visible { outline: 5px solid rgba(108,92,231,.28); outline-offset: 8px; }
.wheel-button:disabled { cursor: default; }
#wheelCanvas { display: block; width: 100%; height: 100%; border-radius: 50%; }
.wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: clamp(92px, 18vw, 130px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: clamp(8px, 1.6vw, 12px) solid rgba(255,255,255,.9);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 12px 30px rgba(26,24,47,.14);
  color: var(--text);
  font-size: clamp(.85rem, 2.2vw, 1.05rem);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
}

.spin-button {
  position: relative;
  z-index: 2;
  display: inline-flex;
  min-width: min(320px, 82vw);
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 32px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 16px 35px rgba(108,92,231,.32);
  color: #fff;
  font-size: 1.16rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.spin-button:hover:not(:disabled) { transform: translateY(-2px); background: var(--accent-dark); box-shadow: 0 20px 40px rgba(108,92,231,.38); }
.spin-button:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.spin-button:disabled { background: #d5d4dd; box-shadow: none; color: #8d8d96; cursor: not-allowed; }
.spin-icon { font-size: 1.45rem; line-height: 1; }
.hero-hint { z-index: 2; margin: -4px 0 0; color: var(--muted); font-size: .92rem; }
.scroll-cue {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 2;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  text-decoration: none;
  color: var(--muted);
  font-size: 1.65rem;
  animation: float 1.8s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

.workspace {
  width: min(1000px, calc(100% - 32px));
  margin: 0 auto;
  padding: 80px 0 48px;
}
.editor-card {
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid rgba(23,23,28,.06);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.editor-heading h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.04em; }
.eyebrow { margin: 0 0 3px; color: var(--accent); font-size: .8rem; font-weight: 800; }
.item-count { flex: none; padding: 7px 12px; border-radius: 999px; background: #f1efff; color: var(--accent-dark); font-size: .82rem; font-weight: 800; }
textarea {
  width: 100%;
  min-height: 250px;
  resize: vertical;
  padding: 18px 20px;
  border: 2px solid var(--line);
  border-radius: 18px;
  outline: none;
  background: #fbfbfd;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.75;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 5px rgba(108,92,231,.10); }
textarea::placeholder { color: #b2b2bc; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; }
.input-note { margin: 0; color: var(--muted); font-size: .86rem; }
.text-button { padding: 8px 0; background: transparent; color: var(--muted); font-size: .88rem; font-weight: 700; cursor: pointer; }
.text-button:hover:not(:disabled) { color: #d04444; }
.text-button:disabled { opacity: .38; cursor: default; }
.about-section { width: min(760px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 58px; text-align: center; }
.about-section h2 { margin: 0 0 12px; font-size: clamp(1.55rem, 4vw, 2.35rem); letter-spacing: -.05em; }
.about-section p { margin: 0; color: var(--muted); }

.share-section {
  width: min(1000px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 72px;
}
.share-card {
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid rgba(23,23,28,.06);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 42px rgba(31,27,62,.08);
  text-align: center;
}
.share-heading h2 {
  margin: 0 0 7px;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  letter-spacing: -.04em;
}
.share-heading .eyebrow { margin-bottom: 2px; }
.share-heading p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: .92rem; }
.share-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.share-button {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfbfd;
  color: var(--text);
  font-size: .9rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.share-button:hover { transform: translateY(-2px); border-color: #d7d5e8; background: #fff; box-shadow: 0 10px 24px rgba(31,27,62,.08); }
.share-button:active { transform: translateY(0) scale(.99); }
.share-button:focus-visible { outline: 4px solid rgba(108,92,231,.18); outline-offset: 2px; }
.share-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: none;
  place-items: center;
  border-radius: 10px;
  background: #17171c;
  color: #fff;
  font-size: .82rem;
  font-weight: 900;
  line-height: 1;
}
.share-line .share-icon { background: #06c755; font-size: .55rem; letter-spacing: -.04em; }
.share-facebook .share-icon { background: #1877f2; font-family: Arial, sans-serif; font-size: 1.25rem; }
.share-copy .share-icon { background: #ece9ff; color: var(--accent-dark); font-size: 1rem; }
.share-note { margin: 16px 0 0; color: var(--muted); font-size: .78rem; }
.share-status { min-height: 1.5em; margin: 3px 0 0; color: var(--accent-dark); font-size: .8rem; font-weight: 750; }

.ad-section {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 48px;
}
.ad-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .08em;
  text-align: center;
}
.ad-slot {
  width: 100%;
  min-height: 90px;
}
.ad-slot .adsbygoogle {
  min-height: 90px;
}

.site-footer {
  display: flex;
  width: min(1000px, calc(100% - 32px));
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 26px 0 calc(26px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.site-footer p { margin: 0; }


.result-dialog {
  width: min(520px, calc(100% - 28px));
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
  overflow: visible;
}
.result-dialog::backdrop { background: rgba(18,18,24,.46); backdrop-filter: blur(6px); }
.result-card { position: relative; padding: 42px 28px 28px; border-radius: 28px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.24); text-align: center; }
.result-label { margin: 0 0 8px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.result-text { margin: 0 0 28px; overflow-wrap: anywhere; font-size: clamp(2rem, 8vw, 3.4rem); line-height: 1.2; letter-spacing: -.05em; }
.result-actions { display: grid; grid-template-columns: 1fr 1.1fr; gap: 10px; }
.primary-button, .secondary-button { min-height: 52px; padding: 12px 16px; border-radius: 15px; font-weight: 850; cursor: pointer; }
.primary-button { background: var(--accent); color: #fff; }
.secondary-button { background: #f1f1f5; color: var(--text); }
.dialog-close { position: absolute; top: 12px; right: 14px; width: 38px; height: 38px; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.5rem; cursor: pointer; }

.legal-page { min-height: 100vh; }
.legal-header { position: static; }
.legal-main { width: min(760px, calc(100% - 36px)); margin: 0 auto; padding: 70px 0 100px; }
.legal-main h1 { margin: 0 0 36px; font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.05em; }
.legal-main h2 { margin: 38px 0 12px; font-size: 1.25rem; }
.legal-main p, .legal-main li { color: #4f5058; }
.legal-main a { color: var(--accent-dark); }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 640px) {
  .site-header { width: calc(100% - 24px); padding-top: 12px; }
  .hero { gap: 16px; padding: 70px 12px 56px; }
  .wheel-stage { width: min(66vh, 96vw, 500px); }
  .wheel-button { inset: 20px; width: calc(100% - 40px); }
  .spin-button { min-width: min(300px, 82vw); min-height: 58px; }
  .workspace { width: calc(100% - 24px); padding-top: 56px; }
  .editor-card { border-radius: 22px; }
  .editor-footer { align-items: flex-start; }
  .about-section { padding-bottom: 48px; }
  .share-section { width: calc(100% - 24px); padding-bottom: 56px; }
  .share-card { border-radius: 22px; }
  .share-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .share-button { min-height: 56px; padding-inline: 10px; }
  .ad-section { width: calc(100% - 24px); padding-bottom: 40px; }
  .ad-slot, .ad-slot .adsbygoogle { min-height: 100px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .result-actions { grid-template-columns: 1fr; }
  .primary-button { order: -1; }
}

@media (max-height: 720px) and (min-width: 700px) {
  .wheel-stage { width: min(62vh, 520px); }
  .hero { gap: 14px; }
  .spin-button { min-height: 54px; }
}

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


/* Accessibility and production refinements */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  transform: translateY(-160%);
  padding: 12px 16px;
  border-radius: 12px;
  background: #17171c;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 4px solid rgba(108,92,231,.30); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .scroll-cue { animation: none; }
}
@media (forced-colors: active) {
  .pointer, .spin-button, .primary-button { forced-color-adjust: none; }
}
