:root {
  color-scheme: dark;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans CJK JP", system-ui, sans-serif;
  background: #091b1b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(ellipse at 50% 19%, #284d3f 0%, #132a29 43%, #081718 100%);
}

.stage {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: min(calc(100vw - var(--safe-left) - var(--safe-right)), calc((100vh - var(--safe-top) - var(--safe-bottom)) * 0.5625));
  width: min(calc(100vw - var(--safe-left) - var(--safe-right)), calc((100dvh - var(--safe-top) - var(--safe-bottom)) * 0.5625));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background-color: #234e52;
  background-image:
    linear-gradient(180deg, #12221510 4%, transparent 27%, #162a291a 53%, transparent 79%, #071b14a8 100%),
    url("./assets/temple.webp"),
    linear-gradient(180deg, #278cb9 0%, #388a8f 35%, #2e544c 64%, #56472f 100%);
  background-position: center;
  background-size: cover;
  box-shadow: 0 0 62px #0008;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.controls {
  position: absolute;
  inset: auto 0 2.7cqw;
  display: grid;
  justify-items: center;
  gap: 2.7cqw;
  pointer-events: none;
}

.color-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(44px, 1fr));
  gap: 2.4cqw;
  width: 73%;
}

.button {
  --rim: #eeac41;
  position: relative;
  isolation: isolate;
  min-width: 44px;
  min-height: 44px;
  padding: .38em .5em .47em;
  border: max(2px, .46cqw) solid var(--rim);
  border-radius: max(9px, 2cqw);
  color: #fff6dc;
  font-family: inherit;
  font-size: clamp(14px, 3.6cqw, 46px);
  font-weight: 900;
  line-height: 1.16;
  white-space: nowrap;
  text-shadow: 0 1px 2px #3d180d, 0 0 .12em #2b0509;
  box-shadow: 0 1cqw 1.7cqw #081413b8, inset 0 0 0 .32cqw #3519099c, inset 0 .48cqw .55cqw #fff3b470;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.button:focus-visible { outline: 2px solid #fff7b8; outline-offset: 3px; }
.button:active:not(:disabled) { transform: translateY(1px); filter: brightness(1.15); }
.button:disabled { cursor: not-allowed; }

.color-button { height: max(44px, 10cqw); }
.color-button[data-color="red"] {
  --rim: #ffc59b;
  background: linear-gradient(#fd8773, #b8292a 48%, #6e151b);
}
.color-button[data-color="blue"] {
  --rim: #b6f1ff;
  background: linear-gradient(#53d7fe, #1852bc 48%, #172b74);
}
.color-button[data-color="green"] {
  --rim: #d8fd97;
  background: linear-gradient(#8bd753, #368c35 48%, #1a4b28);
}

.main-button {
  width: max(78px, 27cqw);
  height: max(44px, 11.8cqw);
  font-size: clamp(13px, 3.7cqw, 46px);
  background:
    linear-gradient(110deg, transparent 18%, #ffe3a347 47%, transparent 72%),
    linear-gradient(#ef6c35, #a72420 51%, #640d17);
}

.stage[data-state="result"] .main-button { width: max(92px, 31cqw); }

.result {
  position: absolute;
  inset: 57% 12% auto;
  padding: 4.1cqw 5cqw 4.6cqw;
  border: max(2px, .55cqw) solid #efb852;
  border-radius: 2.2cqw;
  background: linear-gradient(165deg, #62351e, #281714 74%);
  color: #fff0ce;
  text-align: center;
  box-shadow: 0 1.5cqw 5cqw #050907c7, inset 0 0 0 .48cqw #a56b295a, inset 0 .4cqw .7cqw #ffe2a780;
}

.result h1 {
  margin: 0 0 2.8cqw;
  color: #ffe4a3;
  font-size: clamp(18px, 6.1cqw, 73px);
  font-weight: 900;
  line-height: 1.08;
  text-shadow: 0 .3cqw .4cqw #2f0d08;
}

.result dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
}

.result dl > div + div { border-inline-start: 1px solid #e3a95277; }
.result dt { color: #ffd685; font-size: clamp(12px, 3.3cqw, 38px); font-weight: 800; }
.result dd { margin: .45cqw 0 0; font: 900 clamp(24px, 8cqw, 94px) / 1 Georgia, serif; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
