:root {
  --ink: #f4efe4;
  --muted: #b5b4a8;
  --hot: #ff6528;
  --acid: #dbff45;
  --deep: #080a08;
  --shake-x: 0px;
  --shake-y: 0px;
  --scale: 1;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: #050606; }
body {
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, #viewport:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

.app {
  position: relative;
  width: min(100vw, 500px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(ellipse 90% 52% at 50% 44%, #30372d 0%, #121710 52%, #050605 100%);
  transform: translate3d(var(--shake-x), var(--shake-y), 0) scale(var(--scale));
  transition: filter .2s ease;
}
.app::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid #ffffff12;
  pointer-events: none;
  z-index: 30;
}
#scene, .atmosphere, .fx, .flash, .grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#scene { z-index: 1; touch-action: none; }
.atmosphere {
  z-index: 0;
  background: linear-gradient(115deg, transparent 0 43%, #ffffff08 43.2%, transparent 43.5%), radial-gradient(circle at 50% 56%, #8ca65c14 0%, transparent 44%);
  transition: background .7s ease;
  pointer-events: none;
}
.fx { z-index: 8; pointer-events: none; }
.grain {
  z-index: 9;
  opacity: .16;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}
.flash { z-index: 12; opacity: 0; pointer-events: none; background: #fff6df; }
.topbar, .stage-nav, .identity, .interaction, .dock { position: absolute; z-index: 10; }
.topbar {
  inset: 0 0 auto;
  min-height: calc(64px + env(safe-area-inset-top));
  padding: calc(16px + env(safe-area-inset-top)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 800 16px/1 "DIN Condensed", "Avenir Next Condensed", sans-serif;
  letter-spacing: .06em;
  text-shadow: 0 2px 10px #000;
}
.brand i {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  color: #11150c;
  background: var(--acid);
  font: 900 23px/1 sans-serif;
  transform: skew(-8deg);
  box-shadow: 0 0 22px #dbff4575;
}
.top-actions { display: flex; gap: 7px; }
.top-actions button {
  border: 1px solid #ffffff35;
  background: #0c0e0ab8;
  padding: 9px 11px;
  border-radius: 999px;
  font: 700 14px/1 "Apple SD Gothic Neo", sans-serif;
  backdrop-filter: blur(12px);
}
.top-actions button[aria-pressed="false"] { color: #7f8378; }
.stage-nav {
  top: calc(74px + env(safe-area-inset-top));
  right: 17px;
  display: flex;
  align-items: center;
  gap: 5px;
  font: 700 15px/1 "DIN Condensed", "Avenir Next Condensed", sans-serif;
  letter-spacing: .08em;
  opacity: .82;
}
.stage-nav button { border: 0; background: transparent; padding: 4px 8px; font-size: 29px; line-height: 1; }
.stage-nav span { color: #858a7e; }
.stage-nav[hidden] { display: none; }
.identity { top: calc(86px + env(safe-area-inset-top)); left: 22px; right: 22px; pointer-events: none; }
.identity p {
  margin: 0 0 7px;
  color: var(--acid);
  font: 800 15px/1 "DIN Condensed", "Avenir Next Condensed", sans-serif;
  letter-spacing: .16em;
  text-shadow: 0 0 18px #b9ff3566;
  transition: color .45s ease;
}
.identity h1 {
  margin: 0;
  font: 900 clamp(31px, 8.2vw, 42px)/1.02 "Apple SD Gothic Neo", sans-serif;
  letter-spacing: -.075em;
  text-shadow: 0 3px 16px #000, 0 1px 0 #000;
}
.power {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  color: #d7d9cc;
  font: 800 13px/1 "DIN Condensed", "Avenir Next Condensed", sans-serif;
  letter-spacing: .13em;
}
.power i { width: 7px; height: 7px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 10px var(--acid); }
.interaction { inset: 155px 0 74px; z-index: 4; touch-action: none; user-select: none; cursor: grab; -webkit-tap-highlight-color: transparent; }
.interaction:active { cursor: grabbing; }
.interaction.is-done { cursor: default; }
.reticle { position: absolute; inset: 47% 13% auto; aspect-ratio: 1; pointer-events: none; opacity: .34; }
.reticle i { position: absolute; width: 24px; height: 24px; border-color: #dbe0d1; border-style: solid; }
.reticle i:nth-child(1) { left: 0; top: 0; border-width: 1px 0 0 1px; }
.reticle i:nth-child(2) { right: 0; top: 0; border-width: 1px 1px 0 0; }
.reticle i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 1px 1px; }
.reticle i:nth-child(4) { right: 0; bottom: 0; border-width: 0 1px 1px 0; }
.meter { position: absolute; top: 37%; bottom: 17%; right: 17px; width: 4px; border-radius: 9px; background: #ffffff1c; overflow: hidden; }
.meter span { position: absolute; inset: 100% 0 auto; height: 100%; border-radius: inherit; background: linear-gradient(to top, var(--hot), var(--acid)); box-shadow: 0 0 20px #d9ff45aa; transform: translateY(0); }
.gesture {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  text-shadow: 0 2px 12px #000;
}
.gesture strong { font: 900 clamp(25px, 7vw, 34px)/1.08 "Apple SD Gothic Neo", sans-serif; letter-spacing: -.05em; }
.gesture span { color: var(--acid); font: 800 26px/1 "DIN Condensed", "Avenir Next Condensed", sans-serif; letter-spacing: .05em; }
.result {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 39%;
  text-align: center;
  font: 900 clamp(35px, 11vw, 57px)/.93 "Apple SD Gothic Neo", sans-serif;
  letter-spacing: -.085em;
  opacity: 0;
  transform: translateY(14px) scale(.94);
  pointer-events: none;
  text-shadow: 0 5px 30px #000;
}
.result.show { animation: resultIn 1.8s cubic-bezier(.12,.8,.18,1) both; }
@keyframes resultIn {
  0% { opacity: 0; transform: translateY(20px) scale(.86); }
  12%, 70% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-16px) scale(1.04); }
}
.next-device {
  position: absolute;
  left: 50%;
  bottom: 17px;
  transform: translate(-50%, 16px);
  border: 0;
  background: var(--acid);
  color: #10140c;
  border-radius: 999px;
  padding: 15px 23px;
  font-size: 18px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  box-shadow: 0 0 34px #d8ff4575;
}
.next-device.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.dock {
  inset: auto 0 0;
  min-height: calc(72px + env(safe-area-inset-bottom));
  padding: 10px 18px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(to top, #050605f5, #050605ba 58%, transparent);
}
.habit {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 0;
  font-size: 18px;
  font-weight: 750;
  text-align: left;
}
.habit span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.habit b { color: var(--acid); font-size: 14px; white-space: nowrap; }
.days { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.days b { font: 900 34px/1 "DIN Condensed", "Avenir Next Condensed", sans-serif; }
.days span { margin-top: 2px; color: #9fa296; font-size: 13px; font-weight: 700; }
dialog {
  width: min(calc(100% - 30px), 440px);
  margin: auto auto 12px;
  color: var(--ink);
  background: #12150e;
  border: 1px solid #ffffff32;
  border-radius: 24px 24px 12px 12px;
  padding: 23px;
  box-shadow: 0 -24px 80px #000b;
}
dialog::backdrop { background: #000b; backdrop-filter: blur(6px); }
dialog label { display: block; margin-bottom: 12px; color: var(--acid); font-size: 16px; font-weight: 800; }
dialog input { width: 100%; border: 0; border-bottom: 2px solid #f4efe4; background: transparent; color: var(--ink); padding: 12px 0; font-size: 27px; font-weight: 900; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dialog-actions button { border: 1px solid #ffffff31; background: transparent; padding: 12px 17px; border-radius: 999px; font-size: 16px; font-weight: 800; }
.dialog-actions button:last-child { background: var(--acid); border-color: var(--acid); color: #10140c; }
@media (min-width: 560px) {
  body { background: radial-gradient(circle at 50% 45%, #171b13, #040504 58%); }
  .app { box-shadow: 0 0 0 1px #ffffff12, 0 30px 100px #000; }
}
@media (max-height: 660px) {
  .identity { top: calc(70px + env(safe-area-inset-top)); }
  .identity h1 { font-size: 31px; }
  .interaction { top: 133px; }
  .gesture strong { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .app, .result, .next-device { transition: none; }
}
