html,
body {
  margin: 0;
  padding: 0;
  font-family: "Edu NSW ACT Hand Pre", Kiwi Maru;
  overflow: hidden;
  background-color: black; /* margin concealment except for bottom */
  /* 画面向き切り替え時のレイアウト安定化 */
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
}

h1 {
  color: aliceblue;  
  font-size: clamp(1.5rem, 6vw, 2rem);
  /* opacity: 0; */
}

p {
  color: aliceblue;
  line-height: 1.1;
  font-size: clamp(0.8rem, 3vw, 1.2rem);
}

.grid-area {
  position: relative;  
  display: grid;
  height: 100vh;
  grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr);
  grid-template-columns: 1fr;
  /* 横画面対応 */
  width: 100vw;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
  /* 画面向き切り替え時の安定化 */
  transition: none !important;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.title-area {
  grid-row: 1;
  grid-column: 1;
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;  
  flex-direction: column; /* default is vertical alignment */
  align-items: center;
  justify-content: center;
  background-color: black;
}

.circles-area {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  width: 100%;
  height: 100%;
  background-color: black;
  /* .boxを適切に配置してぴったり収める */
  align-items: center;
  justify-content: center;
  gap: 0px;
  padding: 0px;
  box-sizing: border-box;
  /* 横画面対応 */
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

.box {
  display: flex;
  position: relative;
  /* 親要素の高さに合わせた正方形 */
  width: auto;
  height: 100%;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  aspect-ratio: 1;
  overflow: hidden;
  /* 横画面対応 */
  max-width: 100%;
  max-height: 100%;
}

.circle-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);  
  grid-template-rows: repeat(4, 1fr);  
  gap: 10px;
  /* .box内にぴったり収める設定 */
  width: 100%;
  height: 100%;
  container-type: inline-size;
  aspect-ratio: 1;
  padding: 10px 0px 0px 10px;
  box-sizing: border-box;
  /* 親要素(.box)内に完全に収める */
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.circle-blank {
  border-radius: 50%;  
  /* .boxにぴったり合わせる設定 */
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 1;
  box-sizing: border-box;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.circle-img {
  border-radius: 50%;
  background-color: rgba(255, 214, 0, 0.16);
  aspect-ratio: 1;
  background-size: contain;      
  background-position: center;   
  background-repeat: no-repeat; 
  overflow: hidden;
  /* .boxにぴったり合わせる設定 */
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.footer-area {
  grid-row: 3;
  grid-column: 1;
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0; 
  align-items: center; 
  justify-content: center;
  background-color: black;
}

@media (min-aspect-ratio: 4/3) and (orientation: portrait) {
  .title-area {
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: nowrap;
  }
}

/* pタグの文字が途切れる場合にh1の右側に表示 */
@media (max-width: 600px) {
  .title-area {
    flex-direction: row;
    gap: 0.3rem;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
  }
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
  }
}

/* タブレット・中画面対応 */
@media (max-width: 768px) {
  .title-area {
    flex-direction: row;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
  }
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
  }
  
  .circles-area {
    padding: 0;
  }
  
  .box {
    max-width: 100%;
    max-height: 100%;
  }
}

/* 極小画面では縦並びに戻す */
@media (max-width: 400px) {
  .title-area {
    flex-direction: column;
    gap: 0.2rem;
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

@media (max-aspect-ratio: 3/4) {
  .title-area {
    flex-direction: column;
    gap: 0.2rem;
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p {
    margin: 0.2rem 0;
    white-space: normal;
  }
}

@media (max-aspect-ratio: 3/1) {
  .title-area {
    flex-direction: row;
    /* gap: 0.2rem; */
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p {
    margin: 0.2rem 0;
    white-space: normal;
  }
}

@media (max-aspect-ratio: 2/1) {
  .title-area {
    flex-direction: column;
    gap: 0.2rem;
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p {
    margin: 0.2rem 0;
    white-space: normal;
  }
}


@media (max-width: 300px) {
  .title-area {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    justify-content: flex-start;
  }
  .title-area h1,
  .title-area p,
  .footer-area p {
    margin: 0; /* reset top and bottom margins */
    white-space: nowrap; /* prevent text from wrapping (if necessary) */
    font-size: clamp(0.1rem, 4vw, 1.5rem);
  }
}

@media (max-width: 150px) {
  .title-area,
  .footer-area {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    justify-content: flex-start;
  }
  .title-area h1,
  .title-area p,
  .footer-area p {
    margin: 0;
    white-space: nowrap;
    font-size: clamp(0.1rem, 2vw, 1.5rem);
  }
}

@media (max-height: 400px) {
  .title-area {
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p,
  .footer-area p {
    margin: 0;
    white-space: nowrap;
    font-size: clamp(0.5rem, 2vw, 1.5rem);
  }
}

@media (max-height: 180px) {
  .title-area {
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
  }
  .title-area h1,
  .title-area p,
  .footer-area p {
    margin: 0;
    white-space: nowrap;
    font-size: clamp(0.1rem, 0.5vw, 1.5rem);
  }
}

/* ===== 横画面対応 - .boxの子要素を適切に収める ===== */

/* 横画面（スマホ・タブレット）対応 */
@media (orientation: landscape) {
  html, body {
    width: 100vw !important;
    height: 100vh !important;
  }
  
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden;
    transform: translateZ(0);
  }
  
  .title-area {
    /* 横画面では文字を横並びに */
    flex-direction: row !important;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
  }
  
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: nowrap;
  }
  
  .circles-area {
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100% !important;
    height: 100% !important;
  }
  
  .box {
    /* 横画面でも正方形を維持 */
    width: auto;
    height: 100%;
    aspect-ratio: 1;
    overflow: hidden;
  }
  
  .circle-container {
    /* 横画面でも.box内に完全に収める */
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
}

/* 横長画面（アスペクト比 4:3以上）対応 */
@media (min-aspect-ratio: 4/3) and (orientation: landscape) {
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr);
    max-height: 100vh;
    overflow: hidden;
  }
  
  .title-area {
    /* 横長画面では文字を横並びに */
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
  }
  
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: nowrap;
  }
  
  .circles-area {
    /* 横長画面でも中央配置を維持 */
    align-items: center;
    justify-content: center;
    max-height: 100%;
    overflow: hidden;
  }
  
  .box {
    /* 横長画面でも高さベースの正方形 */
    width: auto;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 1;
    overflow: hidden;
  }
  
  .circle-container {
    /* 横長画面でも.box内に完全に収める */
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
  }
}

/* 超横長画面（アスペクト比 16:9以上）対応 */
@media (min-aspect-ratio: 16/9) {
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr);
    height: 100vh;
    max-width: 100vw;
    overflow: hidden;
  }
  
  .circles-area {
    /* 超横長画面でも適切に配置 */
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  
  .box {
    /* 超横長画面でも正方形維持 */
    width: auto;
    height: 100%;
    aspect-ratio: 1;
    overflow: hidden;
  }
  
  .circle-container {
    /* 超横長画面でも.box内に収める */
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
}

/* ===== スマホ画面向き切り替え時の安定化 ===== */

/* iOS Safari向けの安定化 */
@supports (-webkit-touch-callout: none) {
  html, body {
    position: fixed !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
  }
  
  .grid-area {
    position: relative !important;
    width: 100vw !important;
    height: 100vh !important;
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
  }
}

/* Android向けの安定化 */
@media screen and (orientation: landscape) and (max-device-width: 768px) {
  .grid-area {
    width: 100vw !important;
    height: 100vh !important;
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
  }
  
  .circles-area {
    width: 100% !important;
    height: 100% !important;
  }
}

@media screen and (orientation: portrait) and (max-device-width: 768px) {
  .grid-area {
    width: 100vw !important;
    height: 100vh !important;
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
  }
}

/* ===== 画面向き切り替え時の強制リフロー対策 ===== */

/* 全ての画面向き変更で強制的にレイアウトを再計算 */
@media (orientation: portrait) {
  html, body, .grid-area, .title-area, .circles-area, .footer-area, .box, .circle-container, .circle-blank, .circle-img {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
    width: 100vw !important;
    height: 100vh !important;
    display: grid !important;
  }
  
  .circles-area {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* 画面サイズに関係なく常にグリッド比率を維持 */
@media screen {
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
  }
}

/* 特にiOSのSafari向け */
@supports (-webkit-appearance: none) {
  .grid-area {
    position: relative !important;
    display: grid !important;
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
    width: 100vw !important;
    height: 100vh !important;
  }
}

/* デスクトップ・大画面対応 */
@media (min-width: 769px) {
  .title-area {
    flex-direction: row;
    gap: 1rem;
    align-items: center;
    justify-content: center;
  }
  
  .title-area h1,
  .title-area p {
    margin: 0;
    white-space: nowrap;
  }
  
  .circles-area {
    gap: 0px;
    padding: 0;
  }
  
  .box {
    max-width: none;
    max-height: 100%;
  }
  
  h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
  }
  
  p {
    font-size: clamp(1rem, 2vw, 1.4rem);
  }
}

/* ===== orientationchange対応の緊急CSS ===== */

/* 画面向き切り替え時の強制スタイル適用（リロード後と同じ状態） */
@media (orientation: landscape) {
  html, body {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    top: 0 !important;
    left: 0 !important;
  }
  
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
    grid-template-columns: 1fr !important;
    width: 100vw !important;
    height: 100vh !important;
    display: grid !important;
    position: relative !important;
    overflow: hidden !important;
    transform: translateZ(0) !important;
    box-sizing: border-box !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
  }
  
  .title-area {
    flex-direction: row !important;
    gap: 0.5rem !important;
    align-items: center !important;
    justify-content: center !important;
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    grid-row: 1 !important;
    grid-column: 1 !important;
    background-color: black !important;
    min-height: 0 !important;
    min-width: 0 !important;
  }
  
  .circles-area {
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    gap: 0px !important;
    padding: 0px !important;
    grid-row: 2 !important;
    grid-column: 1 !important;
    background-color: black !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
  
  .footer-area {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: black !important;
    grid-row: 3 !important;
    grid-column: 1 !important;
  }
  
  .box {
    width: auto !important;
    height: 100% !important;
    aspect-ratio: 1 !important;
    overflow: hidden !important;
    display: flex !important;
    position: relative !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
  
  .circle-container {
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-template-rows: repeat(4, 1fr) !important;
    gap: 10px !important;
    aspect-ratio: 1 !important;
    container-type: inline-size !important;
    padding: 10px 0px 0px 10px !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}

@media (orientation: portrait) {
  html, body {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    top: 0 !important;
    left: 0 !important;
  }
  
  .grid-area {
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
    grid-template-columns: 1fr !important;
    width: 100vw !important;
    height: 100vh !important;
    display: grid !important;
    position: relative !important;
    overflow: hidden !important;
    transform: translateZ(0) !important;
    box-sizing: border-box !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    min-width: 100vw !important;
    min-height: 100vh !important;
  }
  
  .title-area {
    flex-direction: column !important;
    gap: 0.2rem !important;
    align-items: center !important;
    justify-content: center !important;
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    grid-row: 1 !important;
    grid-column: 1 !important;
    background-color: black !important;
    min-height: 0 !important;
    min-width: 0 !important;
  }
  
  .circles-area {
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    gap: 0px !important;
    padding: 0px !important;
    grid-row: 2 !important;
    grid-column: 1 !important;
    background-color: black !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
  
  .footer-area {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: black !important;
    grid-row: 3 !important;
    grid-column: 1 !important;
  }
  
  .box {
    width: auto !important;
    height: 100% !important;
    aspect-ratio: 1 !important;
    overflow: hidden !important;
    display: flex !important;
    position: relative !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
  
  .circle-container {
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    grid-template-rows: repeat(4, 1fr) !important;
    gap: 10px !important;
    aspect-ratio: 1 !important;
    container-type: inline-size !important;
    padding: 10px 0px 0px 10px !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}

/* 特にiOS Safari向けの緊急対応 */
@supports (-webkit-touch-callout: none) {
  .grid-area {
    position: relative !important;
    display: grid !important;
    grid-template-rows: minmax(0, 2fr) minmax(0, 6fr) minmax(0, 2fr) !important;
    width: 100vw !important;
    height: 100vh !important;
  }
}

/* 簡潔な向き対応 */
@media (orientation: landscape) {
  .title-area {
    flex-direction: row !important;
  }
}

@media (orientation: portrait) {
  .title-area {
    flex-direction: column !important;
  }
}
.circle-blank,
  .circle-img {
    border-radius: 50% !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    aspect-ratio: 1 !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }
