:root{
  --accent: #b9a7e6;
  --accent-dark: #7f67c8;
  --text: #cbbcf2;
  --shadow: rgba(0,0,0,.25);

  --thanks-size: clamp(14px, 4.2vw, 26px);
  --icon-size: clamp(44px, 10vw, 72px);
  --icon-text-size: clamp(14px, 4vw, 22px);

  --icon-gap: 14px;
  --icon-internal-gap: 12px;

  --mail-bottom: 11vh;
  --mail-gap-from-btn: 80px;

  --gate-border: #d99cff;

  /*
    入力ウィンドウ・ランダム一言ウィンドウの背景色。
    透過率 .72 はそのまま、薄い灰色にしています。
  */
  --gate-bg: rgba(225,225,225,.72);

  --gate-text: rgba(120,120,120,.82);
  --gate-input-border: #cfcfcf;
  --gate-input-border-focus: #bdbdbd;
  --gate-input-text: #8f8f8f;

  /*
    ランダム一言ウィンドウ全体の縮小率。
    数字を小さくすると、文字・枠・影ごと小さくなります。
    例：0.80 = もう少し小さい / 0.90 = 少し大きい
  */
  --home-msg-global-scale: 0.82;

  /*
    Thank you for watching と お題箱だけの文字色。
    数字の 0.55 を小さくするとさらに薄く、
    大きくすると濃くなります。
  */
  --sub-text: rgba(203, 188, 242, 0.55);
}

*{
  box-sizing: border-box;
}

html,
body{
  width: 100%;
  min-height: 100%;
  overflow: hidden;
}

html{
  background: #faf7ff;
}

body{
  margin: 0;
  font-family: "DotGothic16", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #faf7ff;
}

/* ホーム画面 */
.stage{
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  background: url("images/bg_pc.png") center / cover no-repeat;
}

.thanks{
  position: absolute;
  top: 4.5vh;
  left: 6vw;
  color: var(--sub-text);
  font-size: var(--thanks-size);
  letter-spacing: .02em;
  user-select: none;
  display: inline-block;
}

.icons{
  position: absolute;
  left: 7vw;
  top: 18vh;
  display: flex;
  flex-direction: column;
  gap: var(--icon-gap);
}

.icon-btn{
  display: inline-flex;
  align-items: center;
  gap: var(--icon-internal-gap);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  color: inherit;
  font-family: inherit;
}

.icon-btn img{
  width: var(--icon-size);
  height: auto;
  display: block;
  filter: drop-shadow(0 6px 10px var(--shadow));
}

.icon-text{
  color: var(--text);
  font-size: var(--icon-text-size);
  letter-spacing: .04em;
  user-select: none;
}

.mail-top-link{
  position: absolute;
  left: 7vw;
  bottom: calc(var(--mail-bottom) + var(--mail-gap-from-btn));
  color: var(--sub-text);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
  cursor: pointer;
}

.mail-top-link:hover{
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.18));
}

.mail-btn{
  position: absolute;
  left: 50%;
  bottom: var(--mail-bottom);
  transform: translateX(-50%);
  width: min(560px, 82vw);
  height: 58px;
  background: rgba(202, 185, 245, 0.45);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  box-shadow: 0 12px 28px var(--shadow);
}

.mail-icon{
  color: rgba(90,60,160,.65);
  font-size: 20px;
}

/* PC配置 */
@media (min-width: 769px){
  .icons{
    left: 9vw;
    top: 22vh;
  }

  .mail-top-link{
    left: 9vw;
  }
}

/* スマホ背景 */
@media (max-width: 768px){
  :root{
    --icon-size: clamp(68px, 14vw, 110px);

    /*
      スマホ時の左端位置。
      アイコン列・お題箱・メールボックスの左端をここで統一します。
    */
    --mobile-left: 4vw;
  }

  .stage{
    background-image: url("images/bg_sp.png");
    background-position: center;
  }

  .icons{
    left: var(--mobile-left);

    /*
      アイコン列全体の上下位置。
      数字を小さくすると上へ、大きくすると下へ移動します。
      例：14vh = さらに上 / 16vh = 少し下
    */
    top: 12vh;
  }

  .icon-btn{
    padding-left: 0;
  }

  .mail-top-link{
    left: var(--mobile-left);
  }

  .mail-btn{
    left: var(--mobile-left);
    transform: none;
    width: calc(100vw - var(--mobile-left) * 2);
  }
}

/* ホーム表示後のランダム一言ウィンドウ */
.home-message{
  position: fixed;
  z-index: 15000;

  display: none;
  align-items: center;
  justify-content: center;

  width: var(--home-msg-width, 54vw);
  min-height: var(--home-msg-height, 118px);

  left: var(--home-msg-left, 50vw);
  top: var(--home-msg-top, 50vh);

  padding: 20px 28px;

  border: 2px solid var(--gate-border);
  background: var(--gate-bg);
  box-shadow: 0 18px 42px rgba(0,0,0,.18);

  color: var(--gate-text);
  font-size: var(--home-msg-font-size, clamp(15px, 3.5vw, 21px));
  line-height: 1.65;
  letter-spacing: .06em;
  font-family: inherit;
  text-align: var(--home-msg-align, center);

  /*
    改行は \n の位置だけを基本にします。
    ボックス幅不足による変な自動改行を減らします。
  */
  white-space: pre;

  transform: scale(var(--home-msg-scale, var(--home-msg-global-scale)));
  transform-origin: top left;

  /*
    リンクつきコメントを押せるようにするため auto にしています。
  */
  pointer-events: auto;
  user-select: none;

  opacity: 0;
}

.home-message.is-show{
  display: flex;
  animation: homeMessageFade 2s ease forwards;
}

/* ランダム一言ウィンドウ内のリンク */
.home-message a{
  color: #4c6fdc;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
  pointer-events: auto;
}

.home-message a:visited{
  color: #4c6fdc;
}

.home-message a:hover{
  filter: brightness(1.08);
}

@keyframes homeMessageFade{
  0%{
    opacity: 0;
  }
  12%{
    opacity: 1;
  }
  82%{
    opacity: 1;
  }
  100%{
    opacity: 0;
  }
}

/* 最初の入力ウィンドウ */
.gate{
  position: fixed;
  inset: 0;
  z-index: 20000;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 100vw;
  height: 100vh;
  height: 100svh;
  height: 100dvh;

  padding: 20px;
  background: rgba(255,255,255,.72);
  overflow: hidden;
}

.gate.is-hidden{
  display: none !important;
}

.gate-window{
  width: min(590px, 70vw);
  height: 260px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;

  padding: 28px 32px;

  border: 3px solid var(--gate-border);
  background: var(--gate-bg);
  box-shadow: 0 18px 42px rgba(0,0,0,.18);

  text-align: center;
}

.gate-text{
  margin: 0;
  color: var(--gate-text);
  font-size: 20px;
  line-height: 1.4;
  letter-spacing: .06em;
}

.gate-input{
  display: block;

  width: 410px;
  max-width: 100%;
  height: 50px;
  margin: 0 auto;

  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;

  border: 2px solid var(--gate-input-border);
  background: rgba(255,255,255,.96);

  color: var(--gate-input-text);
  font-size: 24px;
  font-family: inherit;

  padding: 6px 12px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.08);

  caret-color: #8f8f8f;
}

.gate-input:focus{
  outline: none;
  border-color: var(--gate-input-border-focus);
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,.08),
    0 0 0 1px rgba(180,180,180,.45);
}

.gate-ok{
  display: block;

  width: 150px;
  height: 48px;
  margin: 0 auto;

  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;

  border: 1px solid rgba(205,205,205,.95);
  background: linear-gradient(#ffffff, #e8e8e8);

  color: #999;
  font-size: 18px;
  font-family: inherit;

  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}

.gate-ok:hover{
  filter: brightness(1.03);
}

/* スマホでもPCに近い横長比率 */
@media (max-width: 768px){
  .gate{
    padding: 16px;
  }

  .gate-window{
    width: 72vw;
    height: auto;
    aspect-ratio: 2 / 1;

    min-height: 190px;
    max-height: 260px;

    padding: 22px 24px;
    gap: 14px;
  }

  .gate-text{
    font-size: clamp(14px, 3.4vw, 17px);
  }

  .gate-input{
    width: 78%;
    height: 40px;
    font-size: 18px;
  }

  .gate-ok{
    width: 132px;
    height: 40px;
    font-size: 16px;
  }
}

/* iPhoneなど細い画面 */
@media (max-width: 430px){
  .gate-window{
    width: 76vw;
    aspect-ratio: 1.9 / 1;

    min-height: 180px;
    max-height: 235px;

    padding: 20px 18px;
    gap: 13px;
  }

  .gate-text{
    font-size: 15px;
  }

  .gate-input{
    width: 82%;
    height: 38px;
    font-size: 17px;
    padding: 4px 10px;
  }

  .gate-ok{
    width: 126px;
    height: 38px;
    font-size: 15px;
  }
}

/* とても小さい画面 */
@media (max-width: 360px){
  .gate-window{
    width: 80vw;
    min-height: 170px;
    padding: 18px 14px;
    gap: 11px;
  }

  .gate-text{
    font-size: 14px;
  }

  .gate-input{
    height: 36px;
    font-size: 16px;
  }

  .gate-ok{
    width: 120px;
    height: 36px;
    font-size: 14px;
  }
}

/* 白フェード */
#fade-layer{
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  z-index: 9998;
}

#fade-layer.on{
  opacity: 1;
}

/* ローディング */
#loading{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: none;
  z-index: 9999;
}

#loading.on{
  display: grid;
  place-items: center;
}

.spinner{
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.25);
  border-top-color: rgba(255,255,255,.9);
  animation: spin 1s linear infinite;
}

@keyframes spin{
  to{
    transform: rotate(360deg);
  }
}

/* pixiv確認モーダル */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  z-index: 10000;
}

.modal-backdrop.on{
  display: grid;
  place-items: center;
}

.modal-window{
  width: min(520px, 82vw);
  min-height: 184px;
  background: #f7f3ff;
  border: 2px solid rgba(185,167,230,.75);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.25);
  overflow: hidden;
}

.modal-topbar{
  height: 42px;
  background: rgba(185,167,230,.55);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 10px;
}

.win-btn{
  width: 38px;
  height: 28px;
  border-radius: 10px;
  border: 2px solid rgba(127,103,200,.55);
  background: rgba(255,255,255,.75);
  color: #7f67c8;
  cursor: pointer;
  font-weight: 700;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.win-btn:hover{
  border-color: rgba(185,167,230,.95);
  box-shadow: 0 0 0 5px rgba(185,167,230,.32);
}

.modal-body{
  padding: 22px 20px 18px;
  display: grid;
  gap: 14px;
}

.modal-text{
  color: #7f67c8;
  font-size: 16px;
  line-height: 1.7;
  text-align: center;
}

.modal-actions{
  display: flex;
  justify-content: center;
  gap: 14px;
}

.modal-cancel,
.modal-ok{
  width: min(180px, 34vw);
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(127,103,200,.55);
  cursor: pointer;
  font-size: 16px;
  font-family: "DotGothic16", system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}

.modal-cancel{
  background: rgba(255,255,255,.92);
  color: #7f67c8;
}

.modal-ok{
  background: rgba(185,167,230,.42);
  color: rgba(63,42,122,.70);
  font-weight: 700;
}

.modal-cancel:hover,
.modal-ok:hover{
  border-color: rgba(185,167,230,.98);
  box-shadow: 0 0 0 6px rgba(185,167,230,.36);
}

.modal-cancel:focus-visible,
.modal-ok:focus-visible,
.win-btn:focus-visible{
  outline: none;
  border-color: rgba(185,167,230,.98);
  box-shadow: 0 0 0 6px rgba(185,167,230,.38);
}
