*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f5f2eb;
  color: #2b2623;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

[hidden] {
  display: none !important;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  cursor: crosshair;
}

.stage__canvas,
.stage__ash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage__ash {
  pointer-events: none;
}

.corner-ui {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 26px;
  pointer-events: none;
  z-index: 10;
}

.corner-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.corner-ui--top {
  top: 0;
}

.corner-ui--bottom {
  bottom: 0;
}

.corner-btn,
.corner-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(43, 38, 35, 0.72);
  text-transform: uppercase;
}

.corner-btn {
  pointer-events: auto;
  background: none;
  border: none;
  padding: 6px 8px;
  cursor: pointer;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.corner-btn:hover {
  color: #111111;
}

.fade-overlay {
  position: absolute;
  inset: 0;
  background: #000000;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1.4s ease;
}

.fade-overlay.is-black {
  opacity: 1;
  pointer-events: auto;
}

.fade-replay-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.fade-replay-btn:hover {
  border-color: rgba(255, 255, 255, 0.7);
  color: #ffffff;
}

.gallery-tools { bottom: env(safe-area-inset-bottom, 0px); }
.gallery-tools .corner-btn { min-height:44px; }
.gallery-credit { position:absolute; left:50%; transform:translateX(-50%); white-space:nowrap; text-transform:none; }
.corner-ui .corner-btn, .gallery-credit {
  color:#000;
  font-family: 'Baskerville', 'Palatino Linotype', 'Noto Serif CJK SC', 'Songti SC', Georgia, serif;
  font-size: clamp(12px, 1.2vw, 15px);
  font-weight: 500;
  font-variant: small-caps;
  text-transform: none;
  letter-spacing: .095em;
  line-height: 1.3;
}
.corner-ui .corner-btn:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }
.corner-ui .corner-btn:hover { text-decoration:underline; }
@media(max-width:340px){ .gallery-credit { left:auto; right:16px; transform:none; } }
.stage { height:100dvh; }
.corner-ui .speed-entry { display:flex; align-items:center; gap:5px; pointer-events:auto; background:#f5f2eb; }
.speed-entry input { width:clamp(48px,11vw,108px); accent-color:#913b28; margin:0; }
#btn-fade-images { display:none; }
.is-black #btn-fade-images { display:inline-block; }
.fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f2eb;
  color: #2b2623;
  font-size: 14px;
  z-index: 30;
}

@media (max-width: 640px) {
  .corner-ui {
    padding: 14px 16px;
  }
  .corner-group {
    gap: 8px;
  }
  .corner-btn,
  .corner-label {
    font-size: 10px;
  }
}
