/* ==========================================================================
   Reset (id/要素セレクタの使用はここのみ許可)
   ========================================================================== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --icg-color-primary: #ffe100;
  --icg-color-primary-dark: #d4b043;
  --icg-color-black: #1e1e1e;
  --icg-color-white: #ffffff;
  --icg-color-gray-bg: #f4f4f4;
  --icg-color-gray-border: #cfcfcf;
  --icg-color-gray-text: #8a8a8a;
  --icg-radius-lg: 20px;
  --icg-radius-md: 14px;
  --icg-radius-sm: 10px;
  --icg-shadow-btn: 0 4px 0 rgba(0, 0, 0, 0.8);
}

body {
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--icg-color-primary-dark);
  color: var(--icg-color-black);
}

.icg {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

/* ==========================================================================
   icg-intro
   ========================================================================== */
.icg-intro {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icg-intro__panel {
  border-radius: var(--icg-radius-lg);
  padding: 32px 24px;
  text-align: center;
}

.icg-intro__lead {
  font-size: 14px;
  margin: 0 0 20px;
}

.icg-intro__terms-block {
  margin: 50px 0;
}

.icg-intro__terms-heading {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 10px;
}

.icg-intro__terms {
  max-height: 240px;
  overflow-y: auto;
  text-align: left;
  background: var(--icg-color-gray-bg);
  padding: 12px;
  margin: 0 0 16px;
}

.icg-intro__terms-item {
  font-size: 12px;
  line-height: 1.6;
  color: #444;
  padding-left: 1.1em;
  position: relative;
  margin: 0 0 10px;
}

.icg-intro__terms-item::before {
  content: "・";
  position: absolute;
  left: 0;
}

.icg-intro__terms-item:last-child {
  margin-bottom: 0;
}

.icg-intro__agree {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 16px;
  cursor: pointer;
}

.icg-intro__agree-checkbox {
  /* 埋め込み先サイトのCSSでinputにappearance:noneが指定されていても
     見た目が崩れないよう、ネイティブ描画に頼らず完全に自前で描画する */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  border: 2px solid var(--icg-color-black);
  border-radius: 4px;
  background-color: var(--icg-color-white);
  position: relative;
  cursor: pointer;
}

.icg-intro__agree-checkbox:checked {
  background-color: var(--icg-color-primary);
}

.icg-intro__agree-checkbox:checked::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border-style: solid;
  border-color: var(--icg-color-black);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.icg-intro__agree-checkbox:focus-visible {
  outline: 2px solid var(--icg-color-primary-dark);
  outline-offset: 2px;
}

.icg-intro__agree-label {
  font-size: 13px;
  font-weight: 700;
}

.icg-intro__start {
  width: 100%;
}

.icg-intro__howto {
  width: 100%;
  margin-top: 10px;
}

/* ==========================================================================
   icg-btn (共通ボタン)
   ========================================================================== */
.icg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--icg-radius-sm);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.icg-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.icg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.icg-btn--square {
  width: 56px;
  height: 56px;
  background: var(--icg-color-primary);
  box-shadow: var(--icg-shadow-btn);
  border: 2px solid #000;
}

.icg-btn--cta {
  width: 100%;
  background: var(--icg-color-primary);
  padding: 16px;
  font-size: 15px;
  border-radius: var(--icg-radius-md);
  box-shadow: var(--icg-shadow-btn);
}

.icg-btn--secondary {
  width: 100%;
  background: var(--icg-color-white);
  border: 2px solid var(--icg-color-gray-border);
  padding: 14px;
  font-size: 14px;
  border-radius: var(--icg-radius-md);
  color: #555;
  margin-top: 10px;
}

.icg-btn--howto {
  width: 100%;
  background: var(--icg-color-gray-bg);
  border: 2px solid var(--icg-color-gray-border);
  padding: 14px;
  font-size: 14px;
  border-radius: var(--icg-radius-md);
  color: #555;
}

.icg-btn__icon {
  width: 24px;
  height: 24px;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ==========================================================================
   icg-app
   ========================================================================== */
.icg-app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0 20px;
  background: var(--icg-color-white);
}

.icg-app__header {
  text-align: center;
}

.icg-app__title {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
}

.icg-app__preview {
  display: flex;
  justify-content: center;
}

.icg-app__select {
  padding: 0;
}

.icg-app__next {
  margin-top: 4px;
}

.icg-app__download {
  padding: 0 20px;
}

.icg-app__howto {
  padding: 0 20px;
}

@media (min-width: 700px) {
  .icg-app__download {
    padding: 0 40px;
  }

  .icg-app__howto {
    padding: 0 40px;
  }
}

/* ==========================================================================
   icg-canvas
   ========================================================================== */
.icg-canvas {
  width: 260px;
  height: 260px;
  /*
  border: 2px solid var(--icg-color-black);
  border-radius: var(--icg-radius-md);
  */
  overflow: hidden;
  background: var(--icg-color-white);
}

/* fabric.js が生成するラッパー要素。id/要素セレクタ禁止ルールの対象外
   (Fabric.jsが自動付与する固有クラス名のため) */
.icg-canvas .canvas-container {
  width: 100% !important;
  height: 100% !important;
}

.icg-canvas .lower-canvas,
.icg-canvas .upper-canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ==========================================================================
   icg-select (フレーム/ロゴ/スタンプ/アップロードの選択エリア)
   ========================================================================== */
.icg-select {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 0 10px;
  scrollbar-width: thin;
  margin: 0 10px;
}

@media ( min-width: 700px ) {
  .icg-select {
    margin: 0 40px;
  }
}

.icg-select__item {
  flex: 0 0 auto;
  position: relative;
}

.icg-select__item--upload {
  flex: 1 1 100%;
}

.icg-select__thumb {
  width: 72px;
  height: 72px;
  border: 2px solid var(--icg-color-black);
  border-radius: var(--icg-radius-sm);
  background: var(--icg-color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  position: relative;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.icg-select__thumb--none {
  color: var(--icg-color-gray-text);
}

.icg-select__thumb.is-selected {
  border-color: var(--icg-color-primary);
}

.icg-select__thumb.is-active {
  box-shadow: 0 0 0 2px inset var(--icg-color-primary-dark);
}

.icg-select__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.icg-select__none-label {
  font-size: 12px;
  font-weight: 700;
}

.icg-select__remove {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--icg-color-black);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icg-select__remove-icon {
  width: 16px;
  height: 16px;
}

.icg-select__upload-input {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
}

/* ==========================================================================
   icg-ui (コントロールエリア)
   ========================================================================== */
.icg-ui {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 10px;
}

@media ( min-width: 700px ) {
  .icg-ui {
    padding: 0 40px 10px;
  }
}


.icg-ui__side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* icg-translate */
.icg-translate {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  column-gap: 8px;
  row-gap: 10px;
  align-items: center;
}

.icg-translate__btn--left {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.icg-translate__btn--right {
  grid-column: 3;
  grid-row: 1 / span 2;
}

.icg-translate__vertical {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* icg-date-toggle */
.icg-date-toggle {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: center;
}

.icg-date-toggle__btn {
  flex: 0 1 140px;
  padding: 14px 10px;
  background: var(--icg-color-white);
  border: 2px solid var(--icg-color-gray-border);
  border-radius: var(--icg-radius-md);
  font-size: 14px;
  color: #666;
}

.icg-date-toggle__btn[aria-pressed="true"] {
  background: var(--icg-color-primary);
  border-color: var(--icg-color-primary-dark);
  color: var(--icg-color-black);
}

/* icg-rotate / icg-scale */
.icg-rotate,
.icg-scale {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   icg-scenes (画面遷移エリア)
   ========================================================================== */
.icg-scenes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--icg-color-gray-bg);
  padding: 4px 10px;
}

.icg-scenes__btn {
  padding: 6px 4px;
  font-size: 14px;
  line-height: 1.2;
  color: #666;
  text-align: center;
}

.icg-scenes__btn.is-current {
  background: var(--icg-color-primary);
  color: var(--icg-color-black);
  border-radius: 100px;
}

.icg-scenes__btn:disabled {
  cursor: default;
  opacity: 1;
}

/* ==========================================================================
   icg-download
   ========================================================================== */
.icg-download {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px 32px;
  background: var(--icg-color-white);
}

@media ( min-width: 700px ) {
  .icg-download {
    padding: 24px 40px 32px;
  }
}

.icg-download__header {
  text-align: center;
}

.icg-download__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.icg-download__preview {
  display: flex;
  justify-content: center;
}

.icg-download__image {
  width: 260px;
  height: 260px;
  border: 2px solid var(--icg-color-black);
  object-fit: contain;
  background: var(--icg-color-white);
}

.icg-download__note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--icg-color-gray-text);
  text-align: center;
  margin: -4px 0 0;
}

/* ==========================================================================
   icg-howto (操作方法モーダル)
   ========================================================================== */
.icg-howto {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.icg-howto__window {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  background: var(--icg-color-white);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
}

@media (min-width: 700px) {
  .icg-howto__window {
    max-width: 600px;
  }
}

.icg-howto__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--icg-color-black);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icg-howto__close-icon {
  width: 16px;
  height: 16px;
}

.icg-howto__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
}

.icg-howto__body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.icg-howto__capture {
  width: 100%;
  border: 1px solid var(--icg-color-gray-border);
  border-radius: var(--icg-radius-sm);
}

.icg-howto__section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.icg-howto__heading {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.icg-howto__text {
  font-size: 13px;
  line-height: 1.7;
  color: #444;
  margin: 0;
}

.icg-howto__emphasis {
  font-weight: 700;
  color: var(--icg-color-primary-dark);
}

/* ==========================================================================
   Responsive (PC幅)
   ========================================================================== */
@media (min-width: 700px) {
  .icg {
    max-width: 560px;
    min-height: auto;
    margin: 30px auto 0;
    overflow: hidden;
  }

  .icg-intro {
    min-height: auto;
  }

  .icg-intro__lead {
    font-size: 18px;
  }

  .icg-intro__terms-heading {
    font-size: 24px;
  }

  .icg-intro__terms-item {
    font-size: 16px;
  }

  .icg-intro__agree-label {
    font-size: 17px;
  }

  .icg-btn--cta {
    font-size: 20px;
  }

  .icg-btn--secondary {
    font-size: 18px;
  }

  .icg-btn--howto {
    font-size: 18px;
  }

  .icg-app__title {
    font-size: 42px;
  }

  .icg-canvas {
    width: 100%;
    height: auto;
    max-width: 400px;
    aspect-ratio: 1 / 1;
  }

  .icg-select__none-label {
    font-size: 16px;
  }

  .icg-date-toggle__btn {
    font-size: 18px;
  }

  .icg-scenes__btn {
    font-size: 18px;
  }

  .icg-download__title {
    font-size: 23px;
  }

  .icg-download__image {
    width: 100%;
    height: auto;
    max-width: 400px;
    aspect-ratio: 1 / 1;
  }

  .icg-download__note {
    font-size: 16px;
  }

  .icg-howto__title {
    font-size: 24px;
  }

  .icg-howto__heading {
    font-size: 18px;
  }

  .icg-howto__text {
    font-size: 14px;
  }
}
