:root {
  color-scheme: light;
  --paper: #f7f4ea;
  --ink: #111111;
  --accent: #f52522;
  --line: #1f1714;
  --muted: #666666;
  --font-sans: "Noto Sans CJK JP", "Noto Sans JP", "Hiragino Sans",
    "Yu Gothic", "YuGothic", "Meiryo", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-sans);
  position: fixed;
  inset: 0;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.app-shell {
  width: 100%;
  height: 100svh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.screen {
  width: min(100%, 430px);
  height: min(720px, calc(100svh - 32px));
  min-height: 0;
  border: 2px solid var(--line);
  display: none;
  background: #ffffff center / cover no-repeat;
  padding: 32px 26px;
  position: relative;
  overflow: hidden;
}

.screen::after {
  content: "\00a9  COLOUR MANNERS";
  position: absolute;
  right: 16px;
  bottom: 12px;
  color: #111111;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  pointer-events: none;
}

.screen-loading::after {
  content: none;
}

.screen.is-active {
  display: flex;
}

.screen-start {
  background-image: url("./bg_main.png");
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
}

.screen-select {
  background-image: url("./bg_sel.png");
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(112px, 19svh, 170px);
  padding-top: clamp(296px, 46svh, 372px);
}

.brand {
  width: 100%;
}

.screen-start .brand,
.screen-select .select-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.logo {
  width: 220px;
  font-weight: 900;
  font-size: 62px;
  line-height: 0.9;
  letter-spacing: 0;
}

.logo span:nth-child(1) {
  color: #284cc9;
}

.logo span:nth-child(2) {
  color: #159c84;
}

.logo span:nth-child(3) {
  color: #ffcf23;
}

.logo small {
  display: block;
  margin-top: 8px;
  color: #231815;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand {
  padding-top: 42px;
}

.brand p {
  margin: 34px 0 0;
  font-size: 28px;
  line-height: 1.35;
  font-weight: 800;
}

.select-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.55;
  font-weight: 800;
  text-align: center;
}

.pick-button,
.primary-button,
.secondary-button,
.secondary-link {
  min-height: 56px;
  border: 3px solid #000000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  flex: 0 0 auto;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}

.file-input {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

.pick-button,
.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.pick-button {
  width: clamp(112px, 34vw, 142px);
  height: auto;
  min-height: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  background: transparent url("./btn_add.png") center / contain no-repeat;
  color: var(--line);
  padding: 0;
  font-size: 48px;
  line-height: 1;
  border: 0;
  color: transparent;
  overflow: hidden;
}

.primary-button {
  width: min(100%, 190px);
  height: 56px;
}

.primary-button.small {
  width: auto;
  min-width: 128px;
  height: 52px;
  font-size: 18px;
}

.screen-start .primary-button {
  align-self: center;
}

#startButton,
#makeButton,
#saveButton,
.screen-result .primary-button.small {
  width: min(100%, clamp(218px, 60vw, 250px));
  height: auto;
  min-height: 0;
  aspect-ratio: 724 / 241;
  border: 0;
  color: transparent;
  overflow: hidden;
  padding: 0;
  background: transparent center / contain no-repeat;
  text-indent: 100%;
}

#startButton {
  background-image: url("./btn_start.png");
}

#makeButton {
  background-image: url("./btn_make.png");
}

#saveButton,
.screen-result .primary-button.small {
  background-image: url("./btn_save.png");
}

.secondary-button,
.secondary-link {
  width: 100%;
  border-width: 2px;
  background: #ffffff;
  color: var(--ink);
  font-size: 16px;
}

.screen-loading {
  background: #fbf8dc;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(14px, 2.4svh, 28px);
  padding-top: clamp(132px, 24svh, 210px);
}

.loader-ring {
  width: min(70vw, 42svh, 300px);
  height: auto;
  aspect-ratio: 778 / 790;
  border-radius: 50%;
  background: transparent;
  border: 0;
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
}

.loading-art {
  position: absolute;
  inset: 0;
  background: transparent url("./loading.png") center / contain no-repeat;
  animation: loading-spin 2.4s linear infinite;
  transform: translateZ(0);
  transform-origin: 50% 50%;
  will-change: transform;
  z-index: 0;
  pointer-events: none;
}

.loading-percent {
  font-size: clamp(26px, 4.2svh, 34px);
  font-weight: 900;
  white-space: nowrap;
  color: #4b260d;
  position: relative;
  z-index: 1;
  line-height: 1;
  text-shadow:
    0 3px 0 #ffffff,
    3px 0 0 #ffffff,
    0 -3px 0 #ffffff,
    -3px 0 0 #ffffff,
    0 8px 12px rgba(111, 91, 31, 0.24);
}

.loading-message {
  max-width: 260px;
  min-height: 0;
  color: #4b260d;
  font-size: clamp(18px, 3svh, 24px);
  font-weight: 900;
  line-height: 1.42;
  text-shadow:
    0 3px 0 #ffffff,
    3px 0 0 #ffffff,
    0 -3px 0 #ffffff,
    -3px 0 0 #ffffff,
    0 8px 12px rgba(111, 91, 31, 0.24);
}

@keyframes loading-spin {
  from {
    transform: translateZ(0) rotate(0deg);
  }

  to {
    transform: translateZ(0) rotate(360deg);
  }
}

.screen-result {
  background: #fbf8dc;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(10px, 2svh, 22px);
  padding-top: clamp(12px, 2.6svh, 28px);
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.screen-result::after {
  right: 10px;
  bottom: max(6px, env(safe-area-inset-bottom, 0px));
  font-size: 10px;
}

.preview {
  width: min(100%, 42svh, 292px);
  aspect-ratio: 9 / 16;
  background: #d5d5d5;
  border: 7px solid #ff75a6;
  border-radius: 5px;
  box-shadow: 0 12px 24px rgba(121, 96, 36, 0.22);
  object-fit: contain;
}

.actions {
  width: min(100%, 320px);
  display: grid;
  gap: clamp(5px, 0.9svh, 8px);
  justify-items: center;
}

.status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  width: 100%;
  line-height: 1.4;
}

.screen-select .status {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 44px;
  width: auto;
}

.loading-cancel {
  width: min(100%, 220px);
  min-height: 48px;
}

@media (max-width: 430px) {
  .app-shell {
    padding: 0;
  }

  .screen {
    width: 100%;
    height: 100svh;
    min-height: 0;
    border: 0;
  }
}

@media (max-height: 700px) {
  .screen {
    padding: 20px 22px;
  }

  .screen::after {
    bottom: 8px;
    font-size: 10px;
  }

  .screen-select {
    gap: clamp(84px, 16svh, 126px);
    padding-top: clamp(250px, 43svh, 304px);
  }

  .pick-button {
    width: clamp(92px, 25svh, 118px);
  }

  #startButton,
  #makeButton,
  #saveButton,
  .screen-result .primary-button.small {
    width: min(100%, 220px);
  }

  .screen-result {
    gap: 8px;
    padding-top: 12px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .preview {
    width: min(100%, 39svh, 250px);
    border-width: 5px;
  }

  .secondary-button,
  .secondary-link {
    min-height: 40px;
    font-size: 14px;
  }

  .screen-result .secondary-button,
  .screen-result .secondary-link {
    min-height: 38px;
  }
}
