:root {
  color-scheme: dark;
  --ink: #fff;
  --bg: #000;
  --muted: #bdbdbd;
  --font: Inter, sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  padding: clamp(14px, 4vw, 48px);
  color: var(--ink);
  background: var(--ink);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
a {
  color: inherit;
}

/* ---------- 3D シーン ---------- */
.scene {
  max-width: 768px;
  width: 100%;
  margin: auto;
  perspective: 1200px;
}

/* .card は「回転する入れ物」だけ */
.card {
  position: relative;
  width: 100%;
  aspect-ratio: 2048/1272;
  min-height: 380px;
  transform-style: preserve-3d;
  will-change: transform;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.card:active {
  cursor: grabbing;
}

/* 見た目（背景・枠・余白）は面ごとに持たせる */
.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
  border: 1px solid #292929;
  border-radius: 3px;
  box-shadow: 0 12px 50px 5px #0009;
  padding: clamp(12px, 5.1vw, 54px) clamp(10px, 5.1vw, 40px);
  display: flex;
  justify-content: space-between;
  column-gap: 5%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face.back {
  transform: rotateY(180deg);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.back-mark {
  width: min(34%, 200px);
  aspect-ratio: 1;
  margin-bottom: 4%;
}
.back-name {
  margin: 0;
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 750;
  line-height: 1;
}
.back-role {
  margin: 2% 0 0;
  font-size: clamp(12px, 2vw, 18px);
  font-weight: 700;
  color: var(--muted);
}

/* ---------- 表面レイアウト（PC：769px以上） ---------- */
.left,
.right {
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.brand-word {
  width: min(80%, 200px);
  aspect-ratio: 3.25 / 1;
}
.mark-slot {
  width: min(56%, 280px);
  aspect-ratio: 1;
  align-self: center;
  margin-bottom: 40px;
}

.left {
  width: 40%;
  padding-top: 40px;
}

.right {
  align-items: center;
}
.role {
  font-size: clamp(16px, 2.8vw, 20px);
  font-weight: 750;
  line-height: 1;
  margin: 0 0 2%;
}
.rishi-word {
  margin-bottom: 6%;
}

.rishi-word .name {
  font-size: clamp(48px, 7.8vw, 64px);
  font-weight: 750;
  line-height: 1;
}

.qr-frame {
  width: 145px;
  aspect-ratio: 1;
  border: 2px solid #fff;
  display: grid;
  place-items: center;
  padding: 5%;
  background: #fff;
  background-image: url(../img/rishi-card-qr.svg);
  background-repeat: no-repeat;
  background-size: cover;
}
#qr {
  width: 100%;
  height: 100%;
  display: block;
}
.qr-fallback {
  color: #111;
  font-size: 12px;
  text-align: center;
}
.bottom-left {
  display: flex;
  justify-content: center;
  gap: 20px;
  align-items: center;
  min-width: 0px;
  width: 100%;
}
.social {
  display: grid;
  place-items: center;
  width: clamp(30px, 5vw, 62px);
  height: clamp(30px, 5vw, 62px);
  text-decoration: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.social:hover {
  opacity: 0.72;
  transform: translateY(-3px);
}
.social img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.social-fallback {
  font-size: clamp(26px, 4vw, 48px);
  font-weight: 500;
  line-height: 1;
  width: min(45px, 4.5vw);
  height: min(45px, 4.5vw);
}

/* ---------- 連絡先ボタン ---------- */
.bottom-right {
  align-self: stretch;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6%;
}
.contact-btn {
  border: 1px solid #fff;
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 8px 18px;
  font:
    700 clamp(12px, 2.5vw, 16px) / 1 Inter,
    system-ui,
    sans-serif;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
}
.contact-btn:hover {
  background: #fff;
  color: #000;
}

.asset-slot {
  position: relative;
  display: block;
  place-items: center;
}
.asset-slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}

/* ---------- 下部ボタン ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
}
.action {
  border: 1px solid #666;
  background: #111;
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  width: 200px;
  margin: auto;
  font:
    600 13px/1.2 system-ui,
    sans-serif;
  cursor: pointer;
  text-decoration: none;
}
.action:hover {
  background: #252525;
}
.hint {
  color: #888;
  font-size: 12px;
  text-align: center;
  margin: 12px 0 0;
}

/* ---------- スマホ・タブレット（768px以下）：gridレイアウト ---------- */
@media (max-width: 768px) {
  body {
    padding: 14px;
  }
  .card {
    min-height: 0;
    aspect-ratio: 1 / 1.3;
  }

  /* 表面だけgrid。裏面（flex）には影響しない */
  .face.front {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "mark brand" /* 1行目：左が mark、右が brand */
      "right right" /* 2行目：左右ぶち抜きで right */
      "social social"; /* 3行目：左右ぶち抜きで social */
    justify-items: center;
    align-items: center;
    row-gap: 3%;
    column-gap: 4%;
    padding: 10%;
  }

  /* .left のラッパーを無効化し、中身をgridに直接参加させる */
  .left {
    display: contents;
  }

  .brand-word {
    grid-area: brand;
    width: 100%;
    max-width: 200px;
    margin: 0;
    position: relative;
    top: 0;
    left: 0;
    transform: translateX(-40%);
  }
  .mark-slot {
    grid-area: mark;
    width: clamp(20px, 7vw, 30px);
    margin: auto;
    justify-self: start;
    align-self: center;
  }

  .right {
    grid-area: right;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .role {
    font-size: clamp(12px, 3.3vw, 19px);
    margin: 0 0 2%;
  }
  .rishi-word {
    width: auto;
    margin-bottom: 3%;
  }
  .rishi-word .name {
    font-size: clamp(30px, 9vw, 44px);
  }
  .qr-frame {
    width: clamp(90px, 30vw, 130px);
    border-width: 1px;
    padding: 4%;
  }
  .bottom-right {
    margin-top: 10%;
  }
  .contact-btn {
    padding: 7px 12px;
  }

  .bottom-left {
    grid-area: social;
    width: 100%;
    gap: clamp(15px, 3vw, 20px);
    padding-left: 0;
  }
  .social {
    width: clamp(25px, 7vw, 38px);
    height: clamp(25px, 7vw, 38px);
  }
  .social-fallback {
    width: clamp(25px, 7vw, 38px);
    height: clamp(25px, 7vw, 38px);
  }

  .actions {
    margin-top: 16px;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .social {
    transition: none !important;
  }
}
