* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg1: #0f0c29;
  --bg2: #302b63;
  --bg3: #24243e;
  --accent: #ff2e88;
  --accent2: #00e5ff;
  --gold: #ffd700;
  --text: #ffffff;
}

/* -------- 背景テーマ(クリック数で解禁、見た目のみ) -------- */
body[data-bgtheme="sunset"] {
  --bg1: #2b0a3d;
  --bg2: #7b2d6b;
  --bg3: #ff6a3d;
}
body[data-bgtheme="ocean"] {
  --bg1: #001f3f;
  --bg2: #0074d9;
  --bg3: #003d5c;
}
body[data-bgtheme="forest"] {
  --bg1: #0b2e13;
  --bg2: #1b5e20;
  --bg3: #2e7d32;
}
body[data-bgtheme="neon"] {
  --bg1: #0a0014;
  --bg2: #ff00c8;
  --bg3: #00fff2;
}
body[data-bgtheme="sakura"] {
  --bg1: #2b1320;
  --bg2: #b8437a;
  --bg3: #ffd6e8;
}
body[data-bgtheme="gold"] {
  --bg1: #1a1400;
  --bg2: #8a6d00;
  --bg3: #ffd700;
}
body[data-bgtheme="aurora"] {
  --bg1: #020024;
  --bg2: #090979;
  --bg3: #00d4ff;
}
body[data-bgtheme="galaxy"] {
  --bg1: #000000;
  --bg2: #1b0036;
  --bg3: #4b0082;
}
body[data-bgtheme="rainbow"] {
  animation: rainbowBgShift 6s linear infinite !important;
  background: linear-gradient(135deg, #ff2e88, #ffd700, #00e5ff, #7cff00, #ff2e88) !important;
  background-size: 400% 400% !important;
}
body[data-bgtheme="legend"] {
  animation: rainbowBgShift 3s linear infinite !important;
  background: linear-gradient(135deg, #ffd700, #ffffff, #ff2e88, #00e5ff, #ffd700) !important;
  background-size: 400% 400% !important;
}

@keyframes rainbowBgShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg1), var(--bg2) 50%, var(--bg3));
  background-size: 400% 400%;
  animation: bgShift 18s ease infinite;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@keyframes bgShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
}

#app {
  position: relative;
  z-index: 10;
  width: min(640px, 94vw);
  padding: 28px 24px 20px;
  border-radius: 28px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  text-align: center;
}

#header { margin-bottom: 14px; }

#title {
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--gold));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleFlow 4s linear infinite;
  text-shadow: 0 0 40px rgba(255,255,255,0.15);
}

@keyframes titleFlow {
  to { background-position: 200% center; }
}

#subtitle {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.7;
  letter-spacing: 0.5px;
}

#modeSelector {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modeSlot {
  flex: 1;
  position: relative;
}

.modeBtn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.modeBtn .modeNum {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.75;
  letter-spacing: 0.3px;
}

.modeBtn.active {
  background: linear-gradient(160deg, rgba(0,229,255,0.22), rgba(255,46,136,0.18));
  border-color: var(--accent2);
  box-shadow: 0 0 14px rgba(0,229,255,0.25);
}

.modeBtn.active .modeNum { opacity: 1; }

.modeBtn.cleared::after {
  content: "✅";
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 12px;
}

.modeReplayBtn {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255,215,0,0.5);
  background: #1a1430;
  color: var(--text);
  font-size: 10px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.modeReplayBtn:hover {
  background: #2a2050;
  transform: scale(1.1);
}
.modeReplayBtn.hidden { display: none; }

#statsRow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0 14px;
}

.statBox {
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 10px 6px;
  min-width: 0;
}

.statLabel {
  font-size: 10px;
  opacity: 0.55;
  letter-spacing: 1px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statValue {
  font-size: clamp(14px, 3.6vw, 22px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#clickCount {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255,215,0,0.5);
  transition: transform 0.06s ease;
}
#clickCount.pulse { transform: scale(1.12); }

#progressWrap { margin: 6px 0 20px; }

#progressBar {
  position: relative;
  height: 22px;
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
}

#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--gold));
  background-size: 300% 100%;
  animation: fillFlow 3s linear infinite;
  border-radius: 12px 0 0 12px;
  transition: width 0.15s ease-out;
}

@keyframes fillFlow {
  to { background-position: 300% 0; }
}

#progressGlow {
  position: absolute;
  top: 0; left: 0; height: 100%; width: 0%;
  box-shadow: 0 0 20px 4px rgba(255,255,255,0.5);
  pointer-events: none;
  transition: width 0.15s ease-out;
}

#progressText {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

#clickArea {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
}

#clickBtn {
  position: relative;
  width: min(230px, 55vw);
  height: min(230px, 55vw);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #ff5fa8, #ff2e88 55%, #c2126a 100%);
  box-shadow:
    0 0 0 6px rgba(255,255,255,0.06),
    0 14px 0 0 #9c0d54,
    0 24px 40px rgba(255,46,136,0.45);
  transform: translateY(0);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#clickBtn:active,
#clickBtn.pressed {
  transform: translateY(10px);
  box-shadow:
    0 0 0 6px rgba(255,255,255,0.06),
    0 4px 0 0 #9c0d54,
    0 10px 24px rgba(255,46,136,0.5);
}

#clickBtnInner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 4px;
  pointer-events: none;
}

#clickBtnEmoji {
  font-size: clamp(48px, 13vw, 72px);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
}

#clickBtnLabel {
  font-weight: 900;
  font-size: clamp(14px, 3.4vw, 18px);
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

#ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 60%);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}

#ripple.go {
  animation: rippleGo 0.4s ease-out;
}

@keyframes rippleGo {
  from { opacity: 0.9; transform: scale(0.3); }
  to { opacity: 0; transform: scale(1.3); }
}

#milestoneBanner {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,215,0,0.18), rgba(255,46,136,0.18));
  border: 1px solid rgba(255,215,0,0.4);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
}

#milestoneBanner.hidden { display: none; }

#milestoneBanner.show {
  animation: bannerPop 2.6s ease forwards;
}

@keyframes bannerPop {
  0% { opacity: 0; transform: translateY(-8px) scale(0.95); }
  10% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* -------- anti-cheat warning -------- */

#cheatWarning {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 30, 30, 0.18);
  border: 1px solid rgba(255, 60, 60, 0.6);
  font-weight: 800;
  font-size: 13px;
  color: #ffdcdc;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: cheatPulse 1.6s ease-in-out infinite;
}

#cheatWarning.hidden { display: none; }

@keyframes cheatPulse {
  0%, 100% { background: rgba(255, 30, 30, 0.14); }
  50% { background: rgba(255, 30, 30, 0.28); }
}

#cheatCooldown {
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

#clickBtn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6) brightness(0.7);
  animation: cheatShake 0.15s linear infinite;
}

@keyframes cheatShake {
  0% { transform: translateX(-2px); }
  50% { transform: translateX(2px); }
  100% { transform: translateX(-2px); }
}

/* -------- 暇つぶしパネル -------- */

#funPanel {
  margin-top: 16px;
  border-radius: 16px;
  background: rgba(0,0,0,0.24);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  text-align: left;
}

#funTabs {
  display: flex;
}

.funTabBtn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  opacity: 0.55;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.funTabBtn.active {
  opacity: 1;
  background: rgba(255,255,255,0.08);
  border-bottom: 2px solid var(--accent2);
}

.funView {
  padding: 14px 16px 16px;
}

.funView.hidden { display: none; }

#factGenreSelect {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
#factGenreSelect option {
  background: #241f45;
  color: #fff;
}

#factText {
  font-size: 13px;
  line-height: 1.6;
  min-height: 58px;
  opacity: 0.92;
}

#factNextBtn {
  margin-top: 10px;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
#factNextBtn:hover { background: rgba(255,255,255,0.14); }

#badgeGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}

.badge .badgeEmoji {
  font-size: 22px;
  filter: grayscale(1) brightness(0.5);
  opacity: 0.4;
}

.badge .badgeName {
  font-size: 9px;
  opacity: 0.4;
  letter-spacing: 0.5px;
}

.badge.unlocked {
  background: linear-gradient(160deg, rgba(255,215,0,0.16), rgba(255,46,136,0.12));
  border-color: rgba(255,215,0,0.4);
  box-shadow: 0 0 14px rgba(255,215,0,0.15);
}

.badge.unlocked .badgeEmoji {
  filter: none;
  opacity: 1;
}

.badge.unlocked .badgeName {
  opacity: 0.9;
  color: var(--gold);
}

/* -------- テーマ選択グリッド -------- */

#themeHint {
  font-size: 11px;
  opacity: 0.55;
  margin-bottom: 10px;
  line-height: 1.5;
}

#themeGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.themeCard {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.1);
  cursor: pointer;
  text-align: center;
  padding: 0;
  background: none;
}

.themeCard .themeSwatch {
  height: 40px;
  width: 100%;
}

.themeCard .themeLabel {
  display: block;
  font-size: 9px;
  font-weight: 700;
  padding: 5px 2px;
  background: rgba(0,0,0,0.3);
  opacity: 0.85;
}

.themeCard.selected {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255,215,0,0.5);
}

.themeCard.locked {
  cursor: not-allowed;
  opacity: 0.55;
}

.themeCard.locked .themeSwatch {
  filter: grayscale(1) brightness(0.5);
}

.themeCard.locked .themeLabel::before {
  content: "🔒 ";
}

#footer {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

#footer button {
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

#footer button:hover { background: rgba(255,255,255,0.14); }

#footNote {
  font-size: 11px;
  opacity: 0.45;
  width: 100%;
  margin-top: 4px;
}

/* -------- celebration overlay -------- */

#celebrateOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(255,46,136,0.35), rgba(0,0,0,0.88));
  animation: overlayPulse 3.2s ease-in-out infinite;
  overflow: hidden;
}

#celebrateOverlay.hidden { display: none; }

/* a slow, smooth breathing glow — no hard strobing/flashing (accessibility) */
@keyframes overlayPulse {
  0%, 100% { background-color: rgba(0,0,0,0.88); }
  50% { background-color: rgba(40,0,30,0.78); }
}

#strobeLayer {
  position: absolute;
  inset: 0;
  z-index: -1;
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

#strobeLayer.active {
  opacity: 0.4;
  animation: strobeCycle 5s ease-in-out infinite;
}

/* slow, continuous color drift — smoothly blended, not a hard on/off flash */
@keyframes strobeCycle {
  0%   { background: #ff2e88; }
  16%  { background: #00e5ff; }
  33%  { background: #ffd700; }
  50%  { background: #7cff00; }
  66%  { background: #ff6a00; }
  83%  { background: #b400ff; }
  100% { background: #ff2e88; }
}

#celebrateContent {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px 30px;
  max-width: 90vw;
}

#celebrateTitle {
  font-size: clamp(32px, 10vw, 72px);
  font-weight: 900;
  background: linear-gradient(90deg, #ffd700, #ff2e88, #00e5ff, #7cff00, #ffd700);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleFlow 0.6s linear infinite, megaPulse 0.28s ease-in-out infinite alternate;
  text-shadow: 0 0 80px rgba(255,255,255,0.6), 0 0 140px rgba(255,46,136,0.5);
}

@keyframes megaPulse {
  from { transform: scale(1) rotate(-2deg); }
  to { transform: scale(1.16) rotate(2deg); }
}

#celebrateSub {
  margin-top: 14px;
  font-size: clamp(14px, 3vw, 20px);
  font-weight: 700;
  color: #fff;
  opacity: 0.9;
}

#celebrateContent button {
  margin: 26px 8px 0;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  color: #1a0a12;
  box-shadow: 0 8px 24px rgba(255,215,0,0.4);
}

#celebrateContent button:hover { filter: brightness(1.1); }

.hidden { display: none !important; }

/* -------- 動画ウィジェット(YouTube埋め込み、動画を見ながらクリックできる) -------- */

#videoWidget {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#videoToggleBtn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(20,16,40,0.85);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#videoToggleBtn:hover { background: rgba(40,32,70,0.9); }

#videoWidget.expanded #videoToggleBtn { display: none; }
#videoWidget:not(.expanded) #videoWidgetPanel { display: none; }

#videoWidgetPanel {
  width: min(320px, 88vw);
  margin-top: 8px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(15,12,35,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}

#videoWidgetHeaderRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

#videoWidgetTitle {
  font-size: 12px;
  font-weight: 800;
  opacity: 0.9;
}

#videoCollapseBtn {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 8px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}
#videoCollapseBtn:hover { background: rgba(255,255,255,0.14); }

#videoInputRow {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

#videoUrlInput {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 12px;
}
#videoUrlInput::placeholder { color: rgba(255,255,255,0.4); }

#videoLoadBtn {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  color: #0d0620;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
#videoLoadBtn:hover { filter: brightness(1.1); }

#videoEmbedWrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

#videoEmbedWrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

#videoEmptyHint {
  font-size: 11px;
  opacity: 0.55;
  text-align: center;
  padding: 0 14px;
  line-height: 1.6;
}

#videoRemoveBtn {
  margin-top: 8px;
  width: 100%;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 11px;
  opacity: 0.7;
  cursor: pointer;
}
#videoRemoveBtn:hover { opacity: 1; background: rgba(255,255,255,0.1); }

@media (max-width: 420px) {
  #statsRow { gap: 6px; grid-template-columns: repeat(2, 1fr); }
  #app { padding: 20px 14px 16px; }
  #videoWidget { right: 8px; bottom: 8px; }
}
